# reubenmiddleton/call-roster architecture

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

## Overview

Call Roster is a planning-phase 24/7 practice scheduling product, not yet a shippable application. Its intended workflow is to collect structured preferences, help a scheduler assemble and publish a roster, export a shareable calendar, and track fairness across months. The tree shows API, analytics, export, and a throwaway Python solver prototype; sampled evidence does not establish that the API currently invokes the solver or renders a complete user interface.

Main entry points: [`app/api/practices/[practiceId]/rosters`](https://github.com/reubenmiddleton/call-roster/tree/main/app/api/practices/%5BpracticeId%5D/rosters) (Roster management), [`lib/server/db.ts`](https://github.com/reubenmiddleton/call-roster/blob/main/lib/server/db.ts) (Database access), [`app/api/practices/[practiceId]/swap-requests/route.ts`](https://github.com/reubenmiddleton/call-roster/blob/main/app/api/practices/%5BpracticeId%5D/swap-requests/route.ts) (Swap requests), [`lib/server/tenant-context.ts`](https://github.com/reubenmiddleton/call-roster/blob/main/lib/server/tenant-context.ts) (Tenant scoping)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Roster workflow"]
  node_roster_api["Roster management"]
  node_assignment_api["Assignments<br/>[route.ts]"]
  node_swap_api["Swap requests<br/>[route.ts]"]
  node_preferences["Structured preferences<br/>[request.ts]"]
  node_shift_calendar["Shifts and holidays<br/>[shifts.ts]"]
  node_export["Roster export<br/>[render-html.ts]"]
end

subgraph group_solver["Scheduling engine"]
  node_solver_contract["Solver contract<br/>[contract.py]"]
  node_solver_instance["Solver instance<br/>[instance.py]"]
  node_solver_model["Constraint model<br/>[model.py]"]
end

subgraph group_fairness["Fairness analytics"]
  node_availability["Availability analysis<br/>[availability.ts]"]
  node_burden["Burden calculations<br/>[burden.ts]"]
  node_ledger["Burden ledger<br/>[ledger.ts]"]
  node_equity["Equity measures<br/>[equity.ts]"]
  node_burden_schedules["Burden schedules<br/>[burden-schedule.ts]"]
end

subgraph group_platform["Tenant platform"]
  node_tenant_context["Tenant scoping<br/>[tenant-context.ts]"]
  node_api_db[("Database access<br/>[db.ts]")]
  node_journal["Command journal<br/>[command-journal.ts]"]
end

node_scheduler(("Practice scheduler"))

node_scheduler -->|"manages rosters"| node_roster_api
node_scheduler -->|"submits preferences"| node_preferences
node_roster_api -.->|"checks tenant"| node_tenant_context
node_assignment_api -->|"checks tenant"| node_tenant_context
node_assignment_api -->|"writes assignments"| node_api_db
node_swap_api -->|"checks tenant"| node_tenant_context
node_swap_api -->|"reads assignments"| node_api_db
node_swap_api -->|"records command"| node_journal
node_roster_api -.->|"requests solving"| node_solver_contract
node_solver_contract -->|"builds instance"| node_solver_instance
node_solver_model -->|"uses instance"| node_solver_instance
node_availability -->|"uses shift data"| node_shift_calendar
node_ledger -->|"resolves weights"| node_burden
node_ledger -->|"compares fairness"| node_equity
node_burden_schedules -->|"validates schedules"| node_burden
node_burden_schedules -->|"loads and saves"| node_api_db
node_roster_api -.->|"exports roster"| node_export
node_export -->|"lays out shifts"| node_shift_calendar
node_roster_api -.->|"stores roster"| node_api_db

click node_roster_api "https://github.com/reubenmiddleton/call-roster/tree/main/app/api/practices/%5BpracticeId%5D/rosters"
click node_assignment_api "https://github.com/reubenmiddleton/call-roster/blob/main/app/api/practices/%5BpracticeId%5D/assignments/route.ts"
click node_swap_api "https://github.com/reubenmiddleton/call-roster/blob/main/app/api/practices/%5BpracticeId%5D/swap-requests/route.ts"
click node_preferences "https://github.com/reubenmiddleton/call-roster/blob/main/lib/contract/request.ts"
click node_shift_calendar "https://github.com/reubenmiddleton/call-roster/blob/main/lib/analytics/shifts.ts"
click node_export "https://github.com/reubenmiddleton/call-roster/blob/main/lib/export/render-html.ts"
click node_solver_contract "https://github.com/reubenmiddleton/call-roster/blob/main/solver/src/call_roster_solver/contract.py"
click node_solver_instance "https://github.com/reubenmiddleton/call-roster/blob/main/solver/src/call_roster_solver/instance.py"
click node_solver_model "https://github.com/reubenmiddleton/call-roster/blob/main/solver/src/call_roster_solver/model.py"
click node_availability "https://github.com/reubenmiddleton/call-roster/blob/main/lib/analytics/availability.ts"
click node_burden "https://github.com/reubenmiddleton/call-roster/blob/main/lib/analytics/burden.ts"
click node_ledger "https://github.com/reubenmiddleton/call-roster/blob/main/lib/analytics/ledger.ts"
click node_equity "https://github.com/reubenmiddleton/call-roster/blob/main/lib/analytics/equity.ts"
click node_burden_schedules "https://github.com/reubenmiddleton/call-roster/blob/main/lib/server/burden-schedule.ts"
click node_tenant_context "https://github.com/reubenmiddleton/call-roster/blob/main/lib/server/tenant-context.ts"
click node_api_db "https://github.com/reubenmiddleton/call-roster/blob/main/lib/server/db.ts"
click node_journal "https://github.com/reubenmiddleton/call-roster/blob/main/lib/server/command-journal.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_roster_api,node_assignment_api,node_swap_api,node_preferences,node_shift_calendar,node_export toneBlue
class node_solver_contract,node_solver_instance,node_solver_model toneAmber
class node_availability,node_burden,node_ledger,node_equity,node_burden_schedules toneMint
class node_tenant_context,node_api_db,node_journal,node_scheduler toneRose
```

## Components

### Roster workflow

- [Roster management](https://github.com/reubenmiddleton/call-roster/tree/main/app/api/practices/%5BpracticeId%5D/rosters): `app/api/practices/[practiceId]/rosters`
- [Assignments](https://github.com/reubenmiddleton/call-roster/blob/main/app/api/practices/%5BpracticeId%5D/assignments/route.ts): `app/api/practices/[practiceId]/assignments/route.ts`
- [Swap requests](https://github.com/reubenmiddleton/call-roster/blob/main/app/api/practices/%5BpracticeId%5D/swap-requests/route.ts): `app/api/practices/[practiceId]/swap-requests/route.ts`
- [Structured preferences](https://github.com/reubenmiddleton/call-roster/blob/main/lib/contract/request.ts): `lib/contract/request.ts`
- [Shifts and holidays](https://github.com/reubenmiddleton/call-roster/blob/main/lib/analytics/shifts.ts): `lib/analytics/shifts.ts`
- [Roster export](https://github.com/reubenmiddleton/call-roster/blob/main/lib/export/render-html.ts): `lib/export/render-html.ts`

### Scheduling engine

- [Solver contract](https://github.com/reubenmiddleton/call-roster/blob/main/solver/src/call_roster_solver/contract.py): `solver/src/call_roster_solver/contract.py`
- [Solver instance](https://github.com/reubenmiddleton/call-roster/blob/main/solver/src/call_roster_solver/instance.py): `solver/src/call_roster_solver/instance.py`
- [Constraint model](https://github.com/reubenmiddleton/call-roster/blob/main/solver/src/call_roster_solver/model.py): `solver/src/call_roster_solver/model.py`

### Fairness analytics

- [Availability analysis](https://github.com/reubenmiddleton/call-roster/blob/main/lib/analytics/availability.ts): `lib/analytics/availability.ts`
- [Burden calculations](https://github.com/reubenmiddleton/call-roster/blob/main/lib/analytics/burden.ts): `lib/analytics/burden.ts`
- [Burden ledger](https://github.com/reubenmiddleton/call-roster/blob/main/lib/analytics/ledger.ts): `lib/analytics/ledger.ts`
- [Equity measures](https://github.com/reubenmiddleton/call-roster/blob/main/lib/analytics/equity.ts): `lib/analytics/equity.ts`
- [Burden schedules](https://github.com/reubenmiddleton/call-roster/blob/main/lib/server/burden-schedule.ts): `lib/server/burden-schedule.ts`

### Tenant platform

- [Tenant scoping](https://github.com/reubenmiddleton/call-roster/blob/main/lib/server/tenant-context.ts): `lib/server/tenant-context.ts`
- [Database access](https://github.com/reubenmiddleton/call-roster/blob/main/lib/server/db.ts): `lib/server/db.ts`
- [Command journal](https://github.com/reubenmiddleton/call-roster/blob/main/lib/server/command-journal.ts): `lib/server/command-journal.ts`

### Other components

- **Practice scheduler**

## Connections

- Practice scheduler → Roster management: manages rosters (evidence: `README.md`)
- Practice scheduler → Structured preferences: submits preferences (evidence: `README.md`)
- Roster management → Tenant scoping: checks tenant (evidence: `app/api/practices/[practiceId]/rosters/route.ts`)
- Assignments → Tenant scoping: checks tenant (evidence: `app/api/practices/[practiceId]/assignments/route.ts`)
- Assignments → Database access: writes assignments (evidence: `app/api/practices/[practiceId]/assignments/route.ts`)
- Swap requests → Tenant scoping: checks tenant (evidence: `app/api/practices/[practiceId]/swap-requests/route.ts`)
- Swap requests → Database access: reads assignments (evidence: `app/api/practices/[practiceId]/swap-requests/route.ts`)
- Swap requests → Command journal: records command (evidence: `app/api/practices/[practiceId]/swap-requests/route.ts`)
- Roster management → Solver contract: requests solving
- Solver contract → Solver instance: builds instance (evidence: `solver/src/call_roster_solver/contract.py`)
- Constraint model → Solver instance: uses instance (evidence: `solver/src/call_roster_solver/model.py`)
- Availability analysis → Shifts and holidays: uses shift data (evidence: `lib/analytics/availability.ts`)
- Burden ledger → Burden calculations: resolves weights (evidence: `lib/analytics/ledger.ts`)
- Burden ledger → Equity measures: compares fairness (evidence: `lib/analytics/ledger.ts`)
- Burden schedules → Burden calculations: validates schedules (evidence: `lib/server/burden-schedule.ts`)
- Burden schedules → Database access: loads and saves (evidence: `lib/server/burden-schedule.ts`)
- Roster management → Roster export: exports roster
- Roster export → Shifts and holidays: lays out shifts
- Roster management → Database access: stores roster (evidence: `app/api/practices/[practiceId]/rosters/route.ts`)
