# itai-symon/shmirot architecture

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

## Overview

Shmirot is an offline guard-duty scheduling app. The main workflow is configuring a platoon and activity, generating a fair roster, then viewing and adjusting the live board; local persistence, history, fairness explanations, backup/restore, and the algorithm lab support that workflow. Edges reflect the supplied excerpts, SOURCE INDEX references, and README; unsampled implementation details are not inferred.

Main entry points: [`src/App.tsx`](https://github.com/itai-symon/shmirot/blob/main/src/App.tsx) (App coordinator), [`src/solver/solve.ts`](https://github.com/itai-symon/shmirot/blob/main/src/solver/solve.ts) (Roster solver), [`src/ui/planner.ts`](https://github.com/itai-symon/shmirot/blob/main/src/ui/planner.ts) (Plan orchestration), [`src/storage/db.ts`](https://github.com/itai-symon/shmirot/blob/main/src/storage/db.ts) (Device database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App workflow"]
  node_app["App coordinator<br/>[App.tsx]"]
  node_platoon["Platoon setup<br/>[PlatoonScreen.tsx]"]
  node_activity["Activity setup<br/>[ActivityScreen.tsx]"]
  node_board["Schedule board<br/>[BoardScreen.tsx]"]
  node_backupcard["Backup controls<br/>[BackupCard.tsx]"]
  node_onboarding["Onboarding<br/>[Onboarding.tsx]"]
end

subgraph group_planning["Schedule planning"]
  node_planner["Plan orchestration<br/>[planner.ts]"]
  node_shifts["Shift generation<br/>[shiftGenerator.ts]"]
  node_solverclient["Solver client<br/>[solverClient.ts]"]
  node_worker["Solver worker<br/>[worker.ts]"]
  node_solver["Roster solver<br/>[solve.ts]"]
  node_matching["Cost matching<br/>[matching.ts]"]
  node_certificate["Optimality certificate<br/>[certificate.ts]"]
  node_warnings["Solver warnings<br/>[warnings.ts]"]
end

subgraph group_state["Local data"]
  node_db[("Device database<br/>[db.ts]")]
  node_backup["Backup and restore<br/>[backup.ts]"]
  node_ledger["Duty ledger<br/>[ledger.ts]"]
  node_history["Activity history<br/>[history.ts]"]
end

subgraph group_assurance["Fairness and verification"]
  node_fairness["Fairness calculations<br/>[fairness.ts]"]
  node_score["Board score<br/>[BoardScore.tsx]"]
  node_fairpanel["Fairness panel<br/>[FairnessPanel.tsx]"]
  node_verifier["Independent verifier<br/>[index.ts]"]
  node_verifiermodel["Verifier model<br/>[model.ts]"]
  node_verifiermatching["Verifier matching<br/>[matching.ts]"]
  node_upperbound["Rest upper bound<br/>[upperBound.ts]"]
  node_lab["Algorithm lab<br/>[Lab.tsx]"]
  node_scenarios["Lab scenarios<br/>[scenario.ts]"]
end

node_user(("Platoon user"))

node_user -->|"uses"| node_app
node_app -->|"shows"| node_platoon
node_app -->|"shows"| node_activity
node_app -->|"shows"| node_board
node_app -->|"saves"| node_db
node_app -->|"offers"| node_backupcard
node_app -->|"shows"| node_onboarding
node_app -->|"replans"| node_planner
node_activity -->|"configures"| node_planner
node_planner -->|"generates"| node_shifts
node_planner -->|"requests solve"| node_solverclient
node_solverclient -->|"dispatches"| node_worker
node_solverclient -->|"falls back"| node_solver
node_worker -->|"runs"| node_solver
node_solver -->|"matches seats"| node_matching
node_solver -->|"builds proof"| node_certificate
node_solver -->|"checks risks"| node_warnings
node_platoon -->|"persists roster"| node_db
node_board -->|"edits plan"| node_planner
node_board -->|"renders"| node_fairpanel
node_board -->|"renders"| node_score
node_score -->|"calculates"| node_fairness
node_fairpanel -->|"calculates"| node_fairness
node_backupcard -->|"exports imports"| node_backup
node_backup -->|"reads writes"| node_db
node_db -->|"stores data"| node_ledger
node_db -->|"stores data"| node_history
node_lab -->|"runs algorithm"| node_solver
node_lab -->|"checks result"| node_verifier
node_lab -->|"loads examples"| node_scenarios
node_verifier -->|"checks presence"| node_verifiermodel
node_verifier -->|"uses matching"| node_verifiermatching
node_verifier -->|"checks bound"| node_upperbound
node_upperbound -->|"uses matching"| node_verifiermatching
node_upperbound -->|"uses model"| node_verifiermodel

click node_app "https://github.com/itai-symon/shmirot/blob/main/src/App.tsx"
click node_platoon "https://github.com/itai-symon/shmirot/blob/main/src/ui/PlatoonScreen.tsx"
click node_activity "https://github.com/itai-symon/shmirot/blob/main/src/ui/ActivityScreen.tsx"
click node_board "https://github.com/itai-symon/shmirot/blob/main/src/ui/BoardScreen.tsx"
click node_backupcard "https://github.com/itai-symon/shmirot/blob/main/src/ui/BackupCard.tsx"
click node_onboarding "https://github.com/itai-symon/shmirot/blob/main/src/ui/Onboarding.tsx"
click node_planner "https://github.com/itai-symon/shmirot/blob/main/src/ui/planner.ts"
click node_shifts "https://github.com/itai-symon/shmirot/blob/main/src/storage/shiftGenerator.ts"
click node_solverclient "https://github.com/itai-symon/shmirot/blob/main/src/ui/solverClient.ts"
click node_worker "https://github.com/itai-symon/shmirot/blob/main/src/solver/worker.ts"
click node_solver "https://github.com/itai-symon/shmirot/blob/main/src/solver/solve.ts"
click node_matching "https://github.com/itai-symon/shmirot/blob/main/src/solver/matching.ts"
click node_certificate "https://github.com/itai-symon/shmirot/blob/main/src/solver/certificate.ts"
click node_warnings "https://github.com/itai-symon/shmirot/blob/main/src/solver/warnings.ts"
click node_db "https://github.com/itai-symon/shmirot/blob/main/src/storage/db.ts"
click node_backup "https://github.com/itai-symon/shmirot/blob/main/src/storage/backup.ts"
click node_ledger "https://github.com/itai-symon/shmirot/blob/main/src/ui/ledger.ts"
click node_history "https://github.com/itai-symon/shmirot/blob/main/src/ui/history.ts"
click node_fairness "https://github.com/itai-symon/shmirot/blob/main/src/ui/fairness.ts"
click node_score "https://github.com/itai-symon/shmirot/blob/main/src/ui/BoardScore.tsx"
click node_fairpanel "https://github.com/itai-symon/shmirot/blob/main/src/ui/FairnessPanel.tsx"
click node_verifier "https://github.com/itai-symon/shmirot/blob/main/src/verifier/index.ts"
click node_verifiermodel "https://github.com/itai-symon/shmirot/blob/main/src/verifier/model.ts"
click node_verifiermatching "https://github.com/itai-symon/shmirot/blob/main/src/verifier/matching.ts"
click node_upperbound "https://github.com/itai-symon/shmirot/blob/main/src/verifier/upperBound.ts"
click node_lab "https://github.com/itai-symon/shmirot/blob/main/src/lab/Lab.tsx"
click node_scenarios "https://github.com/itai-symon/shmirot/blob/main/src/lab/scenario.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_platoon,node_activity,node_board,node_backupcard,node_onboarding,node_user toneBlue
class node_planner,node_shifts,node_solverclient,node_worker,node_solver,node_matching,node_certificate,node_warnings toneAmber
class node_db,node_backup,node_ledger,node_history toneMint
class node_fairness,node_score,node_fairpanel,node_verifier,node_verifiermodel,node_verifiermatching,node_upperbound,node_lab,node_scenarios toneRose
```

## Components

### App workflow

- [App coordinator](https://github.com/itai-symon/shmirot/blob/main/src/App.tsx): `src/App.tsx`
- [Platoon setup](https://github.com/itai-symon/shmirot/blob/main/src/ui/PlatoonScreen.tsx): `src/ui/PlatoonScreen.tsx`
- [Activity setup](https://github.com/itai-symon/shmirot/blob/main/src/ui/ActivityScreen.tsx): `src/ui/ActivityScreen.tsx`
- [Schedule board](https://github.com/itai-symon/shmirot/blob/main/src/ui/BoardScreen.tsx): `src/ui/BoardScreen.tsx`
- [Backup controls](https://github.com/itai-symon/shmirot/blob/main/src/ui/BackupCard.tsx): `src/ui/BackupCard.tsx`
- [Onboarding](https://github.com/itai-symon/shmirot/blob/main/src/ui/Onboarding.tsx): `src/ui/Onboarding.tsx`

### Schedule planning

- [Plan orchestration](https://github.com/itai-symon/shmirot/blob/main/src/ui/planner.ts): `src/ui/planner.ts`
- [Shift generation](https://github.com/itai-symon/shmirot/blob/main/src/storage/shiftGenerator.ts): `src/storage/shiftGenerator.ts`
- [Solver client](https://github.com/itai-symon/shmirot/blob/main/src/ui/solverClient.ts): `src/ui/solverClient.ts`
- [Solver worker](https://github.com/itai-symon/shmirot/blob/main/src/solver/worker.ts): `src/solver/worker.ts`
- [Roster solver](https://github.com/itai-symon/shmirot/blob/main/src/solver/solve.ts): `src/solver/solve.ts`
- [Cost matching](https://github.com/itai-symon/shmirot/blob/main/src/solver/matching.ts): `src/solver/matching.ts`
- [Optimality certificate](https://github.com/itai-symon/shmirot/blob/main/src/solver/certificate.ts): `src/solver/certificate.ts`
- [Solver warnings](https://github.com/itai-symon/shmirot/blob/main/src/solver/warnings.ts): `src/solver/warnings.ts`

### Local data

- [Device database](https://github.com/itai-symon/shmirot/blob/main/src/storage/db.ts): `src/storage/db.ts`
- [Backup and restore](https://github.com/itai-symon/shmirot/blob/main/src/storage/backup.ts): `src/storage/backup.ts`
- [Duty ledger](https://github.com/itai-symon/shmirot/blob/main/src/ui/ledger.ts): `src/ui/ledger.ts`
- [Activity history](https://github.com/itai-symon/shmirot/blob/main/src/ui/history.ts): `src/ui/history.ts`

### Fairness and verification

- [Fairness calculations](https://github.com/itai-symon/shmirot/blob/main/src/ui/fairness.ts): `src/ui/fairness.ts`
- [Board score](https://github.com/itai-symon/shmirot/blob/main/src/ui/BoardScore.tsx): `src/ui/BoardScore.tsx`
- [Fairness panel](https://github.com/itai-symon/shmirot/blob/main/src/ui/FairnessPanel.tsx): `src/ui/FairnessPanel.tsx`
- [Independent verifier](https://github.com/itai-symon/shmirot/blob/main/src/verifier/index.ts): `src/verifier/index.ts`
- [Verifier model](https://github.com/itai-symon/shmirot/blob/main/src/verifier/model.ts): `src/verifier/model.ts`
- [Verifier matching](https://github.com/itai-symon/shmirot/blob/main/src/verifier/matching.ts): `src/verifier/matching.ts`
- [Rest upper bound](https://github.com/itai-symon/shmirot/blob/main/src/verifier/upperBound.ts): `src/verifier/upperBound.ts`
- [Algorithm lab](https://github.com/itai-symon/shmirot/blob/main/src/lab/Lab.tsx): `src/lab/Lab.tsx`
- [Lab scenarios](https://github.com/itai-symon/shmirot/blob/main/src/lab/scenario.ts): `src/lab/scenario.ts`

### Other components

- **Platoon user**

## Connections

- Platoon user → App coordinator: uses
- App coordinator → Platoon setup: shows (evidence: `src/App.tsx`)
- App coordinator → Activity setup: shows (evidence: `src/App.tsx`)
- App coordinator → Schedule board: shows (evidence: `src/App.tsx`)
- App coordinator → Device database: saves (evidence: `src/App.tsx`)
- App coordinator → Backup controls: offers (evidence: `src/App.tsx`)
- App coordinator → Onboarding: shows (evidence: `src/App.tsx`)
- App coordinator → Plan orchestration: replans (evidence: `src/App.tsx`)
- Activity setup → Plan orchestration: configures (evidence: `src/ui/ActivityScreen.tsx`)
- Plan orchestration → Shift generation: generates (evidence: `src/ui/planner.ts`)
- Plan orchestration → Solver client: requests solve (evidence: `src/ui/solverClient.ts`)
- Solver client → Solver worker: dispatches (evidence: `src/ui/solverClient.ts`)
- Solver client → Roster solver: falls back (evidence: `src/ui/solverClient.ts`)
- Solver worker → Roster solver: runs (evidence: `src/solver/worker.ts`)
- Roster solver → Cost matching: matches seats (evidence: `src/solver/solve.ts`)
- Roster solver → Optimality certificate: builds proof (evidence: `src/solver/solve.ts`)
- Roster solver → Solver warnings: checks risks (evidence: `src/solver/solve.ts`)
- Platoon setup → Device database: persists roster (evidence: `src/ui/PlatoonScreen.tsx`)
- Schedule board → Plan orchestration: edits plan (evidence: `src/ui/BoardScreen.tsx`)
- Schedule board → Fairness panel: renders (evidence: `src/ui/BoardScreen.tsx`)
- Schedule board → Board score: renders (evidence: `src/ui/BoardScreen.tsx`)
- Board score → Fairness calculations: calculates (evidence: `src/ui/BoardScore.tsx`)
- Fairness panel → Fairness calculations: calculates (evidence: `src/ui/FairnessPanel.tsx`)
- Backup controls → Backup and restore: exports imports (evidence: `src/ui/BackupCard.tsx`)
- Backup and restore → Device database: reads writes (evidence: `src/storage/backup.ts`)
- Device database → Duty ledger: stores data (evidence: `src/storage/db.ts`)
- Device database → Activity history: stores data (evidence: `src/storage/db.ts`)
- Algorithm lab → Roster solver: runs algorithm (evidence: `src/lab/Lab.tsx`)
- Algorithm lab → Independent verifier: checks result (evidence: `src/lab/Lab.tsx`)
- Algorithm lab → Lab scenarios: loads examples (evidence: `src/lab/Lab.tsx`)
- Independent verifier → Verifier model: checks presence (evidence: `src/verifier/index.ts`)
- Independent verifier → Verifier matching: uses matching (evidence: `src/verifier/index.ts`)
- Independent verifier → Rest upper bound: checks bound (evidence: `src/verifier/index.ts`)
- Rest upper bound → Verifier matching: uses matching (evidence: `src/verifier/upperBound.ts`)
- Rest upper bound → Verifier model: uses model (evidence: `src/verifier/upperBound.ts`)
