# jasonwarrenuk/those-who-came-before architecture

> Architecture diagram of the GitHub repository jasonwarrenuk/those-who-came-before, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jasonwarrenuk/those-who-came-before
- Repository: https://github.com/jasonwarrenuk/those-who-came-before

## Overview

#### Purpose and Status
Those Who Came Before is an archaeological artefact-discovery game whose future player interpretation system creates an unreliable narrative. The current implementation is a SvelteKit development shell plus a deterministic MVP artefact-generation pipeline; no playable game loop exists. Design and delivery authority live in `docs/roadmaps/mvp.md` and `.claude/roadmaps.json`.

#### Runtime, Delivery, and Entry Points
Deno runs TypeScript tasks, SvelteKit 2/Svelte 5 provides the UI, and Vite builds the application. The Deno Svelte adapter targets Deno Deploy; GitHub Pages publishing is configured separately in `.github/workflows/pages.yml`.
- Application shell: `src/app.html`, `src/routes/+layout.svelte`, `src/routes/+page.svelte`
- Runtime/dependencies: `deno.json`, `svelte.config.js`, `vite.config.ts`
- Development workbench route: `src/routes/dev/explorer/+page.svelte`

#### Domain Contract Layer
The type modules define the intended bounded contexts before full gameplay orchestration exists: generated artefacts/worlds, descriptions and interpretations, player lens and contradictions, scholarly careers/documents, corpus/visibility, and persistence.
- Core generated-world contracts: `src/lib/types/artefact.ts`, `src/lib/types/world.ts`, `src/lib/types/grammar.ts`
- Future interpretation/career boundary: `src/lib/types/interpretation.ts`, `src/lib/types/lens.ts`, `src/lib/types/career.ts`
- Save and publication-oriented state: `src/lib/types/save.ts`, `src/lib/types/documents.ts`, `src/lib/types/corpus.ts`

#### Deterministic Generation Foundation
Generation is seed-driven through xoshiro128**, with shared statistical utilities. Determinism permits reproducible artefacts, calibration, CLI sampling, and visual exploration. World naming/phonology is an adjacent deterministic subsystem, not yet integrated into a player loop.
- Randomness and distributions: `src/lib/engine/prng.ts`, `src/lib/engine/statistics.ts`
- World-language generation: `src/lib/engine/world/naming.ts`, `src/lib/engine/world/phonology.ts`, `src/lib/engine/world/syllable.ts`
- CLI stage probes: `scripts/dev/sample-artefact.ts`, `scripts/dev/sample-materials.ts`, `scripts/dev/sample-classification.ts`

#### Artefact Generation Pipeline
The primary pipeline transforms a seed and culture/phase context into a normalised artefact and derived readings:
1. Grammar selects weighted geometric components subject to culture/phase biases, complexity budgets, and accumulated constraints.
2. Plausibility validates physical and ergonomic implications.
3. Materials assign physical substances from affinity, technology, scarcity, and trade availability.
4. Decoration resolves motif layers and exchanged/introduced materials, grading execution against material properties.
- Structure and flattening: `src/lib/engine/generation/grammar.ts`, `src/lib/data/grammars/core.ts`, `src/lib/data/grammars/primitives.ts`
- Validation and materials: `src/lib/engine/generation/plausibility.ts`, `src/lib/engine/generation/materials.ts`, `src/lib/data/materials.ts`
- Decoration: `src/lib/engine/generation/decoration.ts`, `src/lib/data/decorations.ts`

#### Classification and Descriptions
Generated anatomy, materials, and decoration are converted into feature values, then tags scored by declarative rules. Culture-phase baseline sampling makes classifications relative to local norms rather than globally absolute. Prose then renders the artefact through distinct registers; observational templates are the current pipeline consumer.
- Feature and tag derivation: `src/lib/engine/generation/classification.ts`, `src/lib/data/classification.ts`, `src/lib/engine/generation/baselines.ts`
- Description assembly: `src/lib/engine/generation/prose.ts`, `src/lib/data/descriptions/observational/index.ts`
- Future interpretive/technical registers: `src/lib/data/descriptions/interpretive/index.ts`, `src/lib/data/descriptions/technical/index.ts`

#### Developer Exploration Boundary
`/dev/explorer` is a dev-only diagnostic UI, not gameplay. Its panels expose pipeline state, seed control, rule calibration, type graphs, and visual representations so generation behavior can be inspected before player-facing integration.
- Explorer coordination: `src/routes/dev/explorer/+page.svelte`, `src/routes/dev/explorer/panels.ts`, `src/routes/dev/explorer/seed.ts`
- Pipeline panels: `src/routes/dev/explorer/structure/+page.svelte`, `src/routes/dev/explorer/materials/+page.svelte`, `src/routes/dev/explorer/tags/+page.svelte`
- Calibration/shared cached baselines: `src/routes/dev/explorer/calibration/ruleCalibration.ts`, `src/routes/dev/explorer/shared/baselineCache.ts`

#### Architectural Gaps
The designed core loops—excavation, subjective observation filtered by lens, publishing, contradiction propagation, scholarly career/social systems, and save-backed longitudinal state—are primarily contracts and specifications, not connected runtime stages. Their intended behavior is documented in `docs/03-core-loops-system-map.md`, `docs/06-knowledge-contradiction-model.md`, and `docs/07-career-social-systems.md`.

Main entry points: [`src/lib/engine/prng.ts`](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/prng.ts) (Seeded PRNG & statistics), [`src/lib/engine/generation/grammar.ts`](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/generation/grammar.ts) (Grammar & structure), [`src/lib/engine/generation/classification.ts`](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/generation/classification.ts) (Features & classification), [`src/routes/dev/explorer/structure/+page.svelte`](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/routes/dev/explorer/structure/%2Bpage.svelte) (Pipeline & calibration panels)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_delivery["Runtime &amp; Delivery"]
  node_app_shell["SvelteKit app shell<br/>Svelte UI<br/>[+page.svelte]"]
  node_runtime_build{{"Deno + Vite build<br/>runtime/build<br/>[deno.json]"}}
  node_deno_deploy{{"Deno Deploy<br/>deployment target<br/>[svelte.config.js]"}}
  node_github_pages{{"GitHub Pages publish<br/>deployment workflow<br/>[pages.yml]"}}
end

subgraph group_domain["Domain Contracts"]
  node_world_contracts["Artefact &amp; world contracts<br/>TypeScript contracts<br/>[artefact.ts]"]
  node_interpretation_contracts["Interpretation &amp; career contracts<br/>TypeScript contracts<br/>[interpretation.ts]"]
  node_future_gameplay["Future gameplay loops<br/>unimplemented orchestration"]
end

subgraph group_generation["Deterministic Generation"]
  node_prng_stats{{"Seeded PRNG &amp; statistics<br/>deterministic foundation<br/>[prng.ts]"}}
  node_world_naming["World naming &amp; phonology<br/>world generator<br/>[naming.ts]"]
  node_grammar["Grammar &amp; structure<br/>pipeline stage<br/>[grammar.ts]"]
  node_plausibility["Physical plausibility<br/>pipeline stage<br/>[plausibility.ts]"]
  node_materials["Material assignment<br/>pipeline stage<br/>[materials.ts]"]
  node_decoration["Decoration resolution<br/>pipeline stage<br/>[decoration.ts]"]
  node_classification["Features &amp; classification<br/>pipeline stage<br/>[classification.ts]"]
  node_prose["Observational prose<br/>pipeline stage<br/>[prose.ts]"]
  node_cli_probes["CLI sampling probes<br/>Deno scripts<br/>[sample-artefact.ts]"]
end

subgraph group_explorer["Developer Explorer"]
  node_explorer_route["/dev/explorer<br/>Svelte diagnostic route<br/>[+page.svelte]"]
  node_explorer_panels["Pipeline &amp; calibration panels<br/>diagnostic UI<br/>[+page.svelte]"]
end

node_roadmap["MVP roadmap<br/>design authority<br/>[mvp.md]"]

node_roadmap -.->|"scopes"| node_app_shell
node_roadmap -.->|"plans"| node_future_gameplay
node_runtime_build -->|"runs and builds"| node_app_shell
node_runtime_build -->|"targets"| node_deno_deploy
node_runtime_build -.->|"also publishes via"| node_github_pages
node_world_contracts -->|"models"| node_grammar
node_world_contracts -->|"types"| node_classification
node_interpretation_contracts -.->|"defines boundaries for"| node_future_gameplay
node_prng_stats -->|"seeds"| node_world_naming
node_prng_stats -->|"drives selection"| node_grammar
node_grammar -->|"structured artefact"| node_plausibility
node_plausibility -->|"validated structure"| node_materials
node_materials -->|"material context"| node_decoration
node_decoration -->|"derived anatomy and surface data"| node_classification
node_classification -->|"features and tags"| node_prose
node_prng_stats -->|"reproducible sampling"| node_cli_probes
node_prose -->|"sample output"| node_cli_probes
node_app_shell -->|"hosts route"| node_explorer_route
node_explorer_route -->|"coordinates"| node_explorer_panels
node_prng_stats -->|"seed control"| node_explorer_route
node_grammar -->|"structure inspection"| node_explorer_panels
node_materials -->|"material inspection"| node_explorer_panels
node_classification -->|"tag calibration"| node_explorer_panels

click node_roadmap "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/docs/roadmaps/mvp.md"
click node_app_shell "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/routes/%2Bpage.svelte"
click node_runtime_build "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/deno.json"
click node_deno_deploy "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/svelte.config.js"
click node_github_pages "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/.github/workflows/pages.yml"
click node_world_contracts "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/types/artefact.ts"
click node_interpretation_contracts "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/types/interpretation.ts"
click node_prng_stats "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/prng.ts"
click node_world_naming "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/world/naming.ts"
click node_grammar "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/generation/grammar.ts"
click node_plausibility "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/generation/plausibility.ts"
click node_materials "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/generation/materials.ts"
click node_decoration "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/generation/decoration.ts"
click node_classification "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/generation/classification.ts"
click node_prose "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/generation/prose.ts"
click node_cli_probes "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/scripts/dev/sample-artefact.ts"
click node_explorer_route "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/routes/dev/explorer/%2Bpage.svelte"
click node_explorer_panels "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/routes/dev/explorer/structure/%2Bpage.svelte"
click node_future_gameplay "https://github.com/jasonwarrenuk/those-who-came-before/blob/main/docs/03-core-loops-system-map.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_shell,node_runtime_build,node_deno_deploy,node_github_pages toneBlue
class node_world_contracts,node_interpretation_contracts,node_future_gameplay toneAmber
class node_prng_stats,node_world_naming,node_grammar,node_plausibility,node_materials,node_decoration,node_classification,node_prose,node_cli_probes toneMint
class node_explorer_route,node_explorer_panels toneRose
class node_roadmap toneNeutral
```

## Components

### Runtime & Delivery

- [SvelteKit app shell](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/routes/%2Bpage.svelte): Svelte UI · Current application entry and shell. · `src/routes/+page.svelte`
- [Deno + Vite build](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/deno.json): runtime/build · Deno runtime with SvelteKit and Vite tooling. · `deno.json`
- [Deno Deploy](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/svelte.config.js): deployment target · `svelte.config.js`
- [GitHub Pages publish](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/.github/workflows/pages.yml): deployment workflow · Separate static publishing configuration. · `.github/workflows/pages.yml`

### Domain Contracts

Designed gameplay boundaries are mostly not runtime-connected.

- [Artefact & world contracts](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/types/artefact.ts): TypeScript contracts · Generated-world and grammar domain model. · `src/lib/types/artefact.ts`
- [Interpretation & career contracts](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/types/interpretation.ts): TypeScript contracts · Future lens, contradiction, career, corpus, and save boundaries. · `src/lib/types/interpretation.ts`
- [Future gameplay loops](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/docs/03-core-loops-system-map.md): unimplemented orchestration · Excavation, lens-filtered observation, publishing, careers, contradictions, and saves remain specified. · `docs/03-core-loops-system-map.md`

### Deterministic Generation

- [Seeded PRNG & statistics](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/prng.ts): deterministic foundation · xoshiro128** randomness and shared distributions. · `src/lib/engine/prng.ts`
- [World naming & phonology](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/world/naming.ts): world generator · Adjacent seed-driven language subsystem. · `src/lib/engine/world/naming.ts`
- [Grammar & structure](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/generation/grammar.ts): pipeline stage · Selects constrained weighted geometry and flattens anatomy. · `src/lib/engine/generation/grammar.ts`
- [Physical plausibility](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/generation/plausibility.ts): pipeline stage · Validates physical and ergonomic implications. · `src/lib/engine/generation/plausibility.ts`
- [Material assignment](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/generation/materials.ts): pipeline stage · Assigns substances from affinity, technology, scarcity, and trade. · `src/lib/engine/generation/materials.ts`
- [Decoration resolution](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/generation/decoration.ts): pipeline stage · Applies motifs, exchange materials, and execution grade. · `src/lib/engine/generation/decoration.ts`
- [Features & classification](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/generation/classification.ts): pipeline stage · Derives features and relative tags using culture-phase baselines. · `src/lib/engine/generation/classification.ts`
- [Observational prose](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/lib/engine/generation/prose.ts): pipeline stage · Renders current observational descriptions. · `src/lib/engine/generation/prose.ts`
- [CLI sampling probes](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/scripts/dev/sample-artefact.ts): Deno scripts · Samples artefacts, materials, and classifications. · `scripts/dev/sample-artefact.ts`

### Developer Explorer

Diagnostic workbench, not player gameplay.

- [/dev/explorer](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/routes/dev/explorer/%2Bpage.svelte): Svelte diagnostic route · Coordinates seed control, pipeline inspection, and visual diagnostics. · `src/routes/dev/explorer/+page.svelte`
- [Pipeline & calibration panels](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/src/routes/dev/explorer/structure/%2Bpage.svelte): diagnostic UI · Structure, materials, tags, and rule calibration views. · `src/routes/dev/explorer/structure/+page.svelte`

### Other components

- [MVP roadmap](https://github.com/jasonwarrenuk/those-who-came-before/blob/main/docs/roadmaps/mvp.md): design authority · Defines current delivery scope and intended systems. · `docs/roadmaps/mvp.md`

## Connections

- MVP roadmap → SvelteKit app shell: scopes
- MVP roadmap → Future gameplay loops: plans
- Deno + Vite build → SvelteKit app shell: runs and builds
- Deno + Vite build → Deno Deploy: targets
- Deno + Vite build → GitHub Pages publish: also publishes via
- Artefact & world contracts → Grammar & structure: models
- Artefact & world contracts → Features & classification: types
- Interpretation & career contracts → Future gameplay loops: defines boundaries for
- Seeded PRNG & statistics → World naming & phonology: seeds
- Seeded PRNG & statistics → Grammar & structure: drives selection
- Grammar & structure → Physical plausibility: structured artefact
- Physical plausibility → Material assignment: validated structure
- Material assignment → Decoration resolution: material context
- Decoration resolution → Features & classification: derived anatomy and surface data
- Features & classification → Observational prose: features and tags
- Seeded PRNG & statistics → CLI sampling probes: reproducible sampling
- Observational prose → CLI sampling probes: sample output
- SvelteKit app shell → /dev/explorer: hosts route
- /dev/explorer → Pipeline & calibration panels: coordinates
- Seeded PRNG & statistics → /dev/explorer: seed control
- Grammar & structure → Pipeline & calibration panels: structure inspection
- Material assignment → Pipeline & calibration panels: material inspection
- Features & classification → Pipeline & calibration panels: tag calibration
