# beast2wd/bc-staffing-medina architecture

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

- Interactive diagram: https://gitdiagram.com/beast2wd/bc-staffing-medina
- Repository: https://github.com/beast2wd/bc-staffing-medina

## Overview

This is a multi-tenant fire-department staffing and operations platform, with a React client and FastAPI backend. Users sign in, manage staffing, leave, overtime, deployments and personnel, and receive operational updates; command staff also use an incident worksheet with specialized safety and incident tools. The backend combines route modules, shared authentication and tenant scoping, and MongoDB persistence. The README provides no product overview, so the product description follows the repository structure and source excerpts; links for unsampled features are omitted where their callers are not evidenced.

Main entry points: [`backend/database.py`](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/database.py) (MongoDB), [`backend/routes/fillin_routes.py`](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/fillin_routes.py) (Staffing and fill-ins), [`backend/routes/tactical_routes.py`](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/tactical_routes.py) (Tactical incidents), [`backend/routes/overtime_routes.py`](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/overtime_routes.py) (Overtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app["Application shell<br/>[App.js]"]
  node_login["Client login<br/>[ClientLoginPage.js]"]
  node_authctx["Auth context<br/>[AuthContext.js]"]
  node_staffui["Staffing dashboard<br/>[DashboardPage.js]"]
  node_commandui["Command worksheet"]
  node_deploymentui["Deployment tracker"]
end

subgraph group_identity["Identity and tenancy"]
  node_authroutes["Authentication routes<br/>[auth_routes.py]"]
  node_auth["Auth and roles<br/>[auth.py]"]
  node_tenant["Tenant scoping<br/>[tenant_utils.py]"]
end

subgraph group_operations["Staffing operations"]
  node_staffroutes["Staffing and fill-ins<br/>[fillin_routes.py]"]
  node_requests["Leave and requests<br/>[requests_routes.py]"]
  node_overtime["Overtime<br/>[overtime_routes.py]"]
  node_deployments["Deployments"]
  node_reports["Operational reports<br/>[reports_routes.py]"]
  node_minstaff["Minimum staffing"]
end

subgraph group_command["Incident command"]
  node_tactical["Tactical incidents<br/>[tactical_routes.py]"]
  node_incidenttools["Incident safety tools"]
  node_voice["Chief voice assistant"]
  node_forms["ICS forms"]
end

subgraph group_platform["Backend platform"]
  node_server["API application<br/>[server.py]"]
  node_database[("MongoDB<br/>[database.py]")]
  node_models["Domain models<br/>[models.py]"]
  node_notifications["User notifications"]
  node_websocket["Live updates"]
  node_webhooks["Tenant webhooks<br/>[webhook_service.py]"]
end

node_user(("Department users"))

node_user -->|"uses"| node_app
node_app -->|"provides context"| node_authctx
node_app -->|"routes to"| node_staffui
node_app -->|"routes to"| node_commandui
node_app -->|"routes to"| node_deploymentui
node_login -->|"uses"| node_authctx
node_server -->|"registers"| node_authroutes
node_authroutes -->|"uses"| node_auth
node_auth -->|"reads users"| node_database
node_staffroutes -->|"reads and writes"| node_database
node_staffroutes -->|"uses"| node_models
node_staffroutes -->|"authorizes"| node_auth
node_staffroutes -->|"scopes queries"| node_tenant
node_staffroutes -->|"checks staffing"| node_minstaff
node_staffroutes -->|"broadcasts updates"| node_websocket
node_staffroutes -->|"notifies"| node_webhooks
node_requests -->|"reads and writes"| node_database
node_requests -->|"uses routes"| node_overtime
node_requests -->|"creates notifications"| node_notifications
node_overtime -->|"reads and writes"| node_database
node_overtime -->|"checks staffing"| node_minstaff
node_overtime -->|"creates notifications"| node_notifications
node_overtime -->|"broadcasts updates"| node_websocket
node_overtime -->|"notifies"| node_webhooks
node_deployments -->|"reads and writes"| node_database
node_deployments -->|"uses"| node_models
node_deployments -->|"authorizes"| node_auth
node_deployments -->|"scopes queries"| node_tenant
node_deployments -->|"notifies"| node_webhooks
node_reports -->|"reads data"| node_database
node_reports -->|"uses deployment data"| node_deployments
node_tactical -->|"reads and writes"| node_database
node_tactical -->|"authorizes"| node_auth
node_tactical -->|"scopes queries"| node_tenant
node_tactical -->|"broadcasts updates"| node_websocket
node_tactical -->|"uses worksheets"| node_incidenttools
node_tactical -->|"uses ICS forms"| node_forms
node_voice -->|"reads and writes"| node_database
node_voice -->|"dispatches actions"| node_staffroutes
node_voice -->|"dispatches actions"| node_tactical
node_voice -->|"dispatches actions"| node_forms
node_notifications -->|"reads and writes"| node_database
node_notifications -->|"broadcasts alerts"| node_websocket
node_minstaff -->|"reads and writes"| node_database
node_minstaff -->|"creates alerts"| node_notifications
node_minstaff -->|"broadcasts alerts"| node_websocket
node_server -->|"configures"| node_database

click node_app "https://github.com/beast2wd/bc-staffing-medina/blob/main/frontend/src/App.js"
click node_login "https://github.com/beast2wd/bc-staffing-medina/blob/main/frontend/src/pages/ClientLoginPage.js"
click node_authctx "https://github.com/beast2wd/bc-staffing-medina/blob/main/frontend/src/context/AuthContext.js"
click node_staffui "https://github.com/beast2wd/bc-staffing-medina/blob/main/frontend/src/pages/DashboardPage.js"
click node_commandui "https://github.com/beast2wd/bc-staffing-medina/blob/main/frontend/src/pages/command/TacticalWorksheetPage.js"
click node_deploymentui "https://github.com/beast2wd/bc-staffing-medina/tree/main/frontend/src/pages/deployment-tracker"
click node_authroutes "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/auth_routes.py"
click node_auth "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/auth.py"
click node_tenant "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/tenant_utils.py"
click node_staffroutes "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/fillin_routes.py"
click node_requests "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/requests_routes.py"
click node_overtime "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/overtime_routes.py"
click node_deployments "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/deployments_routes.py"
click node_reports "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/reports_routes.py"
click node_minstaff "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/services/min_staffing_service.py"
click node_tactical "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/tactical_routes.py"
click node_incidenttools "https://github.com/beast2wd/bc-staffing-medina/tree/main/backend/services"
click node_voice "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/voice_command_routes.py"
click node_forms "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/ics_forms_routes.py"
click node_server "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/server.py"
click node_database "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/database.py"
click node_models "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/models.py"
click node_notifications "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/user_notifications_routes.py"
click node_websocket "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/websocket_manager.py"
click node_webhooks "https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/services/webhook_service.py"

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_login,node_authctx,node_staffui,node_commandui,node_deploymentui,node_user toneBlue
class node_authroutes,node_auth,node_tenant toneAmber
class node_staffroutes,node_requests,node_overtime,node_deployments,node_reports,node_minstaff toneMint
class node_tactical,node_incidenttools,node_voice,node_forms toneRose
class node_server,node_database,node_models,node_notifications,node_websocket,node_webhooks toneIndigo
```

## Components

### Web application

- [Application shell](https://github.com/beast2wd/bc-staffing-medina/blob/main/frontend/src/App.js): `frontend/src/App.js`
- [Client login](https://github.com/beast2wd/bc-staffing-medina/blob/main/frontend/src/pages/ClientLoginPage.js): `frontend/src/pages/ClientLoginPage.js`
- [Auth context](https://github.com/beast2wd/bc-staffing-medina/blob/main/frontend/src/context/AuthContext.js): `frontend/src/context/AuthContext.js`
- [Staffing dashboard](https://github.com/beast2wd/bc-staffing-medina/blob/main/frontend/src/pages/DashboardPage.js): `frontend/src/pages/DashboardPage.js`
- [Command worksheet](https://github.com/beast2wd/bc-staffing-medina/blob/main/frontend/src/pages/command/TacticalWorksheetPage.js): `frontend/src/pages/command/TacticalWorksheetPage.js`
- [Deployment tracker](https://github.com/beast2wd/bc-staffing-medina/tree/main/frontend/src/pages/deployment-tracker): `frontend/src/pages/deployment-tracker`

### Identity and tenancy

- [Authentication routes](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/auth_routes.py): `backend/routes/auth_routes.py`
- [Auth and roles](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/auth.py): `backend/auth.py`
- [Tenant scoping](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/tenant_utils.py): `backend/tenant_utils.py`

### Staffing operations

- [Staffing and fill-ins](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/fillin_routes.py): `backend/routes/fillin_routes.py`
- [Leave and requests](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/requests_routes.py): `backend/routes/requests_routes.py`
- [Overtime](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/overtime_routes.py): `backend/routes/overtime_routes.py`
- [Deployments](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/deployments_routes.py): `backend/routes/deployments_routes.py`
- [Operational reports](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/reports_routes.py): `backend/routes/reports_routes.py`
- [Minimum staffing](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/services/min_staffing_service.py): `backend/services/min_staffing_service.py`

### Incident command

- [Tactical incidents](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/tactical_routes.py): `backend/routes/tactical_routes.py`
- [Incident safety tools](https://github.com/beast2wd/bc-staffing-medina/tree/main/backend/services): `backend/services`
- [Chief voice assistant](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/voice_command_routes.py): `backend/routes/voice_command_routes.py`
- [ICS forms](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/ics_forms_routes.py): `backend/routes/ics_forms_routes.py`

### Backend platform

- [API application](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/server.py): `backend/server.py`
- [MongoDB](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/database.py): `backend/database.py`
- [Domain models](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/models.py): `backend/models.py`
- [User notifications](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/routes/user_notifications_routes.py): `backend/routes/user_notifications_routes.py`
- [Live updates](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/websocket_manager.py): `backend/websocket_manager.py`
- [Tenant webhooks](https://github.com/beast2wd/bc-staffing-medina/blob/main/backend/services/webhook_service.py): `backend/services/webhook_service.py`

### Other components

- **Department users**

## Connections

- Department users → Application shell: uses
- Application shell → Auth context: provides context (evidence: `frontend/src/App.js`)
- Application shell → Staffing dashboard: routes to (evidence: `frontend/src/App.js`)
- Application shell → Command worksheet: routes to (evidence: `frontend/src/App.js`)
- Application shell → Deployment tracker: routes to (evidence: `frontend/src/App.js`)
- Client login → Auth context: uses (evidence: `frontend/src/pages/ClientLoginPage.js`)
- API application → Authentication routes: registers (evidence: `backend/server.py`)
- Authentication routes → Auth and roles: uses
- Auth and roles → MongoDB: reads users (evidence: `backend/auth.py`)
- Staffing and fill-ins → MongoDB: reads and writes (evidence: `backend/routes/fillin_routes.py`)
- Staffing and fill-ins → Domain models: uses (evidence: `backend/routes/fillin_routes.py`)
- Staffing and fill-ins → Auth and roles: authorizes (evidence: `backend/routes/fillin_routes.py`)
- Staffing and fill-ins → Tenant scoping: scopes queries (evidence: `backend/routes/fillin_routes.py`)
- Staffing and fill-ins → Minimum staffing: checks staffing (evidence: `backend/routes/fillin_routes.py`)
- Staffing and fill-ins → Live updates: broadcasts updates (evidence: `backend/routes/fillin_routes.py`)
- Staffing and fill-ins → Tenant webhooks: notifies (evidence: `backend/routes/fillin_routes.py`)
- Leave and requests → MongoDB: reads and writes (evidence: `backend/routes/requests_routes.py`)
- Leave and requests → Overtime: uses routes (evidence: `backend/routes/requests_routes.py`)
- Leave and requests → User notifications: creates notifications (evidence: `backend/routes/requests_routes.py`)
- Overtime → MongoDB: reads and writes (evidence: `backend/routes/overtime_routes.py`)
- Overtime → Minimum staffing: checks staffing (evidence: `backend/routes/overtime_routes.py`)
- Overtime → User notifications: creates notifications (evidence: `backend/routes/overtime_routes.py`)
- Overtime → Live updates: broadcasts updates (evidence: `backend/routes/overtime_routes.py`)
- Overtime → Tenant webhooks: notifies (evidence: `backend/routes/overtime_routes.py`)
- Deployments → MongoDB: reads and writes (evidence: `backend/routes/deployments_routes.py`)
- Deployments → Domain models: uses (evidence: `backend/routes/deployments_routes.py`)
- Deployments → Auth and roles: authorizes (evidence: `backend/routes/deployments_routes.py`)
- Deployments → Tenant scoping: scopes queries (evidence: `backend/routes/deployments_routes.py`)
- Deployments → Tenant webhooks: notifies (evidence: `backend/routes/deployments_routes.py`)
- Operational reports → MongoDB: reads data (evidence: `backend/routes/reports_routes.py`)
- Operational reports → Deployments: uses deployment data (evidence: `backend/routes/reports_routes.py`)
- Tactical incidents → MongoDB: reads and writes (evidence: `backend/routes/tactical_routes.py`)
- Tactical incidents → Auth and roles: authorizes (evidence: `backend/routes/tactical_routes.py`)
- Tactical incidents → Tenant scoping: scopes queries (evidence: `backend/routes/tactical_routes.py`)
- Tactical incidents → Live updates: broadcasts updates (evidence: `backend/routes/tactical_routes.py`)
- Tactical incidents → Incident safety tools: uses worksheets (evidence: `backend/routes/tactical_routes.py`)
- Tactical incidents → ICS forms: uses ICS forms (evidence: `backend/routes/tactical_routes.py`)
- Chief voice assistant → MongoDB: reads and writes (evidence: `backend/routes/voice_command_routes.py`)
- Chief voice assistant → Staffing and fill-ins: dispatches actions (evidence: `backend/routes/voice_command_routes.py`)
- Chief voice assistant → Tactical incidents: dispatches actions (evidence: `backend/routes/voice_command_routes.py`)
- Chief voice assistant → ICS forms: dispatches actions (evidence: `backend/routes/voice_command_routes.py`)
- User notifications → MongoDB: reads and writes (evidence: `backend/routes/user_notifications_routes.py`)
- User notifications → Live updates: broadcasts alerts (evidence: `backend/routes/user_notifications_routes.py`)
- Minimum staffing → MongoDB: reads and writes (evidence: `backend/services/min_staffing_service.py`)
- Minimum staffing → User notifications: creates alerts (evidence: `backend/services/min_staffing_service.py`)
- Minimum staffing → Live updates: broadcasts alerts (evidence: `backend/services/min_staffing_service.py`)
- API application → MongoDB: configures (evidence: `backend/server.py`)
