# rishiofficial432-432/crowd-counting architecture

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

- Interactive diagram: https://gitdiagram.com/rishiofficial432-432/crowd-counting
- Repository: https://github.com/rishiofficial432-432/crowd-counting

## Overview

This is a crowd-safety application centered on estimating crowd size from uploaded imagery, then presenting safety status and response options. Its broader workflow adds live camera and drone monitoring, crowd-flow analysis, venue/road context, and route-based dispersal. The Streamlit entry point invokes the documented UI modules; the dashboard uses routing, alerting, and persistence capabilities. Some API, counting, segmentation, and UI implementation details are not sampled, so those links are limited to explicit documentation or shown references.

Main entry points: [`app.py`](https://github.com/rishiofficial432-432/crowd-counting/blob/main/app.py) (Safety App), [`crowd_safety/ui/dashboard.py`](https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/ui/dashboard.py) (Safety Dashboard), [`backend.py`](https://github.com/rishiofficial432-432/crowd-counting/blob/main/backend.py) (Counting API), [`crowd_safety/ui/disperse.py`](https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/ui/disperse.py) (Dispersal Planner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture and Count"]
  node_count_api["Counting API<br/>[backend.py]"]
  node_counter["Crowd Counter<br/>[crowd_counter.py]"]
  node_segmentation["Density Mapping<br/>[segmentation.py]"]
  node_live_stream["RTSP Monitor<br/>[rtsp_stream.py]"]
  node_drone["Drone Analysis<br/>[drone_mode.py]"]
end

subgraph group_safety["Safety Analysis"]
  node_dashboard["Safety Dashboard<br/>[dashboard.py]"]
  node_flow["Crowd Flow<br/>[crowd_flow.py]"]
  node_road_flow["Road Flow<br/>[road_crowd_flow.py]"]
  node_equilibrium["Equilibrium Analysis<br/>[equilibrium.py]"]
end

subgraph group_response["Response Planning"]
  node_disperse["Dispersal Planner<br/>[disperse.py]"]
  node_routing["Route Engine<br/>[routing_engine.py]"]
  node_search["Location Search"]
  node_alerting["Alerting<br/>[alerting.py]"]
end

subgraph group_platform["Application Platform"]
  node_streamlit["Safety App<br/>[app.py]"]
  node_database[("Crowd Records<br/>[db.py]")]
end

node_operator(("Operator"))
node_count_service{{"LWCC Service"}}

node_operator -->|"uses"| node_streamlit
node_streamlit -->|"submits images"| node_count_api
node_count_api -.->|"estimates counts"| node_counter
node_counter -.->|"counts with"| node_count_service
node_count_api -.->|"produces density maps"| node_segmentation
node_streamlit -->|"renders"| node_dashboard
node_streamlit -->|"renders"| node_live_stream
node_streamlit -->|"renders"| node_drone
node_streamlit -->|"renders"| node_flow
node_streamlit -->|"renders"| node_road_flow
node_dashboard -->|"uses routes"| node_routing
node_disperse -->|"generates routes"| node_routing
node_dashboard -->|"reads and writes"| node_database
node_dashboard -->|"uses alerts"| node_alerting
node_road_flow -->|"uses flow analysis"| node_flow
node_operator -.->|"plans dispersal"| node_disperse
node_disperse -.->|"finds locations"| node_search
node_operator -.->|"analyzes roads"| node_equilibrium
node_operator -.->|"uploads aerial media"| node_drone
node_operator -.->|"monitors streams"| node_live_stream

click node_streamlit "https://github.com/rishiofficial432-432/crowd-counting/blob/main/app.py"
click node_count_api "https://github.com/rishiofficial432-432/crowd-counting/blob/main/backend.py"
click node_counter "https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/infra/crowd_counter.py"
click node_segmentation "https://github.com/rishiofficial432-432/crowd-counting/blob/main/segmentation.py"
click node_live_stream "https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/ui/rtsp_stream.py"
click node_drone "https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/ui/drone_mode.py"
click node_dashboard "https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/ui/dashboard.py"
click node_flow "https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/ui/crowd_flow.py"
click node_road_flow "https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/ui/road_crowd_flow.py"
click node_equilibrium "https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/core/equilibrium.py"
click node_disperse "https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/ui/disperse.py"
click node_routing "https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/core/routing_engine.py"
click node_search "https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/core/search_algorithms.py"
click node_alerting "https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/infra/alerting.py"
click node_database "https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/infra/db.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_count_api,node_counter,node_segmentation,node_live_stream,node_drone toneBlue
class node_dashboard,node_flow,node_road_flow,node_equilibrium toneAmber
class node_disperse,node_routing,node_search,node_alerting toneMint
class node_streamlit,node_database toneRose
class node_operator,node_count_service toneIndigo
```

## Components

### Capture and Count

- [Counting API](https://github.com/rishiofficial432-432/crowd-counting/blob/main/backend.py): `backend.py`
- [Crowd Counter](https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/infra/crowd_counter.py): `crowd_safety/infra/crowd_counter.py`
- [Density Mapping](https://github.com/rishiofficial432-432/crowd-counting/blob/main/segmentation.py): `segmentation.py`
- [RTSP Monitor](https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/ui/rtsp_stream.py): `crowd_safety/ui/rtsp_stream.py`
- [Drone Analysis](https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/ui/drone_mode.py): `crowd_safety/ui/drone_mode.py`

### Safety Analysis

- [Safety Dashboard](https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/ui/dashboard.py): `crowd_safety/ui/dashboard.py`
- [Crowd Flow](https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/ui/crowd_flow.py): `crowd_safety/ui/crowd_flow.py`
- [Road Flow](https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/ui/road_crowd_flow.py): `crowd_safety/ui/road_crowd_flow.py`
- [Equilibrium Analysis](https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/core/equilibrium.py): `crowd_safety/core/equilibrium.py`

### Response Planning

- [Dispersal Planner](https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/ui/disperse.py): `crowd_safety/ui/disperse.py`
- [Route Engine](https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/core/routing_engine.py): `crowd_safety/core/routing_engine.py`
- [Location Search](https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/core/search_algorithms.py): `crowd_safety/core/search_algorithms.py`
- [Alerting](https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/infra/alerting.py): `crowd_safety/infra/alerting.py`

### Application Platform

- [Safety App](https://github.com/rishiofficial432-432/crowd-counting/blob/main/app.py): `app.py`
- [Crowd Records](https://github.com/rishiofficial432-432/crowd-counting/blob/main/crowd_safety/infra/db.py): `crowd_safety/infra/db.py`

### Other components

- **Operator**
- **LWCC Service**

## Connections

- Operator → Safety App: uses
- Safety App → Counting API: submits images (evidence: `app.py`)
- Counting API → Crowd Counter: estimates counts
- Crowd Counter → LWCC Service: counts with
- Counting API → Density Mapping: produces density maps
- Safety App → Safety Dashboard: renders (evidence: `app.py`)
- Safety App → RTSP Monitor: renders (evidence: `app.py`)
- Safety App → Drone Analysis: renders (evidence: `app.py`)
- Safety App → Crowd Flow: renders (evidence: `app.py`)
- Safety App → Road Flow: renders (evidence: `app.py`)
- Safety Dashboard → Route Engine: uses routes (evidence: `crowd_safety/ui/dashboard.py`)
- Dispersal Planner → Route Engine: generates routes (evidence: `crowd_safety/ui/disperse.py`)
- Safety Dashboard → Crowd Records: reads and writes (evidence: `crowd_safety/ui/dashboard.py`)
- Safety Dashboard → Alerting: uses alerts (evidence: `crowd_safety/ui/dashboard.py`)
- Road Flow → Crowd Flow: uses flow analysis (evidence: `crowd_safety/ui/road_crowd_flow.py`)
- Operator → Dispersal Planner: plans dispersal
- Dispersal Planner → Location Search: finds locations
- Operator → Equilibrium Analysis: analyzes roads
- Operator → Drone Analysis: uploads aerial media
- Operator → RTSP Monitor: monitors streams
