# manjunath5513/devyatra architecture

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

- Interactive diagram: https://gitdiagram.com/manjunath5513/devyatra
- Repository: https://github.com/manjunath5513/devyatra

## Overview

#### 1. Repository Shape and Entry Points
DevYatra is a multi-application pilgrimage crowd-management system: a primary Next.js pilgrim/operator UI, a Flask API, standalone ML forecasting, and separate crowd-analysis panels/services. Main runnable entries are `backend/app_new.py` (documented backend), `sih2025-qbit/app/page.tsx` (primary web UI), `aiml crowd prediction/dashboard/app.py` (ML dashboard), and `CrowdAnalyser/YOLOv8/app.py` (YOLO service).

#### 2. Primary Web Experience
The principal frontend is a Next.js App Router application covering dashboards, queueing, crowd analysis, safety, travel, ticketing, traffic, voice, and accessibility. Shared layout and API boundaries are centralized rather than each page owning integrations.
- `sih2025-qbit/app/layout.tsx`
- `sih2025-qbit/app/dashboard/page.tsx`
- `sih2025-qbit/services/apiService.ts`

Client-side feature modules include virtual queues, traffic/parking/shuttle displays, maps, accessibility tooling, and translation. Its internal API routes handle login/session/logout and batch translation.
- `sih2025-qbit/components/smart-queue/VirtualQueueManager.tsx`
- `sih2025-qbit/components/traffic-mobility/TrafficControlPanel.tsx`
- `sih2025-qbit/app/api/auth/login/route.ts`

#### 3. Flask Integration and Domain API
The Python backend is the integration boundary for user data, safety reporting, travel services, carbon features, tickets/groups, chatbot/voice, maps/routes, weather, and emergency functions. `app.py`, `app_new.py`, and a backup indicate competing or evolving application compositions; treat `app_new.py` as the documented launch target and verify which app is canonical before changes.
- `backend/app_new.py`
- `backend/models.py`
- `backend/routes/travel_routes.py`

Persistence is described as SQLAlchemy with SQLite. Runtime configuration and external-key handling are separated in:
- `backend/config.py`
- `backend/.env.example`

#### 4. Crowd Forecasting Pipeline
The ML subsystem is a standalone Python package, not visibly embedded in the Flask app. It moves camera/stream or synthetic inputs through ingestion/capture, detection, feature construction and fusion, forecasting models, then alerting/recording. CLI scripts expose batch, real-time, training, detection, and alert execution modes.
- `aiml crowd prediction/src/crowd_forecast/pipeline.py`
- `aiml crowd prediction/src/crowd_forecast/detection.py`
- `aiml crowd prediction/src/crowd_forecast/alerting.py`

Forecasting is split into baseline and advanced model implementations, with a Streamlit-oriented monitoring/dashboard entry point.
- `aiml crowd prediction/src/crowd_forecast/models/baseline.py`
- `aiml crowd prediction/src/crowd_forecast/models/advanced.py`
- `aiml crowd prediction/dashboard/app.py`

#### 5. Video and Crowd-Analysis Boundary
A separate YOLOv8 service performs real-time people counting, likely consuming webcam/CCTV input independently of the forecasting package. Separate Next.js admin and public panels suggest distinct authority and user-facing deployments rather than routes within the primary UI.
- `CrowdAnalyser/YOLOv8/yolo_people_counter.py`
- `CrowdAnalyser/YOLOv8/app.py`
- `CrowdAnalyser/AdminPanel/src/app/page.tsx`

#### 6. End-to-End Control Flow
Operationally: cameras/sensors or streams feed YOLO detection and/or the forecast pipeline; counts and contextual features produce predictions and alerts; backend APIs expose operational functions and external-service responses; Next.js pages/services render and act on this data for pilgrims and operators. The repo tree does not establish a concrete transport contract between ML services and Flask, so this is a critical integration boundary to formalize.

#### 7. Runtimes and External Dependencies
Material runtimes are Python 3.11+ for Flask, ML, YOLO, and Streamlit; Node.js 18+ for Next.js/TypeScript applications. Stated external integrations include Groq (chat/language), Geoapify (maps/geocoding), weather APIs, Twilio (SMS/WhatsApp alerts), Sarvam (translation), Socket.IO live events, Leaflet mapping, camera/CCTV sources, and SQLAlchemy/SQLite persistence.

Main entry points: [`backend/app_new.py`](https://github.com/manjunath5513/devyatra/blob/master/backend/app_new.py) (Documented backend), [`aiml crowd prediction/src/crowd_forecast/pipeline.py`](https://github.com/manjunath5513/devyatra/blob/master/aiml%20crowd%20prediction/src/crowd_forecast/pipeline.py) (Forecast pipeline), [`CrowdAnalyser/YOLOv8/app.py`](https://github.com/manjunath5513/devyatra/blob/master/CrowdAnalyser/YOLOv8/app.py) (YOLO people counter), [`sih2025-qbit/app/page.tsx`](https://github.com/manjunath5513/devyatra/blob/master/sih2025-qbit/app/page.tsx) (Pilgrim & operator UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Next.js experiences"]
  node_primary_ui["Pilgrim &amp; operator UI<br/>Next.js App Router<br/>[page.tsx]"]
  node_app_layout["Shared application shell<br/>Next.js layout<br/>[layout.tsx]"]
  node_dashboard["Operations dashboard<br/>Next.js page<br/>[page.tsx]"]
  node_api_client["Frontend API boundary<br/>TypeScript service<br/>[apiService.ts]"]
  node_queue_mobility["Queue &amp; mobility tools<br/>client features"]
  node_traffic_panel["Traffic control panel<br/>client feature"]
  node_auth_route["Session API routes<br/>Next.js route handler<br/>[route.ts]"]
end

subgraph group_api["Flask domain API"]
  node_flask_app{{"Documented backend<br/>Flask application<br/>[app_new.py]"}}
  node_domain_routes["Travel and domain routes<br/>Flask routes<br/>[travel_routes.py]"]
  node_data_models["Domain models<br/>SQLAlchemy models<br/>[models.py]"]
  node_sqlite[("Operational data<br/>SQLite database")]
end

subgraph group_forecast["Crowd forecasting"]
  node_forecast_pipeline{{"Forecast pipeline<br/>Python orchestration<br/>[pipeline.py]"}}
  node_detection["Detection &amp; feature input<br/>Python detection<br/>[detection.py]"]
  node_forecast_models["Forecast models<br/>baseline + advanced ML<br/>[advanced.py]"]
  node_alerting["Forecast alerts<br/>Python alerting<br/>[alerting.py]"]
  node_ml_dashboard["Forecast monitoring<br/>Streamlit dashboard<br/>[app.py]"]
end

subgraph group_video["Video analysis"]
  node_yolo_service{{"YOLO people counter<br/>Python video service<br/>[app.py]"}}
  node_yolo_counter["People-counting engine<br/>YOLOv8 inference"]
  node_admin_panel["Crowd admin panel<br/>Next.js application<br/>[page.tsx]"]
end

node_external_apis(("Maps, weather, messaging &amp; AI<br/>external integrations"))
node_camera_streams(("Cameras &amp; sensors<br/>video/stream inputs"))

node_primary_ui -->|"renders within"| node_app_layout
node_app_layout -->|"hosts"| node_dashboard
node_dashboard -->|"uses"| node_queue_mobility
node_dashboard -->|"uses"| node_traffic_panel
node_primary_ui -->|"uses"| node_api_client
node_primary_ui -->|"authenticates through"| node_auth_route
node_api_client -->|"domain API calls"| node_flask_app
node_flask_app -->|"registers"| node_domain_routes
node_flask_app -->|"uses"| node_data_models
node_data_models -->|"persists to"| node_sqlite
node_flask_app -->|"integrates with"| node_external_apis
node_camera_streams -->|"feeds"| node_detection
node_detection -->|"counts and features"| node_forecast_pipeline
node_forecast_pipeline -->|"predicts with"| node_forecast_models
node_forecast_pipeline -->|"triggers"| node_alerting
node_forecast_pipeline -->|"monitors"| node_ml_dashboard
node_camera_streams -->|"feeds"| node_yolo_service
node_yolo_service -->|"runs"| node_yolo_counter
node_yolo_service -->|"serves counts to"| node_admin_panel
node_forecast_pipeline -.->|"operational integration to formalize"| node_flask_app
node_yolo_service -.->|"operational integration to formalize"| node_flask_app

click node_primary_ui "https://github.com/manjunath5513/devyatra/blob/master/sih2025-qbit/app/page.tsx"
click node_app_layout "https://github.com/manjunath5513/devyatra/blob/master/sih2025-qbit/app/layout.tsx"
click node_dashboard "https://github.com/manjunath5513/devyatra/blob/master/sih2025-qbit/app/dashboard/page.tsx"
click node_api_client "https://github.com/manjunath5513/devyatra/blob/master/sih2025-qbit/services/apiService.ts"
click node_queue_mobility "https://github.com/manjunath5513/devyatra/blob/master/sih2025-qbit/components/smart-queue/VirtualQueueManager.tsx"
click node_traffic_panel "https://github.com/manjunath5513/devyatra/blob/master/sih2025-qbit/components/traffic-mobility/TrafficControlPanel.tsx"
click node_auth_route "https://github.com/manjunath5513/devyatra/blob/master/sih2025-qbit/app/api/auth/login/route.ts"
click node_flask_app "https://github.com/manjunath5513/devyatra/blob/master/backend/app_new.py"
click node_domain_routes "https://github.com/manjunath5513/devyatra/blob/master/backend/routes/travel_routes.py"
click node_data_models "https://github.com/manjunath5513/devyatra/blob/master/backend/models.py"
click node_forecast_pipeline "https://github.com/manjunath5513/devyatra/blob/master/aiml%20crowd%20prediction/src/crowd_forecast/pipeline.py"
click node_detection "https://github.com/manjunath5513/devyatra/blob/master/aiml%20crowd%20prediction/src/crowd_forecast/detection.py"
click node_forecast_models "https://github.com/manjunath5513/devyatra/blob/master/aiml%20crowd%20prediction/src/crowd_forecast/models/advanced.py"
click node_alerting "https://github.com/manjunath5513/devyatra/blob/master/aiml%20crowd%20prediction/src/crowd_forecast/alerting.py"
click node_ml_dashboard "https://github.com/manjunath5513/devyatra/blob/master/aiml%20crowd%20prediction/dashboard/app.py"
click node_yolo_service "https://github.com/manjunath5513/devyatra/blob/master/CrowdAnalyser/YOLOv8/app.py"
click node_yolo_counter "https://github.com/manjunath5513/devyatra/blob/master/CrowdAnalyser/YOLOv8/yolo_people_counter.py"
click node_admin_panel "https://github.com/manjunath5513/devyatra/blob/master/CrowdAnalyser/AdminPanel/src/app/page.tsx"

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_primary_ui,node_app_layout,node_dashboard,node_api_client,node_queue_mobility,node_traffic_panel,node_auth_route toneBlue
class node_flask_app,node_domain_routes,node_data_models,node_sqlite toneAmber
class node_forecast_pipeline,node_detection,node_forecast_models,node_alerting,node_ml_dashboard toneMint
class node_yolo_service,node_yolo_counter,node_admin_panel toneRose
class node_external_apis,node_camera_streams toneNeutral
```

## Components

### Next.js experiences

- [Pilgrim & operator UI](https://github.com/manjunath5513/devyatra/blob/master/sih2025-qbit/app/page.tsx): Next.js App Router · `sih2025-qbit/app/page.tsx`
- [Shared application shell](https://github.com/manjunath5513/devyatra/blob/master/sih2025-qbit/app/layout.tsx): Next.js layout · `sih2025-qbit/app/layout.tsx`
- [Operations dashboard](https://github.com/manjunath5513/devyatra/blob/master/sih2025-qbit/app/dashboard/page.tsx): Next.js page · `sih2025-qbit/app/dashboard/page.tsx`
- [Frontend API boundary](https://github.com/manjunath5513/devyatra/blob/master/sih2025-qbit/services/apiService.ts): TypeScript service · `sih2025-qbit/services/apiService.ts`
- [Queue & mobility tools](https://github.com/manjunath5513/devyatra/blob/master/sih2025-qbit/components/smart-queue/VirtualQueueManager.tsx): client features · `sih2025-qbit/components/smart-queue/VirtualQueueManager.tsx`
- [Traffic control panel](https://github.com/manjunath5513/devyatra/blob/master/sih2025-qbit/components/traffic-mobility/TrafficControlPanel.tsx): client feature · `sih2025-qbit/components/traffic-mobility/TrafficControlPanel.tsx`
- [Session API routes](https://github.com/manjunath5513/devyatra/blob/master/sih2025-qbit/app/api/auth/login/route.ts): Next.js route handler · `sih2025-qbit/app/api/auth/login/route.ts`

### Flask domain API

- [Documented backend](https://github.com/manjunath5513/devyatra/blob/master/backend/app_new.py): Flask application · Canonical launch target should be verified against alternate app compositions. · `backend/app_new.py`
- [Travel and domain routes](https://github.com/manjunath5513/devyatra/blob/master/backend/routes/travel_routes.py): Flask routes · `backend/routes/travel_routes.py`
- [Domain models](https://github.com/manjunath5513/devyatra/blob/master/backend/models.py): SQLAlchemy models · `backend/models.py`
- **Operational data**: SQLite database

### Crowd forecasting

- [Forecast pipeline](https://github.com/manjunath5513/devyatra/blob/master/aiml%20crowd%20prediction/src/crowd_forecast/pipeline.py): Python orchestration · Runs ingestion, features, fusion, prediction, recording, and alerts. · `aiml crowd prediction/src/crowd_forecast/pipeline.py`
- [Detection & feature input](https://github.com/manjunath5513/devyatra/blob/master/aiml%20crowd%20prediction/src/crowd_forecast/detection.py): Python detection · `aiml crowd prediction/src/crowd_forecast/detection.py`
- [Forecast models](https://github.com/manjunath5513/devyatra/blob/master/aiml%20crowd%20prediction/src/crowd_forecast/models/advanced.py): baseline + advanced ML · `aiml crowd prediction/src/crowd_forecast/models/advanced.py`
- [Forecast alerts](https://github.com/manjunath5513/devyatra/blob/master/aiml%20crowd%20prediction/src/crowd_forecast/alerting.py): Python alerting · `aiml crowd prediction/src/crowd_forecast/alerting.py`
- [Forecast monitoring](https://github.com/manjunath5513/devyatra/blob/master/aiml%20crowd%20prediction/dashboard/app.py): Streamlit dashboard · `aiml crowd prediction/dashboard/app.py`

### Video analysis

- [YOLO people counter](https://github.com/manjunath5513/devyatra/blob/master/CrowdAnalyser/YOLOv8/app.py): Python video service · Independently counts people from webcam or CCTV feeds. · `CrowdAnalyser/YOLOv8/app.py`
- [People-counting engine](https://github.com/manjunath5513/devyatra/blob/master/CrowdAnalyser/YOLOv8/yolo_people_counter.py): YOLOv8 inference · `CrowdAnalyser/YOLOv8/yolo_people_counter.py`
- [Crowd admin panel](https://github.com/manjunath5513/devyatra/blob/master/CrowdAnalyser/AdminPanel/src/app/page.tsx): Next.js application · Separate administrative crowd-analysis deployment. · `CrowdAnalyser/AdminPanel/src/app/page.tsx`

### Other components

- **Maps, weather, messaging & AI**: external integrations · Includes Geoapify, weather, Twilio, Groq, and Sarvam.
- **Cameras & sensors**: video/stream inputs

## Connections

- Pilgrim & operator UI → Shared application shell: renders within
- Shared application shell → Operations dashboard: hosts
- Operations dashboard → Queue & mobility tools: uses
- Operations dashboard → Traffic control panel: uses
- Pilgrim & operator UI → Frontend API boundary: uses
- Pilgrim & operator UI → Session API routes: authenticates through
- Frontend API boundary → Documented backend: domain API calls
- Documented backend → Travel and domain routes: registers
- Documented backend → Domain models: uses
- Domain models → Operational data: persists to
- Documented backend → Maps, weather, messaging & AI: integrates with
- Cameras & sensors → Detection & feature input: feeds
- Detection & feature input → Forecast pipeline: counts and features
- Forecast pipeline → Forecast models: predicts with
- Forecast pipeline → Forecast alerts: triggers
- Forecast pipeline → Forecast monitoring: monitors
- Cameras & sensors → YOLO people counter: feeds
- YOLO people counter → People-counting engine: runs
- YOLO people counter → Crowd admin panel: serves counts to
- Forecast pipeline → Documented backend: operational integration to formalize · No concrete repository transport contract is established.
- YOLO people counter → Documented backend: operational integration to formalize · No concrete repository transport contract is established.
