# sonihet50/orion---world-state-engine architecture

> Architecture diagram of the GitHub repository sonihet50/orion---world-state-engine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sonihet50/orion---world-state-engine
- Repository: https://github.com/sonihet50/orion---world-state-engine

## Overview

Orion is a world-state engine for writers: users organize worlds and manuscripts, submit chapter material for extraction, then inspect and manage the resulting entities, relationships, events, timelines, and contradictions. The frontend route map and backend API router establish the major product surfaces; sampled services and extraction code show how extracted data is resolved into world state. The README contains only the project title, so some feature links and processing integrations are not documented there or visible in sampled call sites; those connections are omitted or marked unverified.

Main entry points: [`Frontend/src/App.tsx`](https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/App.tsx) (Route application), [`backend/app/models`](https://github.com/sonihet50/orion---world-state-engine/tree/main/backend/app/models) (World records), [`backend/app/services/world_state_service.py`](https://github.com/sonihet50/orion---world-state-engine/blob/main/backend/app/services/world_state_service.py) (World-state service), [`backend/app/pipeline/extractor.py`](https://github.com/sonihet50/orion---world-state-engine/blob/main/backend/app/pipeline/extractor.py) (Chapter extractor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Writer workspace"]
  node_app["Route application<br/>[App.tsx]"]
  node_auth["Sign-in<br/>[SignIn.tsx]"]
  node_worlds["Worlds<br/>[Worlds.tsx]"]
  node_manuscripts["Manuscripts<br/>[Manuscripts.tsx]"]
  node_writing["Writing room<br/>[WritingRoom.tsx]"]
  node_ledger["Entity ledger<br/>[EntityLedger.tsx]"]
  node_graphview["World graph<br/>[WorldGraph.tsx]"]
  node_timelineview["World timeline<br/>[WorldTimeline.tsx]"]
  node_contradictionsview["Contradictions<br/>[Contradictions.tsx]"]
  node_assistantview["World assistant<br/>[WorldAssistant.tsx]"]
  node_authstore["Authentication state<br/>[useAuthStore.ts]"]
  node_apiclient["API client<br/>[client.ts]"]
end

subgraph group_api["API and domain"]
  node_api["Versioned API<br/>[router.py]"]
  node_routes["Product endpoints"]
end

subgraph group_processing["Extraction pipeline"]
  node_preprocessing["Text preprocessing"]
  node_extractor["Chapter extractor<br/>[extractor.py]"]
  node_extractstages["Extraction stages"]
end

subgraph group_persistence["World state storage"]
  node_worldservice["World-state service"]
  node_graphservice["Graph service<br/>[graph_service.py]"]
  node_consistency["Consistency checks"]
  node_repositories["Domain repositories"]
  node_models["World records"]
  node_database[("Relational database<br/>[database.py]")]
end

node_writer(("Writer"))
node_llm["Ollama LLM"]

node_writer -->|"uses"| node_app
node_app -->|"routes to"| node_auth
node_app -->|"routes to"| node_worlds
node_app -->|"routes to"| node_manuscripts
node_app -->|"routes to"| node_writing
node_app -->|"routes to"| node_ledger
node_app -->|"routes to"| node_graphview
node_app -->|"routes to"| node_timelineview
node_app -->|"routes to"| node_contradictionsview
node_app -->|"routes to"| node_assistantview
node_app -->|"checks auth"| node_authstore
node_authstore -->|"requests through"| node_apiclient
node_timelineview -->|"requests through"| node_apiclient
node_apiclient -.->|"sends HTTP"| node_api
node_api -->|"registers"| node_routes
node_worldservice -->|"uses"| node_repositories
node_worldservice -->|"uses"| node_consistency
node_worldservice -->|"updates"| node_models
node_graphservice -->|"reads"| node_models
node_graphservice -->|"queries"| node_repositories
node_repositories -->|"accesses"| node_models
node_database -->|"initializes"| node_models
node_preprocessing -.->|"prepares text for"| node_extractor
node_extractor -->|"imports"| node_preprocessing
node_extractor -->|"runs stages"| node_extractstages
node_extractstages -->|"requests extraction"| node_llm

click node_app "https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/App.tsx"
click node_auth "https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/SignIn.tsx"
click node_worlds "https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/Worlds.tsx"
click node_manuscripts "https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/Manuscripts.tsx"
click node_writing "https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/WritingRoom.tsx"
click node_ledger "https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/EntityLedger.tsx"
click node_graphview "https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/WorldGraph.tsx"
click node_timelineview "https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/WorldTimeline.tsx"
click node_contradictionsview "https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/Contradictions.tsx"
click node_assistantview "https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/WorldAssistant.tsx"
click node_authstore "https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/store/useAuthStore.ts"
click node_apiclient "https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/api/client.ts"
click node_api "https://github.com/sonihet50/orion---world-state-engine/blob/main/backend/app/api/v1/router.py"
click node_routes "https://github.com/sonihet50/orion---world-state-engine/tree/main/backend/app/api/v1/routes"
click node_worldservice "https://github.com/sonihet50/orion---world-state-engine/blob/main/backend/app/services/world_state_service.py"
click node_graphservice "https://github.com/sonihet50/orion---world-state-engine/blob/main/backend/app/services/graph_service.py"
click node_consistency "https://github.com/sonihet50/orion---world-state-engine/blob/main/backend/app/services/consistency_service.py"
click node_repositories "https://github.com/sonihet50/orion---world-state-engine/tree/main/backend/app/repositories"
click node_models "https://github.com/sonihet50/orion---world-state-engine/tree/main/backend/app/models"
click node_database "https://github.com/sonihet50/orion---world-state-engine/blob/main/backend/app/core/database.py"
click node_preprocessing "https://github.com/sonihet50/orion---world-state-engine/tree/main/backend/app/preprocessing"
click node_extractor "https://github.com/sonihet50/orion---world-state-engine/blob/main/backend/app/pipeline/extractor.py"
click node_extractstages "https://github.com/sonihet50/orion---world-state-engine/tree/main/extractor/extractor"

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,node_auth,node_worlds,node_manuscripts,node_writing,node_ledger,node_graphview,node_timelineview,node_contradictionsview,node_assistantview,node_authstore,node_apiclient toneBlue
class node_api,node_routes toneAmber
class node_preprocessing,node_extractor,node_extractstages toneMint
class node_worldservice,node_graphservice,node_consistency,node_repositories,node_models,node_database toneRose
class node_writer,node_llm toneIndigo
```

## Components

### Writer workspace

- [Route application](https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/App.tsx): `Frontend/src/App.tsx`
- [Sign-in](https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/SignIn.tsx): `Frontend/src/pages/SignIn.tsx`
- [Worlds](https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/Worlds.tsx): `Frontend/src/pages/Worlds.tsx`
- [Manuscripts](https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/Manuscripts.tsx): `Frontend/src/pages/Manuscripts.tsx`
- [Writing room](https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/WritingRoom.tsx): `Frontend/src/pages/WritingRoom.tsx`
- [Entity ledger](https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/EntityLedger.tsx): `Frontend/src/pages/EntityLedger.tsx`
- [World graph](https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/WorldGraph.tsx): `Frontend/src/pages/WorldGraph.tsx`
- [World timeline](https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/WorldTimeline.tsx): `Frontend/src/pages/WorldTimeline.tsx`
- [Contradictions](https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/Contradictions.tsx): `Frontend/src/pages/Contradictions.tsx`
- [World assistant](https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/pages/WorldAssistant.tsx): `Frontend/src/pages/WorldAssistant.tsx`
- [Authentication state](https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/store/useAuthStore.ts): `Frontend/src/store/useAuthStore.ts`
- [API client](https://github.com/sonihet50/orion---world-state-engine/blob/main/Frontend/src/api/client.ts): `Frontend/src/api/client.ts`

### API and domain

- [Versioned API](https://github.com/sonihet50/orion---world-state-engine/blob/main/backend/app/api/v1/router.py): `backend/app/api/v1/router.py`
- [Product endpoints](https://github.com/sonihet50/orion---world-state-engine/tree/main/backend/app/api/v1/routes): `backend/app/api/v1/routes`

### Extraction pipeline

- [Text preprocessing](https://github.com/sonihet50/orion---world-state-engine/tree/main/backend/app/preprocessing): `backend/app/preprocessing`
- [Chapter extractor](https://github.com/sonihet50/orion---world-state-engine/blob/main/backend/app/pipeline/extractor.py): `backend/app/pipeline/extractor.py`
- [Extraction stages](https://github.com/sonihet50/orion---world-state-engine/tree/main/extractor/extractor): `extractor/extractor`

### World state storage

- [World-state service](https://github.com/sonihet50/orion---world-state-engine/blob/main/backend/app/services/world_state_service.py): `backend/app/services/world_state_service.py`
- [Graph service](https://github.com/sonihet50/orion---world-state-engine/blob/main/backend/app/services/graph_service.py): `backend/app/services/graph_service.py`
- [Consistency checks](https://github.com/sonihet50/orion---world-state-engine/blob/main/backend/app/services/consistency_service.py): `backend/app/services/consistency_service.py`
- [Domain repositories](https://github.com/sonihet50/orion---world-state-engine/tree/main/backend/app/repositories): `backend/app/repositories`
- [World records](https://github.com/sonihet50/orion---world-state-engine/tree/main/backend/app/models): `backend/app/models`
- [Relational database](https://github.com/sonihet50/orion---world-state-engine/blob/main/backend/app/core/database.py): `backend/app/core/database.py`

### Other components

- **Writer**
- **Ollama LLM**

## Connections

- Writer → Route application: uses (evidence: `Frontend/src/App.tsx`)
- Route application → Sign-in: routes to (evidence: `Frontend/src/App.tsx`)
- Route application → Worlds: routes to (evidence: `Frontend/src/App.tsx`)
- Route application → Manuscripts: routes to (evidence: `Frontend/src/App.tsx`)
- Route application → Writing room: routes to (evidence: `Frontend/src/App.tsx`)
- Route application → Entity ledger: routes to (evidence: `Frontend/src/App.tsx`)
- Route application → World graph: routes to (evidence: `Frontend/src/App.tsx`)
- Route application → World timeline: routes to (evidence: `Frontend/src/App.tsx`)
- Route application → Contradictions: routes to (evidence: `Frontend/src/App.tsx`)
- Route application → World assistant: routes to (evidence: `Frontend/src/App.tsx`)
- Route application → Authentication state: checks auth (evidence: `Frontend/src/App.tsx`)
- Authentication state → API client: requests through (evidence: `Frontend/src/store/useAuthStore.ts`)
- World timeline → API client: requests through (evidence: `Frontend/src/pages/WorldTimeline.tsx`)
- API client → Versioned API: sends HTTP
- Versioned API → Product endpoints: registers (evidence: `backend/app/api/v1/router.py`)
- World-state service → Domain repositories: uses (evidence: `backend/app/services/world_state_service.py`)
- World-state service → Consistency checks: uses (evidence: `backend/app/services/world_state_service.py`)
- World-state service → World records: updates (evidence: `backend/app/services/world_state_service.py`)
- Graph service → World records: reads (evidence: `backend/app/services/graph_service.py`)
- Graph service → Domain repositories: queries (evidence: `backend/app/services/graph_service.py`)
- Domain repositories → World records: accesses (evidence: `backend/app/repositories/entity_repo.py`)
- Relational database → World records: initializes (evidence: `backend/app/core/database.py`)
- Text preprocessing → Chapter extractor: prepares text for (evidence: `backend/app/pipeline/extractor.py`)
- Chapter extractor → Text preprocessing: imports (evidence: `backend/app/pipeline/extractor.py`)
- Chapter extractor → Extraction stages: runs stages (evidence: `extractor/extractor/pipeline.py`)
- Extraction stages → Ollama LLM: requests extraction (evidence: `extractor/extractor/relations.py`)
