Skip to content

Commit 7f326fd

Browse files
committed
uptd
1 parent 9778062 commit 7f326fd

File tree

13 files changed

+335
-63
lines changed

13 files changed

+335
-63
lines changed

README.md

Lines changed: 81 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,89 @@
1-
╭────────────────────────╮ ╭────────╮ ╭──────────╮
2-
[Proto](../InterDeadProto) │ │ Core │ │ [IT](../InterDeadIT)
3-
╰────────────────────────╯ ╰════════╯ ╰──────────╯
1+
<pre>
2+
╔═════════════════════════════════════════════════════════════════════╗
3+
║ INTERDEAD :: REPOSITORIES ║
4+
╠═════════════════════════════════════════════════════════════════════╣
5+
║ ○ <a href="https://github.com/Zhovten-Games/InterDeadReferenceLibrary">InterDead Reference Library (public)</a> ║
6+
║ Public reference library: documents and notes that are safe ║
7+
║ to share outside the private workspace. ║
8+
║ ║
9+
║ ○ <a href="https://github.com/Zhovten-Games/InterDeadIT">InterDeadIT (website / entry point)</a> ║
10+
║ The website: the public entry point into the InterDead meta-verse.║
11+
║ Hosts the “About” and related public-facing materials. ║
12+
║ ║
13+
║ > InterDeadCore (identity + EFBD core) ║
14+
║ Core modules used by the website: identity/auth and EFBD logic. ║
15+
║ Published as packages and consumed by InterDeadIT. ║
16+
║ ║
17+
║ ○ <a href="https://github.com/Zhovten-Games/PsyFramework">PsyFramework</a> (research / tooling) ║
18+
║ Research and tooling repo referenced by the project; supporting ║
19+
║ framework work that may be mentioned from public docs. ║
20+
╠═════════════════════════════════════════════════════════════════════╣
21+
║ INTERDEADIT ║
22+
║═════════════════════════════════════════════════════════════════════║
23+
║ InterDeadCore is the monorepo for shared InterDead domain packages. ║
24+
║ It keeps identity and EFBD scoring logic decoupled from ║
25+
║ presentation, follows hexagonal architecture boundaries, and ║
26+
║ ships reusable building blocks for downstream runtimes. Each ║
27+
║ package is versioned independently, while the repository maintains ║
28+
║ shared data contracts and operational notes so adapters remain ║
29+
║ consistent across deployments. This layout differs from InterDeadIT,║
30+
║ which hosts a single website surface while consuming these packages ║
31+
║ as dependencies. ║
32+
║═════════════════════════════════╦═══════════════════════════════════║
33+
║ ECHO OF AN UNFADING MEMORY ║ INTERDEAD WIKI (ALL LANGUAGES) ║
34+
╠═════════════════════════════════╬═══════════════════════════════════╣
35+
║ <a href="https://interdead.phantom-draft.com/about/">READ (EN)</a> ║ <a href="https://interdead.fandom.com/wiki/InterDead_Wiki">READ (EN)</a> ║
36+
╠═════════════════════════════════╬═══════════════════════════════════╣
37+
║ <a href="https://interdead.phantom-draft.com/ru/about/">READ (RU)</a> ║ <a href="https://interdead.fandom.com/ru/wiki/Interdead_%D0%92%D0%B8%D0%BA%D0%B8">READ (RU)</a> ║
38+
╠═════════════════════════════════╬═══════════════════════════════════╣
39+
║ <a href="https://interdead.phantom-draft.com/uk/about/">READ (UK)</a> ║ <a href="https://interdead.fandom.com/uk/wiki/Main_Page">READ (UK)</a> ║
40+
╠═════════════════════════════════╬═══════════════════════════════════╣
41+
║ <a href="https://interdead.phantom-draft.com/ja/about/">READ (JA)</a> ║ <a href="https://interdead.fandom.com/ja/wiki/InterDead_Wiki">READ (JA)</a> ║
42+
║═════════════════════════════════╩═══════════════════════════════════║
43+
║ CONTACT ║
44+
╠═════════════════════════════════════════════════════════════════════╣
45+
║ <a href="https://www.linkedin.com/company/zhovten-games/">Zhovten Games — LinkedIn</a> ║
46+
╚═════════════════════════════════════════════════════════════════════╝
47+
</pre>
448

5-
## Introduction
49+
Packages:
50+
- `@interdead/identity-core`: Discord-authenticated identity kernel with pluggable storage.
51+
- `@interdead/efbd-scale`: EFBD scoring domain for adaptive horror design.
652

7-
InterDeadCore is the monorepo that harmonizes the shared services of the metaverse once the prototype branched into independent packages. It keeps domain kernels decoupled from presentation, follows the hexagonal architecture, and ships reusable building blocks for identity, EFBD scoring, and auxiliary tooling.
53+
## Stack
854

9-
## Installation
55+
- TypeScript domain packages
56+
- Cloudflare Workers + D1 + KV (host-provided bindings)
57+
- Hexagonal architecture with ports-and-adapters
1058

11-
Each package is versioned and published independently. Refer to the package-level README files for installation commands:
12-
- `efbd-scale`: D1/KV-aware EFBD scoring domain for adaptive horror design.
13-
- `identity-core`: Discord-authenticated identity kernel with pluggable storage.
59+
## Local dev
1460

15-
## Usage Examples
61+
- Install dependencies per package: `npm install` inside `identity-core/` and `efbd-scale/`.
62+
- Run tests per package: `npm test` (and `npm run typecheck` where available).
1663

17-
See the package READMEs for runnable snippets. A typical host registers the identity core and EFBD scale adapters in its IoC container, then wires presentation controllers in the site repo (`InterDeadIT`).
64+
## Deployment (high-level)
1865

19-
## Additional Notes
66+
- Packages are released independently from the monorepo.
67+
- Downstream repositories (such as InterDeadIT) explicitly upgrade package versions.
68+
- See release details in the documentation index below.
2069

21-
- The Fear Inversion Matrix reference is now kept in `wiki/fear_inversion_matrix.md` for easier cross-linking across packages.
22-
- Aligns with the narrative and deployment orchestrated by the landing site (`InterDeadIT`) and the prototype lore (`InterDeadProto`).
23-
- Contributions should preserve the ports-and-adapters layering to keep packages swappable across runtimes.
24-
- Release flow: bump a package with `npm version patch`, create and push a tag matching the package name (for example `identity-core-v0.1.6` or `efbd-scale-v0.1.3`), and ask downstream repos to upgrade explicitly (e.g., `npm install @interdead/[email protected]`).
25-
- Shared D1 schema: the `profiles` table should exist with `profile_id TEXT PRIMARY KEY`, `data TEXT NOT NULL` (JSON identity aggregate plus auxiliary fields like `completedGames`), `last_cleanup_at TEXT`, `last_cleanup_timezone TEXT`, and `delete_count INTEGER DEFAULT 0`.
70+
## Conventions
71+
72+
- Keep adapters thin and let domain services own the business logic.
73+
- Use object-oriented aggregates and shared base errors to keep responsibilities separated.
74+
- Preserve ports-and-adapters layering so packages remain swappable across runtimes.
75+
76+
## Engineering standards
77+
78+
Engineering standards: Canonical project-wide engineering ideals and development standards are maintained in the InterDead Reference Library (public): https://github.com/Zhovten-Games/InterDeadReferenceLibrary/tree/main/standards/development. This repository follows that canon; local notes here must not override or fork the shared standards.
79+
80+
## Docs index
81+
82+
Start here: [docs/index.md](docs/index.md)
83+
84+
Key references:
85+
86+
- [Architecture overview](docs/architecture/overview.md)
87+
- [Ports and events](docs/architecture/ports-and-events.md)
88+
- [Data contracts](docs/data/schemas.md)
89+
- [Release flow](docs/release/versioning-and-tags.md)

docs/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# InterDeadCore Documentation
2+
3+
InterDeadCore is a monorepo of domain packages. This documentation expands on the short README and keeps architecture, data contracts, and release operations in a single place so downstream repos can adopt the core without copying infrastructure assumptions.
4+
5+
## Architecture
6+
- [Overview](architecture/overview.md)
7+
- [Ports and events](architecture/ports-and-events.md)
8+
9+
## Packages
10+
- [EFBD scale](packages/efbd-scale.md)
11+
- [Identity core](packages/identity-core.md)
12+
13+
## Data contracts
14+
- [D1 schemas](data/schemas.md)
15+
- [KV conventions](data/kv-conventions.md)
16+
17+
## Release
18+
- [Versioning and tags](release/versioning-and-tags.md)
19+
- [Downstream upgrades](release/downstream-upgrades.md)
20+
21+
## Operations
22+
- [Cloudflare bindings](operations/cloudflare-bindings.md)

docs/architecture/overview.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Architecture overview
2+
3+
InterDeadCore contains the domain kernels that are shared across the InterDead ecosystem. Unlike InterDeadIT, which is a single website repository, Core is a monorepo where each package ships independently while still sharing the same architectural boundaries and data contracts.
4+
5+
## Principles
6+
7+
- **Hexagonal architecture**: domain services live at the center and communicate through ports that are implemented by adapters in host runtimes.
8+
- **Object-oriented modeling**: aggregates encapsulate state, inheritance is reserved for shared domain behavior, and explicit interfaces define what adapters must provide.
9+
- **Separation of tasks**: identity, EFBD scoring, and orchestration are kept in separate packages, each with its own service layer and persistence adapters.
10+
11+
## What Core owns
12+
13+
- Domain logic and services for identity and EFBD scoring.
14+
- Ports and event contracts consumed by host applications.
15+
- Canonical data shapes for D1 and KV storage.
16+
17+
## What Core does not own
18+
19+
- UI controllers, templates, or localized content.
20+
- Deployment pipelines for the public website.
21+
- Downstream orchestration code outside the core packages.
22+
23+
## Reference artifacts
24+
25+
The Fear Inversion Matrix is stored in the repository wiki at [`wiki/fear_inversion_matrix.md`](../../wiki/fear_inversion_matrix.md). Treat it as a reference asset that informs EFBD scoring and trigger definitions rather than an executable specification.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Ports and events
2+
3+
InterDeadCore exposes ports instead of framework-specific implementations. Host applications (such as InterDeadIT) provide adapters that satisfy these contracts.
4+
5+
## Identity core ports
6+
7+
- **OAuth provider port**: exchanges authorization codes for identities (Discord adapter by default).
8+
- **Profile repository port**: persists `ProfileMetadata` aggregates in D1 or another storage layer.
9+
- **Session store port**: stores login/session state in KV, memory, or a host-managed store.
10+
- **Event bus port**: notifies downstream adapters when identity events are emitted.
11+
12+
## EFBD scale ports
13+
14+
- **Scale repository port**: saves and queries axis scores for each profile.
15+
- **Trigger log repository port**: records triggers for replay and analytics.
16+
- **Clock port**: normalizes timestamps for trigger ingestion.
17+
- **Logger port**: receives operational telemetry from services.
18+
19+
## Shared event expectations
20+
21+
- Identity completion should emit a profile-ready event so EFBD adapters can initialize scoring.
22+
- Trigger ingestion should emit an axis-updated event for UI surfaces or telemetry.

docs/data/kv-conventions.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# KV conventions
2+
3+
The EFBD scale package can persist trigger logs to KV for analytics or replay. Use a predictable key format so downstream systems can enumerate and expire entries safely.
4+
5+
## Trigger log key format
6+
7+
```
8+
efbd-trigger-log:{profileId}:{timestamp}:{axis}
9+
```
10+
11+
- `profileId`: the profile identifier.
12+
- `timestamp`: ISO or epoch timestamp (consistent with the ingestion clock).
13+
- `axis`: one of the `EBF-*` axis codes.
14+
15+
## Retention recommendations
16+
17+
- Retain trigger logs only as long as analytics requires.
18+
- Consider a TTL aligned with downstream reporting windows (for example, 30–90 days).

docs/data/schemas.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# D1 schemas
2+
3+
InterDeadCore shares a small set of D1 tables across packages. These tables are owned by the host application but must conform to the schemas below so the core packages remain portable.
4+
5+
## Profiles
6+
7+
`profiles` stores the identity aggregate for each player.
8+
9+
| column | type | notes |
10+
| --------------------- | ------- | -------------------------------------------------- |
11+
| `profile_id` | text | primary key for the player profile. |
12+
| `data` | text | JSON identity aggregate and auxiliary metadata. |
13+
| `last_cleanup_at` | text | optional timestamp for cleanup automation. |
14+
| `last_cleanup_timezone` | text | optional timezone for cleanup scheduling. |
15+
| `delete_count` | integer | optional counter for delete operations. |
16+
17+
Minimum required columns are `profile_id` and `data`. The remaining columns are optional but recommended for operational tooling.
18+
19+
## EFBD scale
20+
21+
`efbd_scale` tracks axis scores per profile.
22+
23+
| column | type | notes |
24+
| ---------------- | ------- | --------------------------------------- |
25+
| `profile_id` | text | foreign key to the host profile record. |
26+
| `axis_code` | text | one of the `EBF-*` codes. |
27+
| `score` | integer | cumulative score per axis. |
28+
| `trigger_source` | text | latest trigger origin identifier. |
29+
| `updated_at` | text | ISO timestamp of the last update. |
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Cloudflare bindings
2+
3+
InterDeadCore packages expect certain Cloudflare bindings when hosted in Workers or Pages functions. Align the binding names below with your deployment configuration.
4+
5+
## Required bindings
6+
7+
- **D1**: `INTERDEAD_CORE` for the shared database (`profiles` and `efbd_scale`).
8+
- **KV**: `INTERDEAD_CORE_KV` for trigger logs and session state (if enabled).
9+
10+
## Environment variables
11+
12+
- `IDENTITY_DISCORD_CLIENT_ID`
13+
- `IDENTITY_DISCORD_CLIENT_SECRET`
14+
- `IDENTITY_DISCORD_REDIRECT_URI`
15+
16+
## Optional bindings
17+
18+
- Alternate D1 bindings for staging or localized testing.
19+
- Custom KV namespaces for analytics retention experiments.
20+
21+
## Downstream notes (InterDeadIT)
22+
23+
- The InterDeadIT `interdead-auth` worker expects the KV binding name `IDENTITY_KV` for the same trigger-log persistence and caching behaviors.

docs/packages/efbd-scale.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# EFBD scale package
2+
3+
`@interdead/efbd-scale` is the EFBD (Echoed Big Five of Dread) scale package. It ingests triggers from mini-games, persists axis scores, and exposes query helpers for host runtimes.
4+
5+
## Responsibilities
6+
7+
- Ingest EFBD triggers per profile and update axis scores.
8+
- Clamp scores to maintain consistent bounds.
9+
- Provide query services for snapshots and axis inspection.
10+
11+
## Axis codes
12+
13+
- `EBF-SOCIAL`
14+
- `EBF-MIND`
15+
- `EBF-DECLINE`
16+
- `EBF-EXPOSURE`
17+
- `EBF-ABANDON`
18+
19+
The hyphenated strings above are the canonical persisted codes. TypeScript uses underscore enum identifiers (for example, `AxisCode.EBF_SOCIAL`) while the enum values remain the hyphenated strings (for example, `"EBF-SOCIAL"`).
20+
21+
## Key services
22+
23+
- `ScaleIngestionService` for ingesting triggers.
24+
- `ScaleQueryService` for reading snapshots.
25+
- Repository interfaces for scales and trigger logs.
26+
27+
## Expected adapters
28+
29+
- Scale repository adapter backed by D1 or equivalent storage.
30+
- Trigger log repository adapter backed by KV or external telemetry storage.
31+
- Clock and logger adapters for runtime control.
32+
33+
## Integration notes
34+
35+
- Scores increment by `+1` per trigger and clamp at `100`.
36+
- Use shared data contracts from [Data contracts](../data/schemas.md) and [KV conventions](../data/kv-conventions.md).

docs/packages/identity-core.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Identity core package
2+
3+
`@interdead/identity-core` is the headless identity kernel that wires Discord OAuth with pluggable storage adapters. It keeps presentation concerns out of the core while exposing services and factories that host applications can register in their own containers.
4+
5+
## Responsibilities
6+
7+
- Authenticate players via Discord OAuth.
8+
- Maintain the profile aggregate that stores identity metadata.
9+
- Emit events for downstream services (EFBD scale, UI, analytics).
10+
11+
## Key services
12+
13+
- `createIdentityCore` factory that composes domain services and adapters.
14+
- `LinkService` for OAuth entry and completion flows.
15+
- `ProfileMetadata` aggregate for player identity state.
16+
17+
## Expected adapters
18+
19+
- OAuth adapter for Discord (or custom OAuth provider in staging).
20+
- Profile repository adapter backed by D1 or equivalent storage.
21+
- Session store adapter for OAuth state and nonce persistence.
22+
- Event bus and logger adapters for runtime integration.
23+
24+
## Integration notes
25+
26+
- Store OAuth credentials in environment variables.
27+
- Use adapters to enforce task separation between domain logic and platform-specific infrastructure.
28+
- Review the D1 schema details in [Data contracts](../data/schemas.md).
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Downstream upgrades
2+
3+
InterDeadIT and other downstream repositories explicitly install core packages. After publishing a new version, update downstream packages intentionally to avoid unplanned changes.
4+
5+
## Recommended workflow
6+
7+
1. Announce the new core package version to downstream maintainers.
8+
2. Update the dependency in the downstream repo, for example:
9+
```bash
10+
npm install @interdead/[email protected]
11+
```
12+
3. Verify that runtime adapters still satisfy the ports in the updated package.
13+
4. Run downstream test and deployment checks.
14+
15+
## Monorepo note
16+
17+
Because InterDeadCore is a monorepo, tags and release notes are the primary signals for downstream teams. Avoid assuming that every commit is ready for consumption outside the core packages.

0 commit comments

Comments
 (0)