# zyf3rr3r/chrono-breach-v2 architecture

> Architecture diagram of the GitHub repository zyf3rr3r/chrono-breach-v2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zyf3rr3r/chrono-breach-v2
- Repository: https://github.com/zyf3rr3r/chrono-breach-v2

## Overview

CHRONO//BREACH V2 is a browser-based canvas game with an optional cloud API. Players progress through the game, with local play and saves available offline; when configured, the API supports pilot profiles, save recovery, run submission, leaderboards, and announcements. Administrators use a hosted console to manage pilots and announcements. The backend excerpts show route ownership and persistence; frontend internals were not sampled, so game-to-cloud links follow the README rather than inspected client calls.

Main entry points: [`server/src/app.ts`](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/app.ts) (API routes), [`index.html`](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/index.html) (Canvas game), [`server/src/db/index.ts`](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/db/index.ts) (Database access), [`server/src/index.ts`](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/index.ts) (API server startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_game["Game and saves"]
  node_game_client["Canvas game<br/>[index.html]"]
  node_local_saves[("Local saves and outbox<br/>[index.html]")]
  node_game_config["API endpoint config<br/>[config.js]"]
end

subgraph group_api["Cloud API"]
  node_api_service["API server startup<br/>[index.ts]"]
  node_api_routes["API routes<br/>[app.ts]"]
  node_validation["Request validation<br/>[validation.ts]"]
  node_run_logic["Run plausibility<br/>[logic.ts]"]
  node_moderation["Callsign moderation<br/>[moderation.ts]"]
  node_security["Session and token security<br/>[security.ts]"]
  node_profile["Public profile shaping<br/>[profile.ts]"]
  node_api_config["API configuration<br/>[config.ts]"]
end

subgraph group_data["Persistence"]
  node_db_access["Database access<br/>[index.ts]"]
  node_pg_store[("PostgreSQL records<br/>[schema.ts]")]
end

subgraph group_admin["Administration"]
  node_admin_console["Admin console<br/>[admin.js]"]
  node_admin_routes["Pilot and CMS management<br/>[admin.ts]"]
end

node_player(("Player"))
node_admin_actor(("Administrator"))

node_player -->|"plays"| node_game_client
node_game_client -->|"saves locally"| node_local_saves
node_game_client -.->|"reads endpoint"| node_game_config
node_game_client -->|"syncs cloud data"| node_api_routes
node_local_saves -->|"replays queued writes"| node_api_routes
node_api_service -->|"loads settings"| node_api_config
node_api_service -->|"initializes database"| node_db_access
node_api_service -->|"starts server"| node_api_routes
node_api_routes -->|"registers routes"| node_admin_routes
node_api_routes -->|"reads and writes"| node_db_access
node_api_routes -->|"validates requests"| node_validation
node_api_routes -.->|"checks run plausibility"| node_run_logic
node_api_routes -->|"checks callsigns"| node_moderation
node_api_routes -->|"creates credentials"| node_security
node_api_routes -->|"shapes profile response"| node_profile
node_db_access -->|"uses schema"| node_pg_store
node_admin_actor -->|"manages service"| node_admin_console
node_admin_console -->|"calls admin API"| node_admin_routes
node_admin_routes -.->|"reads and updates records"| node_db_access

click node_game_client "https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/index.html"
click node_local_saves "https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/index.html"
click node_game_config "https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/config.js"
click node_api_service "https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/index.ts"
click node_api_routes "https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/app.ts"
click node_validation "https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/validation.ts"
click node_run_logic "https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/logic.ts"
click node_moderation "https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/moderation.ts"
click node_security "https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/security.ts"
click node_profile "https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/profile.ts"
click node_api_config "https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/config.ts"
click node_db_access "https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/db/index.ts"
click node_pg_store "https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/db/schema.ts"
click node_admin_console "https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/public/admin.js"
click node_admin_routes "https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/admin.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_game_client,node_local_saves,node_game_config toneBlue
class node_api_service,node_api_routes,node_validation,node_run_logic,node_moderation,node_security,node_profile,node_api_config toneAmber
class node_db_access,node_pg_store toneMint
class node_admin_console,node_admin_routes toneRose
class node_player,node_admin_actor toneIndigo
```

## Components

### Game and saves

- [Canvas game](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/index.html): `index.html`
- [Local saves and outbox](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/index.html): `index.html`
- [API endpoint config](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/config.js): `config.js`

### Cloud API

- [API server startup](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/index.ts): `server/src/index.ts`
- [API routes](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/app.ts): `server/src/app.ts`
- [Request validation](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/validation.ts): `server/src/validation.ts`
- [Run plausibility](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/logic.ts): `server/src/logic.ts`
- [Callsign moderation](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/moderation.ts): `server/src/moderation.ts`
- [Session and token security](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/security.ts): `server/src/security.ts`
- [Public profile shaping](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/profile.ts): `server/src/profile.ts`
- [API configuration](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/config.ts): `server/src/config.ts`

### Persistence

- [Database access](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/db/index.ts): `server/src/db/index.ts`
- [PostgreSQL records](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/db/schema.ts): `server/src/db/schema.ts`

### Administration

- [Admin console](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/public/admin.js): `server/public/admin.js`
- [Pilot and CMS management](https://github.com/zyf3rr3r/chrono-breach-v2/blob/main/server/src/admin.ts): `server/src/admin.ts`

### Other components

- **Player**
- **Administrator**

## Connections

- Player → Canvas game: plays (evidence: `README.md`)
- Canvas game → Local saves and outbox: saves locally (evidence: `README.md`)
- Canvas game → API endpoint config: reads endpoint
- Canvas game → API routes: syncs cloud data (evidence: `README.md`)
- Local saves and outbox → API routes: replays queued writes (evidence: `README.md`)
- API server startup → API configuration: loads settings (evidence: `server/src/index.ts`)
- API server startup → Database access: initializes database (evidence: `server/src/index.ts`)
- API server startup → API routes: starts server (evidence: `server/src/index.ts`)
- API routes → Pilot and CMS management: registers routes (evidence: `server/src/app.ts`)
- API routes → Database access: reads and writes (evidence: `server/src/app.ts`)
- API routes → Request validation: validates requests (evidence: `server/src/app.ts`)
- API routes → Run plausibility: checks run plausibility (evidence: `server/src/app.ts`)
- API routes → Callsign moderation: checks callsigns (evidence: `server/src/app.ts`)
- API routes → Session and token security: creates credentials (evidence: `server/src/app.ts`)
- API routes → Public profile shaping: shapes profile response (evidence: `server/src/app.ts`)
- Database access → PostgreSQL records: uses schema (evidence: `server/src/db/index.ts`)
- Administrator → Admin console: manages service (evidence: `README.md`)
- Admin console → Pilot and CMS management: calls admin API (evidence: `README.md`)
- Pilot and CMS management → Database access: reads and updates records (evidence: `server/src/admin.ts`)
