# joshishreekar/campusshieldai architecture

> Architecture diagram of the GitHub repository joshishreekar/campusshieldai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joshishreekar/campusshieldai
- Repository: https://github.com/joshishreekar/campusshieldai

## Overview

CampusShield is a campus safety and emergency-management application. Users authenticate in the React client, then submit SOS/complaints or manage incidents; FastAPI routes persist incident records, while department queues, history, evidence, analytics, and notifications support response. A parallel camera workflow captures video and produces candidate AI alerts for staff review. The README describes additional planned capabilities, but explicitly says several workflows remain incomplete; paths and connections for unsampled features are therefore shown only where supported, with no assumed calls.

Main entry points: [`backend/app/main.py`](https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/main.py) (API application), [`backend/app/services/camera_runtime.py`](https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/services/camera_runtime.py) (Camera runtime), [`backend/app/db/session.py`](https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/db/session.py) (PostgreSQL data), [`frontend/src/pages/Dashboard.jsx`](https://github.com/joshishreekar/campusshieldai/blob/main/frontend/src/pages/Dashboard.jsx) (Dashboard views)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Role dashboards<br/>[App.jsx]"]
  node_authui["Session context<br/>[AuthContext.jsx]"]
  node_authsvc["Auth requests<br/>[authService.js]"]
  node_dashboard["Dashboard views<br/>[Dashboard.jsx]"]
  node_reporter["Reporter workflow"]
  node_incsvc["Incident requests<br/>[incidentService.js]"]
  node_wsclient["Live updates client"]
end

subgraph group_api["Backend API"]
  node_main["API application<br/>[main.py]"]
  node_authroute["Authentication<br/>[auth.py]"]
  node_deps["Identity validation<br/>[deps.py]"]
  node_db[("PostgreSQL data<br/>[session.py]")]
end

subgraph group_domain["Incident operations"]
  node_incidents["Incident handling<br/>[incidents.py]"]
  node_departments["Department management<br/>[departments.py]"]
  node_users["User management<br/>[users.py]"]
  node_analytics["Incident analytics<br/>[analytics.py]"]
  node_evidence["Evidence handling<br/>[evidence.py]"]
  node_notifications["Notifications API<br/>[notifications.py]"]
  node_wsroute["WebSocket endpoint<br/>[websocket.py]"]
  node_wsmanager["Recipient dispatch"]
end

subgraph group_vision["Camera AI"]
  node_runtime["Camera runtime<br/>[camera_runtime.py]"]
  node_cameras["Camera management<br/>[cameras.py]"]
  node_yolo["YOLO detection<br/>[yolo_detector.py]"]
  node_firesmoke["Fire smoke detection"]
  node_fall["Fall detection<br/>[fall_detector.py]"]
  node_fight["Fighting analysis"]
end

node_user(("Campus user"))
node_staff(("Authorized staff"))

node_user -->|"uses"| node_app
node_app -->|"provides session"| node_authui
node_authui -->|"calls"| node_authsvc
node_app -->|"routes to"| node_dashboard
node_dashboard -->|"renders"| node_reporter
node_reporter -->|"submits incidents"| node_incsvc
node_incsvc -->|"HTTP requests"| node_incidents
node_authsvc -->|"HTTP requests"| node_authroute
node_main -->|"registers"| node_authroute
node_main -->|"registers"| node_incidents
node_main -->|"registers"| node_departments
node_main -->|"registers"| node_users
node_main -->|"registers"| node_analytics
node_main -->|"registers"| node_evidence
node_main -->|"registers"| node_notifications
node_main -->|"registers"| node_wsroute
node_main -->|"registers"| node_cameras
node_authroute -->|"reads writes"| node_db
node_authroute -->|"uses identity"| node_deps
node_incidents -->|"reads writes"| node_db
node_incidents -->|"sends updates"| node_wsmanager
node_departments -->|"reads writes"| node_db
node_users -.->|"reads writes"| node_db
node_analytics -->|"queries"| node_db
node_evidence -->|"stores metadata"| node_db
node_wsroute -.->|"manages connections"| node_wsmanager
node_wsclient -->|"opens socket"| node_wsroute
node_dashboard -->|"consumes updates"| node_wsclient
node_main -->|"starts stops"| node_runtime
node_cameras -->|"controls streams"| node_runtime
node_runtime -.->|"detects objects"| node_yolo
node_runtime -.->|"detects hazards"| node_firesmoke
node_runtime -.->|"possible integration"| node_fall
node_runtime -.->|"possible integration"| node_fight
node_staff -.->|"reviews alerts"| node_dashboard

click node_app "https://github.com/joshishreekar/campusshieldai/blob/main/frontend/src/App.jsx"
click node_authui "https://github.com/joshishreekar/campusshieldai/blob/main/frontend/src/context/AuthContext.jsx"
click node_authsvc "https://github.com/joshishreekar/campusshieldai/blob/main/frontend/src/services/authService.js"
click node_dashboard "https://github.com/joshishreekar/campusshieldai/blob/main/frontend/src/pages/Dashboard.jsx"
click node_reporter "https://github.com/joshishreekar/campusshieldai/blob/main/frontend/src/pages/ReporterDashboard.jsx"
click node_incsvc "https://github.com/joshishreekar/campusshieldai/blob/main/frontend/src/services/incidentService.js"
click node_wsclient "https://github.com/joshishreekar/campusshieldai/blob/main/frontend/src/context/WebSocketContext.jsx"
click node_main "https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/main.py"
click node_authroute "https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/auth.py"
click node_deps "https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/deps.py"
click node_incidents "https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/incidents.py"
click node_departments "https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/departments.py"
click node_users "https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/users.py"
click node_analytics "https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/analytics.py"
click node_evidence "https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/evidence.py"
click node_notifications "https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/notifications.py"
click node_wsroute "https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/websocket.py"
click node_wsmanager "https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/services/websocket_manager.py"
click node_db "https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/db/session.py"
click node_runtime "https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/services/camera_runtime.py"
click node_cameras "https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/cameras.py"
click node_yolo "https://github.com/joshishreekar/campusshieldai/blob/main/ai_engine/detectors/yolo_detector.py"
click node_firesmoke "https://github.com/joshishreekar/campusshieldai/blob/main/ai_engine/detectors/fire_smoke_detector.py"
click node_fall "https://github.com/joshishreekar/campusshieldai/blob/main/ai_engine/detectors/fall_detector.py"
click node_fight "https://github.com/joshishreekar/campusshieldai/blob/main/ai_engine/detectors/fighting_analyzer.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_authui,node_authsvc,node_dashboard,node_reporter,node_incsvc,node_wsclient,node_user toneBlue
class node_main,node_authroute,node_deps,node_db toneAmber
class node_incidents,node_departments,node_users,node_analytics,node_evidence,node_notifications,node_wsroute,node_wsmanager toneMint
class node_runtime,node_cameras,node_yolo,node_firesmoke,node_fall,node_fight toneRose
class node_staff toneIndigo
```

## Components

### Web client

- [Role dashboards](https://github.com/joshishreekar/campusshieldai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Session context](https://github.com/joshishreekar/campusshieldai/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Auth requests](https://github.com/joshishreekar/campusshieldai/blob/main/frontend/src/services/authService.js): `frontend/src/services/authService.js`
- [Dashboard views](https://github.com/joshishreekar/campusshieldai/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Reporter workflow](https://github.com/joshishreekar/campusshieldai/blob/main/frontend/src/pages/ReporterDashboard.jsx): `frontend/src/pages/ReporterDashboard.jsx`
- [Incident requests](https://github.com/joshishreekar/campusshieldai/blob/main/frontend/src/services/incidentService.js): `frontend/src/services/incidentService.js`
- [Live updates client](https://github.com/joshishreekar/campusshieldai/blob/main/frontend/src/context/WebSocketContext.jsx): `frontend/src/context/WebSocketContext.jsx`

### Backend API

- [API application](https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/auth.py): `backend/app/api/routes/auth.py`
- [Identity validation](https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/deps.py): `backend/app/api/deps.py`
- [PostgreSQL data](https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/db/session.py): `backend/app/db/session.py`

### Incident operations

- [Incident handling](https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/incidents.py): `backend/app/api/routes/incidents.py`
- [Department management](https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/departments.py): `backend/app/api/routes/departments.py`
- [User management](https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/users.py): `backend/app/api/routes/users.py`
- [Incident analytics](https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/analytics.py): `backend/app/api/routes/analytics.py`
- [Evidence handling](https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/evidence.py): `backend/app/api/routes/evidence.py`
- [Notifications API](https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/notifications.py): `backend/app/api/routes/notifications.py`
- [WebSocket endpoint](https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/websocket.py): `backend/app/api/routes/websocket.py`
- [Recipient dispatch](https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/services/websocket_manager.py): `backend/app/services/websocket_manager.py`

### Camera AI

- [Camera runtime](https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/services/camera_runtime.py): `backend/app/services/camera_runtime.py`
- [Camera management](https://github.com/joshishreekar/campusshieldai/blob/main/backend/app/api/routes/cameras.py): `backend/app/api/routes/cameras.py`
- [YOLO detection](https://github.com/joshishreekar/campusshieldai/blob/main/ai_engine/detectors/yolo_detector.py): `ai_engine/detectors/yolo_detector.py`
- [Fire smoke detection](https://github.com/joshishreekar/campusshieldai/blob/main/ai_engine/detectors/fire_smoke_detector.py): `ai_engine/detectors/fire_smoke_detector.py`
- [Fall detection](https://github.com/joshishreekar/campusshieldai/blob/main/ai_engine/detectors/fall_detector.py): `ai_engine/detectors/fall_detector.py`
- [Fighting analysis](https://github.com/joshishreekar/campusshieldai/blob/main/ai_engine/detectors/fighting_analyzer.py): `ai_engine/detectors/fighting_analyzer.py`

### Other components

- **Campus user**
- **Authorized staff**

## Connections

- Campus user → Role dashboards: uses (evidence: `frontend/src/App.jsx`)
- Role dashboards → Session context: provides session (evidence: `frontend/src/App.jsx`)
- Session context → Auth requests: calls (evidence: `frontend/src/context/AuthContext.jsx`)
- Role dashboards → Dashboard views: routes to (evidence: `frontend/src/App.jsx`)
- Dashboard views → Reporter workflow: renders (evidence: `frontend/src/pages/Dashboard.jsx`)
- Reporter workflow → Incident requests: submits incidents (evidence: `frontend/src/pages/ReporterDashboard.jsx`)
- Incident requests → Incident handling: HTTP requests (evidence: `frontend/src/services/incidentService.js`)
- Auth requests → Authentication: HTTP requests (evidence: `frontend/src/services/authService.js`)
- API application → Authentication: registers (evidence: `backend/app/main.py`)
- API application → Incident handling: registers (evidence: `backend/app/main.py`)
- API application → Department management: registers (evidence: `backend/app/main.py`)
- API application → User management: registers (evidence: `backend/app/main.py`)
- API application → Incident analytics: registers (evidence: `backend/app/main.py`)
- API application → Evidence handling: registers (evidence: `backend/app/main.py`)
- API application → Notifications API: registers (evidence: `backend/app/main.py`)
- API application → WebSocket endpoint: registers (evidence: `backend/app/main.py`)
- API application → Camera management: registers (evidence: `backend/app/main.py`)
- Authentication → PostgreSQL data: reads writes (evidence: `backend/app/api/routes/auth.py`)
- Authentication → Identity validation: uses identity (evidence: `backend/app/api/routes/auth.py`)
- Incident handling → PostgreSQL data: reads writes (evidence: `backend/app/api/routes/incidents.py`)
- Incident handling → Recipient dispatch: sends updates (evidence: `backend/app/api/routes/incidents.py`)
- Department management → PostgreSQL data: reads writes (evidence: `backend/app/api/routes/departments.py`)
- User management → PostgreSQL data: reads writes
- Incident analytics → PostgreSQL data: queries (evidence: `backend/app/api/routes/analytics.py`)
- Evidence handling → PostgreSQL data: stores metadata (evidence: `backend/app/api/routes/evidence.py`)
- WebSocket endpoint → Recipient dispatch: manages connections
- Live updates client → WebSocket endpoint: opens socket (evidence: `frontend/src/context/WebSocketContext.jsx`)
- Dashboard views → Live updates client: consumes updates (evidence: `frontend/src/pages/Dashboard.jsx`)
- API application → Camera runtime: starts stops (evidence: `backend/app/main.py`)
- Camera management → Camera runtime: controls streams (evidence: `backend/app/api/routes/cameras.py`)
- Camera runtime → YOLO detection: detects objects
- Camera runtime → Fire smoke detection: detects hazards
- Camera runtime → Fall detection: possible integration
- Camera runtime → Fighting analysis: possible integration
- Authorized staff → Dashboard views: reviews alerts
