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

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

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

## Overview

Orion is a world-state engine for writers: users create worlds, manage manuscripts and chapters, and inspect extracted entities, timelines, relationships, and contradictions. The visible UI routes those activities; the frontend API client communicates with a FastAPI backend. The backend models world state and includes consistency checking, chat, graph, and timeline capabilities. A separate extractor runs staged story analysis, including mention/coreference, event, temporal, and relationship/fact extraction. The README is only a title, so some backend service and job wiring cannot be verified from the supplied excerpts.

Main entry points: [`Frontend/src/App.tsx`](https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/Frontend/src/App.tsx) (Route application), [`extractor/extractor/pipeline.py`](https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/extractor/extractor/pipeline.py) (Extraction pipeline), [`backend/app/api/v1/routes`](https://github.com/skyswordsaint26/orion---world-state-engine/tree/main/backend/app/api/v1/routes) (Feature routes), [`backend/app/services/world_state_service.py`](https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/backend/app/services/world_state_service.py) (World state service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Writer interface"]
  node_app["Route application<br/>[App.tsx]"]
  node_auth["Sign-in<br/>[SignIn.tsx]"]
  node_worldpages["World pages<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_store["World state store<br/>[useWorldStore.ts]"]
  node_client["API client<br/>[client.ts]"]
end

subgraph group_api["Backend API"]
  node_backend["FastAPI application<br/>[main.py]"]
  node_router["API router<br/>[router.py]"]
  node_routes["Feature routes"]
  node_jobs["Extraction jobs"]
end

subgraph group_domain["World state"]
  node_worldservice["World state service"]
  node_consistency["Consistency checks"]
  node_chatservice["World chat<br/>[chat_service.py]"]
  node_models["World data models"]
  node_database[("SQL database<br/>[database.py]")]
  node_llmclient["Backend LLM client<br/>[llm_client.py]"]
end

subgraph group_extract["Story extraction"]
  node_extractpipeline["Extraction pipeline<br/>[pipeline.py]"]
  node_mentions["Mention extraction<br/>[mentions.py]"]
  node_coref["Coreference<br/>[coref.py]"]
  node_events["Event extraction<br/>[events.py]"]
  node_temporal["Temporal extraction<br/>[temporal.py]"]
  node_relations["Facts and relations<br/>[relations.py]"]
end

node_writer(("Writer"))
node_ollama{{"Ollama service"}}

node_writer -->|"uses"| node_app
node_app -->|"routes"| node_auth
node_app -->|"routes"| node_worldpages
node_app -->|"routes"| node_manuscripts
node_app -->|"routes"| node_writing
node_app -->|"routes"| node_ledger
node_app -->|"routes"| node_graphview
node_app -->|"routes"| node_timelineview
node_app -->|"routes"| node_contradictionsview
node_app -->|"routes"| node_assistantview
node_writing -->|"uses"| node_store
node_writing -->|"calls"| node_client
node_graphview -->|"uses"| node_store
node_graphview -->|"calls"| node_client
node_store -->|"fetches through"| node_client
node_client -->|"HTTP requests"| node_backend
node_backend -->|"mounts"| node_router
node_router -->|"registers"| node_routes
node_worldservice -->|"uses"| node_models
node_worldservice -->|"checks with"| node_consistency
node_worldservice -.->|"persists via"| node_database
node_backend -->|"initializes"| node_database
node_routes -.->|"dispatches to"| node_worldservice
node_routes -.->|"dispatches to"| node_chatservice
node_routes -.->|"dispatches jobs"| node_jobs
node_jobs -.->|"runs"| node_extractpipeline
node_extractpipeline -->|"runs stage"| node_mentions
node_extractpipeline -->|"runs stage"| node_coref
node_extractpipeline -->|"runs stage"| node_events
node_extractpipeline -->|"runs stage"| node_temporal
node_extractpipeline -->|"runs stage"| node_relations
node_relations -.->|"generates with"| node_ollama
node_llmclient -->|"requests chat"| node_ollama
node_chatservice -->|"calls"| node_llmclient

click node_app "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/Frontend/src/App.tsx"
click node_auth "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/Frontend/src/pages/SignIn.tsx"
click node_worldpages "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/Frontend/src/pages/Worlds.tsx"
click node_manuscripts "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/Frontend/src/pages/Manuscripts.tsx"
click node_writing "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/Frontend/src/pages/WritingRoom.tsx"
click node_ledger "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/Frontend/src/pages/EntityLedger.tsx"
click node_graphview "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/Frontend/src/pages/WorldGraph.tsx"
click node_timelineview "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/Frontend/src/pages/WorldTimeline.tsx"
click node_contradictionsview "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/Frontend/src/pages/Contradictions.tsx"
click node_assistantview "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/Frontend/src/pages/WorldAssistant.tsx"
click node_store "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/Frontend/src/store/useWorldStore.ts"
click node_client "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/Frontend/src/api/client.ts"
click node_backend "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/backend/app/main.py"
click node_router "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/backend/app/api/v1/router.py"
click node_routes "https://github.com/skyswordsaint26/orion---world-state-engine/tree/main/backend/app/api/v1/routes"
click node_worldservice "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/backend/app/services/world_state_service.py"
click node_consistency "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/backend/app/services/consistency_service.py"
click node_chatservice "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/backend/app/services/chat_service.py"
click node_models "https://github.com/skyswordsaint26/orion---world-state-engine/tree/main/backend/app/models"
click node_database "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/backend/app/core/database.py"
click node_jobs "https://github.com/skyswordsaint26/orion---world-state-engine/tree/main/backend/app/workers/tasks"
click node_extractpipeline "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/extractor/extractor/pipeline.py"
click node_mentions "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/extractor/extractor/mentions.py"
click node_coref "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/extractor/extractor/coref.py"
click node_events "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/extractor/extractor/events.py"
click node_temporal "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/extractor/extractor/temporal.py"
click node_relations "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/extractor/extractor/relations.py"
click node_llmclient "https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/backend/app/pipeline/llm_client.py"

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_worldpages,node_manuscripts,node_writing,node_ledger,node_graphview,node_timelineview,node_contradictionsview,node_assistantview,node_store,node_client toneBlue
class node_backend,node_router,node_routes,node_jobs toneAmber
class node_worldservice,node_consistency,node_chatservice,node_models,node_database,node_llmclient toneMint
class node_extractpipeline,node_mentions,node_coref,node_events,node_temporal,node_relations toneRose
class node_writer,node_ollama toneIndigo
```

## Components

### Writer interface

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

### Backend API

- [FastAPI application](https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/backend/app/main.py): `backend/app/main.py`
- [API router](https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/backend/app/api/v1/router.py): `backend/app/api/v1/router.py`
- [Feature routes](https://github.com/skyswordsaint26/orion---world-state-engine/tree/main/backend/app/api/v1/routes): `backend/app/api/v1/routes`
- [Extraction jobs](https://github.com/skyswordsaint26/orion---world-state-engine/tree/main/backend/app/workers/tasks): `backend/app/workers/tasks`

### World state

- [World state service](https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/backend/app/services/world_state_service.py): `backend/app/services/world_state_service.py`
- [Consistency checks](https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/backend/app/services/consistency_service.py): `backend/app/services/consistency_service.py`
- [World chat](https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/backend/app/services/chat_service.py): `backend/app/services/chat_service.py`
- [World data models](https://github.com/skyswordsaint26/orion---world-state-engine/tree/main/backend/app/models): `backend/app/models`
- [SQL database](https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/backend/app/core/database.py): `backend/app/core/database.py`
- [Backend LLM client](https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/backend/app/pipeline/llm_client.py): `backend/app/pipeline/llm_client.py`

### Story extraction

- [Extraction pipeline](https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/extractor/extractor/pipeline.py): `extractor/extractor/pipeline.py`
- [Mention extraction](https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/extractor/extractor/mentions.py): `extractor/extractor/mentions.py`
- [Coreference](https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/extractor/extractor/coref.py): `extractor/extractor/coref.py`
- [Event extraction](https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/extractor/extractor/events.py): `extractor/extractor/events.py`
- [Temporal extraction](https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/extractor/extractor/temporal.py): `extractor/extractor/temporal.py`
- [Facts and relations](https://github.com/skyswordsaint26/orion---world-state-engine/blob/main/extractor/extractor/relations.py): `extractor/extractor/relations.py`

### Other components

- **Writer**
- **Ollama service**

## Connections

- Writer → Route application: uses (evidence: `Frontend/src/App.tsx`)
- Route application → Sign-in: routes (evidence: `Frontend/src/App.tsx`)
- Route application → World pages: routes (evidence: `Frontend/src/App.tsx`)
- Route application → Manuscripts: routes (evidence: `Frontend/src/App.tsx`)
- Route application → Writing room: routes (evidence: `Frontend/src/App.tsx`)
- Route application → Entity ledger: routes (evidence: `Frontend/src/App.tsx`)
- Route application → World graph: routes (evidence: `Frontend/src/App.tsx`)
- Route application → World timeline: routes (evidence: `Frontend/src/App.tsx`)
- Route application → Contradictions: routes (evidence: `Frontend/src/App.tsx`)
- Route application → World assistant: routes (evidence: `Frontend/src/App.tsx`)
- Writing room → World state store: uses (evidence: `Frontend/src/pages/WritingRoom.tsx`)
- Writing room → API client: calls (evidence: `Frontend/src/pages/WritingRoom.tsx`)
- World graph → World state store: uses (evidence: `Frontend/src/pages/WorldGraph.tsx`)
- World graph → API client: calls (evidence: `Frontend/src/pages/WorldGraph.tsx`)
- World state store → API client: fetches through (evidence: `Frontend/src/store/useWorldStore.ts`)
- API client → FastAPI application: HTTP requests (evidence: `Frontend/src/api/client.ts`)
- FastAPI application → API router: mounts (evidence: `backend/app/main.py`)
- API router → Feature routes: registers (evidence: `backend/app/api/v1/router.py`)
- World state service → World data models: uses (evidence: `backend/app/services/world_state_service.py`)
- World state service → Consistency checks: checks with (evidence: `backend/app/services/world_state_service.py`)
- World state service → SQL database: persists via
- FastAPI application → SQL database: initializes (evidence: `backend/app/main.py`)
- Feature routes → World state service: dispatches to
- Feature routes → World chat: dispatches to
- Feature routes → Extraction jobs: dispatches jobs
- Extraction jobs → Extraction pipeline: runs
- Extraction pipeline → Mention extraction: runs stage (evidence: `extractor/extractor/pipeline.py`)
- Extraction pipeline → Coreference: runs stage (evidence: `extractor/extractor/pipeline.py`)
- Extraction pipeline → Event extraction: runs stage (evidence: `extractor/extractor/pipeline.py`)
- Extraction pipeline → Temporal extraction: runs stage (evidence: `extractor/extractor/pipeline.py`)
- Extraction pipeline → Facts and relations: runs stage (evidence: `extractor/extractor/pipeline.py`)
- Facts and relations → Ollama service: generates with
- Backend LLM client → Ollama service: requests chat (evidence: `backend/app/pipeline/llm_client.py`)
- World chat → Backend LLM client: calls (evidence: `backend/app/services/chat_service.py`)
