# abdelrahmanibrahim11/crovia architecture

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

- Interactive diagram: https://gitdiagram.com/abdelrahmanibrahim11/crovia
- Repository: https://github.com/abdelrahmanibrahim11/crovia

## Overview

CROVIA is a crowd-danger monitoring and warning system for Lusail. Its principal workflow is to monitor network congestion, check reachability, sample phones with location verification, judge arrival flow against bottleneck capacity, and—after an alarm—retrieve more precise location context and send warnings while prioritizing responders. The graph also includes the documented AI and operator/citizen app capabilities. Some backend wiring and screens are unsampled; edges are limited to README statements and relationships listed in the SOURCE INDEX.

Main entry points: [`backend/app/detect/engine.py`](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/detect/engine.py) (Detection engine), [`backend/app/runtime.py`](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/runtime.py) (Service runtime), [`crovia-ui/src/screens/AdminDashboardScreen.tsx`](https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/src/screens/AdminDashboardScreen.tsx) (Operator dashboard), [`crovia-ui/src/screens/UserDashboardScreen.tsx`](https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/src/screens/UserDashboardScreen.tsx) (Citizen dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sensing["Sensing and detection"]
  node_engine["Detection engine<br/>[engine.py]"]
  node_danger["Bottleneck judgement<br/>[danger.py]"]
  node_camara["CAMARA client<br/>[client.py]"]
  node_city["City capacity model<br/>[city.py]"]
  node_registry[("Device registry<br/>[registry.py]")]
  node_budget["API spend control<br/>[budget.py]"]
end

subgraph group_operations["Incident operations"]
  node_webhooks["Network event handlers<br/>[webhooks.py]"]
  node_warnings["Citizen warnings<br/>[warnings.py]"]
  node_priority["Responder priority<br/>[priority.py]"]
  node_incidents["Incident records<br/>[incidents.py]"]
  node_enrollment["Device enrollment<br/>[enrollment.py]"]
  node_agent["AI agent tools<br/>[graph.py]"]
end

subgraph group_platform["Backend platform"]
  node_runtime["Service runtime<br/>[runtime.py]"]
  node_auth["Authentication API<br/>[auth.py]"]
  node_users["User data services<br/>[services.py]"]
  node_database[("User database<br/>[db.py]")]
end

subgraph group_experience["User experience"]
  node_app["App navigation<br/>[App.tsx]"]
  node_operator_screen["Operator dashboard"]
  node_citizen_screen["Citizen dashboard"]
  node_map["City map<br/>[CityMap.tsx]"]
  node_live_state["Live state polling<br/>[useLiveState.ts]"]
  node_ui_api["Backend API client<br/>[api.ts]"]
  node_session["Session handling<br/>[session.ts]"]
  node_geo["Lusail geography<br/>[index.ts]"]
end

node_network(("Mobile network"))
node_operator(("City operator"))
node_citizen(("Citizen"))

node_runtime -->|"runs"| node_engine
node_engine -->|"requests network data"| node_camara
node_engine -->|"evaluates risk"| node_danger
node_engine -->|"uses capacity model"| node_city
node_engine -->|"checks devices"| node_registry
node_engine -->|"allocates spend"| node_budget
node_network -->|"provides API"| node_camara
node_network -->|"sends events"| node_webhooks
node_webhooks -->|"feeds notifications"| node_runtime
node_runtime -->|"sends warnings"| node_warnings
node_runtime -->|"opens responder sessions"| node_priority
node_runtime -->|"uses incident service"| node_incidents
node_runtime -->|"starts agent"| node_agent
node_runtime -->|"uses enrollment"| node_enrollment
node_enrollment -->|"restores devices"| node_registry
node_enrollment -->|"loads consent"| node_database
node_auth -->|"uses user services"| node_users
node_users -->|"reads and writes"| node_database
node_operator -->|"views city status"| node_operator_screen
node_citizen -->|"receives warnings"| node_citizen_screen
node_app -->|"routes to"| node_operator_screen
node_app -->|"routes to"| node_citizen_screen
node_operator_screen -->|"polls state"| node_live_state
node_citizen_screen -->|"polls state"| node_live_state
node_live_state -->|"fetches live data"| node_ui_api
node_operator_screen -->|"renders map"| node_map
node_citizen_screen -->|"renders map"| node_map
node_map -->|"uses geography"| node_geo
node_app -->|"loads session"| node_session
node_session -->|"authenticates"| node_auth
node_engine -->|"triggers warning stage"| node_warnings
node_engine -->|"triggers responder priority"| node_priority
node_camara -->|"checks reachability and location"| node_network

click node_runtime "https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/runtime.py"
click node_engine "https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/detect/engine.py"
click node_danger "https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/detect/danger.py"
click node_camara "https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/camara/client.py"
click node_city "https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/core/city.py"
click node_registry "https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/core/registry.py"
click node_budget "https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/core/budget.py"
click node_webhooks "https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/api/webhooks.py"
click node_warnings "https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/services/warnings.py"
click node_priority "https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/services/priority.py"
click node_incidents "https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/services/incidents.py"
click node_enrollment "https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/services/enrollment.py"
click node_agent "https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/ai/graph.py"
click node_auth "https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/api/auth.py"
click node_users "https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/usersDB/services.py"
click node_database "https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/usersDB/db.py"
click node_app "https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/App.tsx"
click node_operator_screen "https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/src/screens/AdminDashboardScreen.tsx"
click node_citizen_screen "https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/src/screens/UserDashboardScreen.tsx"
click node_map "https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/src/components/CityMap.tsx"
click node_live_state "https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/src/useLiveState.ts"
click node_ui_api "https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/src/api.ts"
click node_session "https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/src/session.ts"
click node_geo "https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/src/geo/index.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_engine,node_danger,node_camara,node_city,node_registry,node_budget toneBlue
class node_webhooks,node_warnings,node_priority,node_incidents,node_enrollment,node_agent toneAmber
class node_runtime,node_auth,node_users,node_database toneMint
class node_app,node_operator_screen,node_citizen_screen,node_map,node_live_state,node_ui_api,node_session,node_geo toneRose
class node_network,node_operator,node_citizen toneIndigo
```

## Components

### Sensing and detection

- [Detection engine](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/detect/engine.py): `backend/app/detect/engine.py`
- [Bottleneck judgement](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/detect/danger.py): `backend/app/detect/danger.py`
- [CAMARA client](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/camara/client.py): `backend/app/camara/client.py`
- [City capacity model](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/core/city.py): `backend/app/core/city.py`
- [Device registry](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/core/registry.py): `backend/app/core/registry.py`
- [API spend control](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/core/budget.py): `backend/app/core/budget.py`

### Incident operations

- [Network event handlers](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/api/webhooks.py): `backend/app/api/webhooks.py`
- [Citizen warnings](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/services/warnings.py): `backend/app/services/warnings.py`
- [Responder priority](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/services/priority.py): `backend/app/services/priority.py`
- [Incident records](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/services/incidents.py): `backend/app/services/incidents.py`
- [Device enrollment](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/services/enrollment.py): `backend/app/services/enrollment.py`
- [AI agent tools](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/ai/graph.py): `backend/app/ai/graph.py`

### Backend platform

- [Service runtime](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/runtime.py): `backend/app/runtime.py`
- [Authentication API](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/api/auth.py): `backend/app/api/auth.py`
- [User data services](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/usersDB/services.py): `backend/app/usersDB/services.py`
- [User database](https://github.com/abdelrahmanibrahim11/crovia/blob/main/backend/app/usersDB/db.py): `backend/app/usersDB/db.py`

### User experience

- [App navigation](https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/App.tsx): `crovia-ui/App.tsx`
- [Operator dashboard](https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/src/screens/AdminDashboardScreen.tsx): `crovia-ui/src/screens/AdminDashboardScreen.tsx`
- [Citizen dashboard](https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/src/screens/UserDashboardScreen.tsx): `crovia-ui/src/screens/UserDashboardScreen.tsx`
- [City map](https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/src/components/CityMap.tsx): `crovia-ui/src/components/CityMap.tsx`
- [Live state polling](https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/src/useLiveState.ts): `crovia-ui/src/useLiveState.ts`
- [Backend API client](https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/src/api.ts): `crovia-ui/src/api.ts`
- [Session handling](https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/src/session.ts): `crovia-ui/src/session.ts`
- [Lusail geography](https://github.com/abdelrahmanibrahim11/crovia/blob/main/crovia-ui/src/geo/index.ts): `crovia-ui/src/geo/index.ts`

### Other components

- **Mobile network**
- **City operator**
- **Citizen**

## Connections

- Service runtime → Detection engine: runs (evidence: `backend/app/runtime.py`)
- Detection engine → CAMARA client: requests network data (evidence: `backend/app/detect/engine.py`)
- Detection engine → Bottleneck judgement: evaluates risk (evidence: `backend/app/detect/engine.py`)
- Detection engine → City capacity model: uses capacity model (evidence: `backend/app/detect/engine.py`)
- Detection engine → Device registry: checks devices (evidence: `backend/app/detect/engine.py`)
- Detection engine → API spend control: allocates spend (evidence: `backend/app/detect/engine.py`)
- Mobile network → CAMARA client: provides API
- Mobile network → Network event handlers: sends events (evidence: `backend/app/api/webhooks.py`)
- Network event handlers → Service runtime: feeds notifications (evidence: `backend/app/api/webhooks.py`)
- Service runtime → Citizen warnings: sends warnings (evidence: `backend/app/main.py`)
- Service runtime → Responder priority: opens responder sessions (evidence: `backend/app/main.py`)
- Service runtime → Incident records: uses incident service (evidence: `backend/app/main.py`)
- Service runtime → AI agent tools: starts agent (evidence: `backend/app/main.py`)
- Service runtime → Device enrollment: uses enrollment (evidence: `backend/app/main.py`)
- Device enrollment → Device registry: restores devices (evidence: `backend/app/services/enrollment.py`)
- Device enrollment → User database: loads consent (evidence: `backend/app/services/enrollment.py`)
- Authentication API → User data services: uses user services (evidence: `backend/app/api/auth.py`)
- User data services → User database: reads and writes (evidence: `backend/app/usersDB/services.py`)
- City operator → Operator dashboard: views city status
- Citizen → Citizen dashboard: receives warnings
- App navigation → Operator dashboard: routes to (evidence: `crovia-ui/App.tsx`)
- App navigation → Citizen dashboard: routes to (evidence: `crovia-ui/App.tsx`)
- Operator dashboard → Live state polling: polls state (evidence: `crovia-ui/src/screens/AdminDashboardScreen.tsx`)
- Citizen dashboard → Live state polling: polls state (evidence: `crovia-ui/src/screens/UserDashboardScreen.tsx`)
- Live state polling → Backend API client: fetches live data (evidence: `crovia-ui/src/useLiveState.ts`)
- Operator dashboard → City map: renders map (evidence: `crovia-ui/src/screens/AdminDashboardScreen.tsx`)
- Citizen dashboard → City map: renders map (evidence: `crovia-ui/src/screens/UserDashboardScreen.tsx`)
- City map → Lusail geography: uses geography (evidence: `crovia-ui/src/components/CityMap.tsx`)
- App navigation → Session handling: loads session (evidence: `crovia-ui/App.tsx`)
- Session handling → Authentication API: authenticates (evidence: `crovia-ui/src/session.ts`)
- Detection engine → Citizen warnings: triggers warning stage
- Detection engine → Responder priority: triggers responder priority
- CAMARA client → Mobile network: checks reachability and location
