# lanzz-18/gotham-protocol architecture

> Architecture diagram of the GitHub repository lanzz-18/gotham-protocol, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lanzz-18/gotham-protocol
- Repository: https://github.com/lanzz-18/gotham-protocol

## Overview

This is a Batman-themed habit and personal progression app: users record actions against five pillars, earn XP and ranks, review history and weekly progress, and can sync their profile and logs across devices. The principal flow runs from the React app through its store into progression calculations and local persistence, with optional cloud synchronization. The README is a generic Vite template and documents no product features; UI and engine connections below use the supplied source index, so unsampled implementation details are not assumed.

Main entry points: [`src/ui/App.tsx`](https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/App.tsx) (App shell), [`src/store/useStore.ts`](https://github.com/lanzz-18/gotham-protocol/blob/main/src/store/useStore.ts) (App state), [`src/engine/week.ts`](https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/week.ts) (Week summaries), [`src/ui/ProfilePanel.tsx`](https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/ProfilePanel.tsx) (Profile)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["App experience"]
  node_app["App shell<br/>[App.tsx]"]
  node_pillar_view["Pillar logging<br/>[PillarsView.tsx]"]
  node_profile["Profile<br/>[ProfilePanel.tsx]"]
  node_history["History<br/>[HistoryView.tsx]"]
  node_stats["Stats<br/>[StatsView.tsx]"]
  node_rogues["Rogues gallery<br/>[RoguesGallery.tsx]"]
  node_settings["Settings<br/>[SettingsView.tsx]"]
  node_auth["Authentication<br/>[AuthModal.tsx]"]
  node_rest["Rest week<br/>[RestWeek.tsx]"]
end

subgraph group_state["State and sync"]
  node_store["App state<br/>[useStore.ts]"]
  node_localdb[("Local database<br/>[db.ts]")]
  node_outbox["Sync outbox<br/>[outbox.ts]"]
  node_cloudsync["Cloud sync<br/>[cloudSync.ts]"]
end

subgraph group_engine["Progression engine"]
  node_engine_config["Progress config<br/>[config.ts]"]
  node_xp["XP and levels<br/>[xp.ts]"]
  node_ranks["Ranks<br/>[ranks.ts]"]
  node_streak["Streaks<br/>[streak.ts]"]
  node_weeks["Week summaries<br/>[week.ts]"]
  node_nemesis["Nemesis system<br/>[nemesis.ts]"]
  node_series["Activity series<br/>[series.ts]"]
  node_merge["History merge<br/>[sync.ts]"]
  node_clock["Time source<br/>[clock.ts]"]
end

subgraph group_support["Presentation support"]
  node_audio["Sound effects<br/>[audio.ts]"]
  node_format["Formatting and export<br/>[format.ts]"]
  node_icons["Icon rendering<br/>[Icons.tsx]"]
  node_icondata["Icon data<br/>[icon-data.ts]"]
end

node_user(("User"))
node_supabase[("Supabase service")]

node_user -->|"uses"| node_app
node_app -->|"reads and updates"| node_store
node_app -->|"renders"| node_pillar_view
node_app -->|"renders"| node_profile
node_app -->|"renders"| node_history
node_app -->|"renders"| node_stats
node_app -->|"renders"| node_rogues
node_app -->|"renders"| node_settings
node_app -->|"renders"| node_auth
node_app -->|"renders"| node_rest
node_app -->|"exports backup"| node_format
node_app -->|"plays sounds"| node_audio
node_profile -->|"reads state"| node_store
node_profile -->|"calculates progress"| node_xp
node_profile -->|"calculates rank"| node_ranks
node_stats -->|"reads state"| node_store
node_stats -->|"summarizes weeks"| node_weeks
node_stats -->|"uses activity series"| node_series
node_rogues -->|"reads state"| node_store
node_rogues -->|"computes villains"| node_nemesis
node_settings -->|"updates settings"| node_store
node_settings -.->|"uses client"| node_supabase
node_store -->|"loads and saves"| node_localdb
node_store -->|"authenticates and syncs"| node_cloudsync
node_store -->|"queues changes"| node_outbox
node_store -->|"computes pillars"| node_ranks
node_store -->|"checks rest weeks"| node_weeks
node_store -->|"uses defaults"| node_engine_config
node_cloudsync -->|"merges history"| node_merge
node_cloudsync -->|"uses client"| node_supabase
node_outbox -->|"persists operations"| node_localdb
node_outbox -->|"flushes changes"| node_cloudsync
node_ranks -->|"derives levels"| node_xp
node_streak -->|"reads time"| node_clock
node_weeks -->|"uses day rules"| node_streak
node_weeks -->|"reads time"| node_clock
node_nemesis -->|"uses day rules"| node_streak
node_nemesis -->|"converts day index"| node_weeks
node_nemesis -->|"calculates villain XP"| node_xp
node_series -->|"uses day rules"| node_streak
node_series -->|"reads time"| node_clock
node_icons -->|"reads definitions"| node_icondata

click node_app "https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/App.tsx"
click node_pillar_view "https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/PillarsView.tsx"
click node_profile "https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/ProfilePanel.tsx"
click node_history "https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/HistoryView.tsx"
click node_stats "https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/StatsView.tsx"
click node_rogues "https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/RoguesGallery.tsx"
click node_settings "https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/SettingsView.tsx"
click node_auth "https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/AuthModal.tsx"
click node_rest "https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/RestWeek.tsx"
click node_store "https://github.com/lanzz-18/gotham-protocol/blob/main/src/store/useStore.ts"
click node_localdb "https://github.com/lanzz-18/gotham-protocol/blob/main/src/store/db.ts"
click node_outbox "https://github.com/lanzz-18/gotham-protocol/blob/main/src/store/outbox.ts"
click node_cloudsync "https://github.com/lanzz-18/gotham-protocol/blob/main/src/store/cloudSync.ts"
click node_engine_config "https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/config.ts"
click node_xp "https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/xp.ts"
click node_ranks "https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/ranks.ts"
click node_streak "https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/streak.ts"
click node_weeks "https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/week.ts"
click node_nemesis "https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/nemesis.ts"
click node_series "https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/series.ts"
click node_merge "https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/sync.ts"
click node_clock "https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/clock.ts"
click node_audio "https://github.com/lanzz-18/gotham-protocol/blob/main/src/lib/audio.ts"
click node_format "https://github.com/lanzz-18/gotham-protocol/blob/main/src/lib/format.ts"
click node_icons "https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/Icons.tsx"
click node_icondata "https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/icon-data.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_pillar_view,node_profile,node_history,node_stats,node_rogues,node_settings,node_auth,node_rest,node_user toneBlue
class node_store,node_localdb,node_outbox,node_cloudsync,node_supabase toneAmber
class node_engine_config,node_xp,node_ranks,node_streak,node_weeks,node_nemesis,node_series,node_merge,node_clock toneMint
class node_audio,node_format,node_icons,node_icondata toneRose
```

## Components

### App experience

- [App shell](https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/App.tsx): `src/ui/App.tsx`
- [Pillar logging](https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/PillarsView.tsx): `src/ui/PillarsView.tsx`
- [Profile](https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/ProfilePanel.tsx): `src/ui/ProfilePanel.tsx`
- [History](https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/HistoryView.tsx): `src/ui/HistoryView.tsx`
- [Stats](https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/StatsView.tsx): `src/ui/StatsView.tsx`
- [Rogues gallery](https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/RoguesGallery.tsx): `src/ui/RoguesGallery.tsx`
- [Settings](https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/SettingsView.tsx): `src/ui/SettingsView.tsx`
- [Authentication](https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/AuthModal.tsx): `src/ui/AuthModal.tsx`
- [Rest week](https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/RestWeek.tsx): `src/ui/RestWeek.tsx`

### State and sync

- [App state](https://github.com/lanzz-18/gotham-protocol/blob/main/src/store/useStore.ts): `src/store/useStore.ts`
- [Local database](https://github.com/lanzz-18/gotham-protocol/blob/main/src/store/db.ts): `src/store/db.ts`
- [Sync outbox](https://github.com/lanzz-18/gotham-protocol/blob/main/src/store/outbox.ts): `src/store/outbox.ts`
- [Cloud sync](https://github.com/lanzz-18/gotham-protocol/blob/main/src/store/cloudSync.ts): `src/store/cloudSync.ts`

### Progression engine

- [Progress config](https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/config.ts): `src/engine/config.ts`
- [XP and levels](https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/xp.ts): `src/engine/xp.ts`
- [Ranks](https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/ranks.ts): `src/engine/ranks.ts`
- [Streaks](https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/streak.ts): `src/engine/streak.ts`
- [Week summaries](https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/week.ts): `src/engine/week.ts`
- [Nemesis system](https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/nemesis.ts): `src/engine/nemesis.ts`
- [Activity series](https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/series.ts): `src/engine/series.ts`
- [History merge](https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/sync.ts): `src/engine/sync.ts`
- [Time source](https://github.com/lanzz-18/gotham-protocol/blob/main/src/engine/clock.ts): `src/engine/clock.ts`

### Presentation support

- [Sound effects](https://github.com/lanzz-18/gotham-protocol/blob/main/src/lib/audio.ts): `src/lib/audio.ts`
- [Formatting and export](https://github.com/lanzz-18/gotham-protocol/blob/main/src/lib/format.ts): `src/lib/format.ts`
- [Icon rendering](https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/Icons.tsx): `src/ui/Icons.tsx`
- [Icon data](https://github.com/lanzz-18/gotham-protocol/blob/main/src/ui/icon-data.ts): `src/ui/icon-data.ts`

### Other components

- **User**
- **Supabase service**

## Connections

- User → App shell: uses
- App shell → App state: reads and updates (evidence: `src/ui/App.tsx`)
- App shell → Pillar logging: renders (evidence: `src/ui/App.tsx`)
- App shell → Profile: renders (evidence: `src/ui/App.tsx`)
- App shell → History: renders (evidence: `src/ui/App.tsx`)
- App shell → Stats: renders (evidence: `src/ui/App.tsx`)
- App shell → Rogues gallery: renders (evidence: `src/ui/App.tsx`)
- App shell → Settings: renders (evidence: `src/ui/App.tsx`)
- App shell → Authentication: renders (evidence: `src/ui/App.tsx`)
- App shell → Rest week: renders (evidence: `src/ui/App.tsx`)
- App shell → Formatting and export: exports backup (evidence: `src/ui/App.tsx`)
- App shell → Sound effects: plays sounds (evidence: `src/ui/App.tsx`)
- Profile → App state: reads state (evidence: `src/ui/ProfilePanel.tsx`)
- Profile → XP and levels: calculates progress (evidence: `src/ui/ProfilePanel.tsx`)
- Profile → Ranks: calculates rank (evidence: `src/ui/ProfilePanel.tsx`)
- Stats → App state: reads state (evidence: `src/ui/StatsView.tsx`)
- Stats → Week summaries: summarizes weeks (evidence: `src/ui/StatsView.tsx`)
- Stats → Activity series: uses activity series (evidence: `src/ui/StatsView.tsx`)
- Rogues gallery → App state: reads state (evidence: `src/ui/RoguesGallery.tsx`)
- Rogues gallery → Nemesis system: computes villains (evidence: `src/ui/RoguesGallery.tsx`)
- Settings → App state: updates settings (evidence: `src/ui/SettingsView.tsx`)
- Settings → Supabase service: uses client (evidence: `src/ui/SettingsView.tsx`)
- App state → Local database: loads and saves (evidence: `src/store/useStore.ts`)
- App state → Cloud sync: authenticates and syncs (evidence: `src/store/useStore.ts`)
- App state → Sync outbox: queues changes (evidence: `src/store/useStore.ts`)
- App state → Ranks: computes pillars (evidence: `src/store/useStore.ts`)
- App state → Week summaries: checks rest weeks (evidence: `src/store/useStore.ts`)
- App state → Progress config: uses defaults (evidence: `src/store/useStore.ts`)
- Cloud sync → History merge: merges history (evidence: `src/store/cloudSync.ts`)
- Cloud sync → Supabase service: uses client (evidence: `src/store/cloudSync.ts`)
- Sync outbox → Local database: persists operations (evidence: `src/store/outbox.ts`)
- Sync outbox → Cloud sync: flushes changes (evidence: `src/store/outbox.ts`)
- Ranks → XP and levels: derives levels (evidence: `src/engine/ranks.ts`)
- Streaks → Time source: reads time (evidence: `src/engine/streak.ts`)
- Week summaries → Streaks: uses day rules (evidence: `src/engine/week.ts`)
- Week summaries → Time source: reads time (evidence: `src/engine/week.ts`)
- Nemesis system → Streaks: uses day rules (evidence: `src/engine/nemesis.ts`)
- Nemesis system → Week summaries: converts day index (evidence: `src/engine/nemesis.ts`)
- Nemesis system → XP and levels: calculates villain XP (evidence: `src/engine/nemesis.ts`)
- Activity series → Streaks: uses day rules (evidence: `src/engine/series.ts`)
- Activity series → Time source: reads time (evidence: `src/engine/series.ts`)
- Icon rendering → Icon data: reads definitions (evidence: `src/ui/Icons.tsx`)
