# rocksonjerom/simlight_prototype architecture

> Architecture diagram of the GitHub repository rocksonjerom/simlight_prototype, 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/rocksonjerom/simlight_prototype
- Repository: https://github.com/rocksonjerom/simlight_prototype

## Overview

SimLight is a multi-tenant simulation authoring and learning platform. Faculty register or sign in, create simulations through manual, AI, or document-based workflows, then publish or assign them; learners access public play routes, make decisions, and receive reports. A second, round-based V2 experience has its own builder and decision engine. The server provides authentication, generation, session and scoring APIs, backed by SQLite by default or optional PostgreSQL. The README documents tenancy and role-based access; some UI-to-API links are inferred from API capabilities rather than inspected call sites.

Main entry points: [`src/App.tsx`](https://github.com/rocksonjerom/simlight_prototype/blob/main/src/App.tsx) (Application routes), [`src/api/client.ts`](https://github.com/rocksonjerom/simlight_prototype/blob/main/src/api/client.ts) (API client), [`server/routes.ts`](https://github.com/rocksonjerom/simlight_prototype/blob/main/server/routes.ts) (Simulation API), [`server/store/index.ts`](https://github.com/rocksonjerom/simlight_prototype/blob/main/server/store/index.ts) (Store dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and catalog"]
  node_app["Application routes<br/>[App.tsx]"]
  node_authui["Auth context<br/>[AuthContext.tsx]"]
  node_catalog["Simulation catalog<br/>[BrowsePage.tsx]"]
end

subgraph group_authoring["Simulation authoring"]
  node_author["Creator workflow<br/>[CreatorPage.tsx]"]
  node_simcontext["Simulation state"]
  node_contentedit["Content editor"]
  node_v2builder["V2 builder"]
end

subgraph group_play["Play and reporting"]
  node_player["Learner player"]
  node_v2play["V2 player<br/>[V2PlayPage.tsx]"]
  node_engine["V2 decision engine<br/>[v2Engine.ts]"]
  node_reports["Performance reports"]
end

subgraph group_services["Server services"]
  node_client["API client<br/>[client.ts]"]
  node_api["Simulation API<br/>[routes.ts]"]
  node_authapi["Authentication API<br/>[routes.ts]"]
  node_guard["Auth middleware<br/>[middleware.ts]"]
  node_llm["LLM providers<br/>[providers.ts]"]
  node_scoring["Scoring service<br/>[scoring.ts]"]
  node_platform["Platform management<br/>[routes.ts]"]
end

subgraph group_storage["Persistence"]
  node_store["Store dispatcher<br/>[index.ts]"]
  node_sqlite[("SQLite database<br/>[database.ts]")]
  node_pgstore[("PostgreSQL store<br/>[store.ts]")]
end

node_faculty(("Faculty"))
node_learner(("Learner"))

node_faculty -->|"opens"| node_app
node_learner -->|"opens public play"| node_app
node_app -->|"wraps routes"| node_authui
node_app -->|"routes to"| node_catalog
node_app -->|"routes to"| node_author
node_app -->|"routes to"| node_player
node_app -->|"routes to"| node_v2play
node_app -->|"routes to"| node_reports
node_author -.->|"edits state"| node_simcontext
node_simcontext -->|"requests generation"| node_client
node_contentedit -->|"saves content"| node_client
node_v2builder -.->|"saves simulation"| node_client
node_v2play -.->|"applies decisions"| node_engine
node_reports -->|"requests report"| node_client
node_authui -->|"uses API"| node_client
node_client -->|"HTTP requests"| node_authapi
node_client -->|"HTTP requests"| node_api
node_api -->|"generates content"| node_llm
node_api -->|"scores decisions"| node_scoring
node_api -->|"reads and writes"| node_store
node_authapi -->|"manages accounts"| node_store
node_api -->|"protects routes"| node_guard
node_store -->|"dispatches SQLite"| node_sqlite
node_store -->|"dispatches PostgreSQL"| node_pgstore
node_platform -->|"uses store"| node_store

click node_app "https://github.com/rocksonjerom/simlight_prototype/blob/main/src/App.tsx"
click node_authui "https://github.com/rocksonjerom/simlight_prototype/blob/main/src/context/AuthContext.tsx"
click node_catalog "https://github.com/rocksonjerom/simlight_prototype/blob/main/src/pages/BrowsePage.tsx"
click node_author "https://github.com/rocksonjerom/simlight_prototype/blob/main/src/pages/CreatorPage.tsx"
click node_simcontext "https://github.com/rocksonjerom/simlight_prototype/blob/main/src/context/SimulationContext.tsx"
click node_contentedit "https://github.com/rocksonjerom/simlight_prototype/blob/main/src/components/content/ContentBlockEditor.tsx"
click node_v2builder "https://github.com/rocksonjerom/simlight_prototype/blob/main/src/components/v2/builder/V2SimulationBuilder.tsx"
click node_player "https://github.com/rocksonjerom/simlight_prototype/blob/main/src/pages/LearnerPlayerPage.tsx"
click node_v2play "https://github.com/rocksonjerom/simlight_prototype/blob/main/src/pages/v2/V2PlayPage.tsx"
click node_engine "https://github.com/rocksonjerom/simlight_prototype/blob/main/src/engine/v2Engine.ts"
click node_reports "https://github.com/rocksonjerom/simlight_prototype/blob/main/src/pages/PerformanceReportPage.tsx"
click node_client "https://github.com/rocksonjerom/simlight_prototype/blob/main/src/api/client.ts"
click node_api "https://github.com/rocksonjerom/simlight_prototype/blob/main/server/routes.ts"
click node_authapi "https://github.com/rocksonjerom/simlight_prototype/blob/main/server/auth/routes.ts"
click node_guard "https://github.com/rocksonjerom/simlight_prototype/blob/main/server/auth/middleware.ts"
click node_llm "https://github.com/rocksonjerom/simlight_prototype/blob/main/server/llm/providers.ts"
click node_scoring "https://github.com/rocksonjerom/simlight_prototype/blob/main/server/services/scoring.ts"
click node_store "https://github.com/rocksonjerom/simlight_prototype/blob/main/server/store/index.ts"
click node_sqlite "https://github.com/rocksonjerom/simlight_prototype/blob/main/server/database.ts"
click node_pgstore "https://github.com/rocksonjerom/simlight_prototype/blob/main/server/pg/store.ts"
click node_platform "https://github.com/rocksonjerom/simlight_prototype/blob/main/server/platform/routes.ts"

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_authui,node_catalog toneBlue
class node_author,node_simcontext,node_contentedit,node_v2builder toneAmber
class node_player,node_v2play,node_engine,node_reports toneMint
class node_client,node_api,node_authapi,node_guard,node_llm,node_scoring,node_platform toneRose
class node_store,node_sqlite,node_pgstore,node_faculty,node_learner toneIndigo
```

## Components

### Access and catalog

- [Application routes](https://github.com/rocksonjerom/simlight_prototype/blob/main/src/App.tsx): `src/App.tsx`
- [Auth context](https://github.com/rocksonjerom/simlight_prototype/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [Simulation catalog](https://github.com/rocksonjerom/simlight_prototype/blob/main/src/pages/BrowsePage.tsx): `src/pages/BrowsePage.tsx`

### Simulation authoring

- [Creator workflow](https://github.com/rocksonjerom/simlight_prototype/blob/main/src/pages/CreatorPage.tsx): `src/pages/CreatorPage.tsx`
- [Simulation state](https://github.com/rocksonjerom/simlight_prototype/blob/main/src/context/SimulationContext.tsx): `src/context/SimulationContext.tsx`
- [Content editor](https://github.com/rocksonjerom/simlight_prototype/blob/main/src/components/content/ContentBlockEditor.tsx): `src/components/content/ContentBlockEditor.tsx`
- [V2 builder](https://github.com/rocksonjerom/simlight_prototype/blob/main/src/components/v2/builder/V2SimulationBuilder.tsx): `src/components/v2/builder/V2SimulationBuilder.tsx`

### Play and reporting

- [Learner player](https://github.com/rocksonjerom/simlight_prototype/blob/main/src/pages/LearnerPlayerPage.tsx): `src/pages/LearnerPlayerPage.tsx`
- [V2 player](https://github.com/rocksonjerom/simlight_prototype/blob/main/src/pages/v2/V2PlayPage.tsx): `src/pages/v2/V2PlayPage.tsx`
- [V2 decision engine](https://github.com/rocksonjerom/simlight_prototype/blob/main/src/engine/v2Engine.ts): `src/engine/v2Engine.ts`
- [Performance reports](https://github.com/rocksonjerom/simlight_prototype/blob/main/src/pages/PerformanceReportPage.tsx): `src/pages/PerformanceReportPage.tsx`

### Server services

- [API client](https://github.com/rocksonjerom/simlight_prototype/blob/main/src/api/client.ts): `src/api/client.ts`
- [Simulation API](https://github.com/rocksonjerom/simlight_prototype/blob/main/server/routes.ts): `server/routes.ts`
- [Authentication API](https://github.com/rocksonjerom/simlight_prototype/blob/main/server/auth/routes.ts): `server/auth/routes.ts`
- [Auth middleware](https://github.com/rocksonjerom/simlight_prototype/blob/main/server/auth/middleware.ts): `server/auth/middleware.ts`
- [LLM providers](https://github.com/rocksonjerom/simlight_prototype/blob/main/server/llm/providers.ts): `server/llm/providers.ts`
- [Scoring service](https://github.com/rocksonjerom/simlight_prototype/blob/main/server/services/scoring.ts): `server/services/scoring.ts`
- [Platform management](https://github.com/rocksonjerom/simlight_prototype/blob/main/server/platform/routes.ts): `server/platform/routes.ts`

### Persistence

- [Store dispatcher](https://github.com/rocksonjerom/simlight_prototype/blob/main/server/store/index.ts): `server/store/index.ts`
- [SQLite database](https://github.com/rocksonjerom/simlight_prototype/blob/main/server/database.ts): `server/database.ts`
- [PostgreSQL store](https://github.com/rocksonjerom/simlight_prototype/blob/main/server/pg/store.ts): `server/pg/store.ts`

### Other components

- **Faculty**
- **Learner**

## Connections

- Faculty → Application routes: opens (evidence: `README.md`)
- Learner → Application routes: opens public play (evidence: `README.md`)
- Application routes → Auth context: wraps routes (evidence: `src/App.tsx`)
- Application routes → Simulation catalog: routes to (evidence: `src/App.tsx`)
- Application routes → Creator workflow: routes to (evidence: `src/App.tsx`)
- Application routes → Learner player: routes to (evidence: `src/App.tsx`)
- Application routes → V2 player: routes to (evidence: `src/App.tsx`)
- Application routes → Performance reports: routes to (evidence: `src/App.tsx`)
- Creator workflow → Simulation state: edits state
- Simulation state → API client: requests generation (evidence: `src/context/SimulationContext.tsx`)
- Content editor → API client: saves content (evidence: `src/components/content/ContentBlockEditor.tsx`)
- V2 builder → API client: saves simulation
- V2 player → V2 decision engine: applies decisions
- Performance reports → API client: requests report (evidence: `src/pages/PerformanceReportPage.tsx`)
- Auth context → API client: uses API (evidence: `src/context/AuthContext.tsx`)
- API client → Authentication API: HTTP requests (evidence: `src/api/client.ts`)
- API client → Simulation API: HTTP requests (evidence: `src/api/client.ts`)
- Simulation API → LLM providers: generates content (evidence: `server/routes.ts`)
- Simulation API → Scoring service: scores decisions (evidence: `server/routes.ts`)
- Simulation API → Store dispatcher: reads and writes (evidence: `server/routes.ts`)
- Authentication API → Store dispatcher: manages accounts (evidence: `server/auth/routes.ts`)
- Simulation API → Auth middleware: protects routes (evidence: `server/routes.ts`)
- Store dispatcher → SQLite database: dispatches SQLite (evidence: `server/store/index.ts`)
- Store dispatcher → PostgreSQL store: dispatches PostgreSQL (evidence: `server/store/index.ts`)
- Platform management → Store dispatcher: uses store (evidence: `server/platform/routes.ts`)
