# tharunsai01/capstone_smarttraffic architecture

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

- Interactive diagram: https://gitdiagram.com/tharunsai01/capstone_smarttraffic
- Repository: https://github.com/tharunsai01/capstone_smarttraffic

## Overview

Smart Traffic Management combines a React operations portal with an Express backend for authentication and AI traffic orchestration. The main workflow is: an operator selects zones and signal mode in the dashboard; it requests an orchestration cycle; the backend runs perception, forecasting, incident and emergency assessment, then signal optimization; the dashboard presents metrics and signal recommendations. Authentication supports local credentials and Google OAuth. The tree and excerpts support the orchestration and auth flows, but not the detailed internals of the ML models or several README-described capabilities.

Main entry points: [`backend/services/agenticAI/orchestrator.js`](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/services/agenticAI/orchestrator.js) (Agent Orchestrator), [`backend/routes/ai.js`](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/routes/ai.js) (AI Endpoint), [`frontend/src/App.jsx`](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/frontend/src/App.jsx) (React Router), [`frontend/src/Dashboard.jsx`](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/frontend/src/Dashboard.jsx) (Operations Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portal["Traffic Portal"]
  node_app["React Router<br/>[App.jsx]"]
  node_dashboard["Operations Dashboard<br/>[Dashboard.jsx]"]
  node_citizen["Citizen Portal<br/>[UserPortal.jsx]"]
  node_login["Login and Signup<br/>[Login.jsx]"]
end

subgraph group_api["Backend API"]
  node_server["Express Server<br/>[app.js]"]
  node_ai_route["AI Endpoint<br/>[ai.js]"]
end

subgraph group_agents["Traffic Agents"]
  node_orchestrator["Agent Orchestrator<br/>[orchestrator.js]"]
  node_perception["Traffic Perception<br/>[mlModels.js]"]
  node_forecast["Flow Forecasting<br/>[mlModels.js]"]
  node_incident["Incident Detection<br/>[mlModels.js]"]
  node_emergency["Emergency Priority<br/>[mlModels.js]"]
  node_optimization["Signal Optimization<br/>[mlModels.js]"]
  node_models["Agent Utilities<br/>[utils.js]"]
end

subgraph group_identity["Identity"]
  node_auth_route["Auth Endpoints<br/>[auth.js]"]
  node_auth_controller["Auth Controller<br/>[authController.js]"]
  node_passport["Google OAuth<br/>[passport.js]"]
  node_user_model[("User Records<br/>[User.js]")]
  node_activity_model[("Activity Logs<br/>[ActivityLog.js]")]
end

node_operator(("Operator"))
node_mongo[("MongoDB")]
node_google(("Google"))

node_operator -->|"uses"| node_app
node_app -->|"routes"| node_dashboard
node_app -->|"routes"| node_login
node_app -->|"routes"| node_citizen
node_dashboard -->|"requests status"| node_server
node_dashboard -->|"posts zones"| node_ai_route
node_server -->|"mounts endpoint"| node_ai_route
node_server -->|"mounts endpoints"| node_auth_route
node_login -->|"authenticates"| node_auth_route
node_auth_route -->|"reads and writes"| node_user_model
node_auth_route -->|"starts OAuth"| node_passport
node_passport -->|"reads and writes"| node_user_model
node_passport -.->|"federated login"| node_google
node_auth_controller -->|"reads and writes"| node_user_model
node_auth_controller -->|"records events"| node_activity_model
node_user_model -->|"persists"| node_mongo
node_activity_model -->|"persists"| node_mongo
node_ai_route -->|"runs cycle"| node_orchestrator
node_orchestrator -->|"invokes"| node_perception
node_orchestrator -->|"invokes"| node_forecast
node_orchestrator -->|"invokes"| node_incident
node_orchestrator -->|"invokes"| node_emergency
node_orchestrator -->|"invokes"| node_optimization
node_orchestrator -->|"uses helpers"| node_models
node_orchestrator -->|"returns results"| node_ai_route
node_ai_route -->|"returns payload"| node_dashboard

click node_app "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/frontend/src/App.jsx"
click node_dashboard "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/frontend/src/Dashboard.jsx"
click node_citizen "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/frontend/src/UserPortal.jsx"
click node_login "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/frontend/src/Login.jsx"
click node_server "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/app.js"
click node_ai_route "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/routes/ai.js"
click node_auth_route "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/routes/auth.js"
click node_auth_controller "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/controllers/authController.js"
click node_passport "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/config/passport.js"
click node_orchestrator "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/services/agenticAI/orchestrator.js"
click node_perception "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/services/agenticAI/mlModels.js"
click node_forecast "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/services/agenticAI/mlModels.js"
click node_incident "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/services/agenticAI/mlModels.js"
click node_emergency "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/services/agenticAI/mlModels.js"
click node_optimization "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/services/agenticAI/mlModels.js"
click node_models "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/services/agenticAI/utils.js"
click node_user_model "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/models/User.js"
click node_activity_model "https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/models/ActivityLog.js"

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_dashboard,node_citizen,node_login toneBlue
class node_server,node_ai_route,node_mongo toneAmber
class node_orchestrator,node_perception,node_forecast,node_incident,node_emergency,node_optimization,node_models toneMint
class node_auth_route,node_auth_controller,node_passport,node_user_model,node_activity_model toneRose
class node_operator,node_google toneIndigo
```

## Components

### Traffic Portal

- [React Router](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Operations Dashboard](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/frontend/src/Dashboard.jsx): `frontend/src/Dashboard.jsx`
- [Citizen Portal](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/frontend/src/UserPortal.jsx): `frontend/src/UserPortal.jsx`
- [Login and Signup](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/frontend/src/Login.jsx): `frontend/src/Login.jsx`

### Backend API

- [Express Server](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/app.js): `backend/app.js`
- [AI Endpoint](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/routes/ai.js): `backend/routes/ai.js`

### Traffic Agents

- [Agent Orchestrator](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/services/agenticAI/orchestrator.js): `backend/services/agenticAI/orchestrator.js`
- [Traffic Perception](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/services/agenticAI/mlModels.js): `backend/services/agenticAI/mlModels.js`
- [Flow Forecasting](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/services/agenticAI/mlModels.js): `backend/services/agenticAI/mlModels.js`
- [Incident Detection](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/services/agenticAI/mlModels.js): `backend/services/agenticAI/mlModels.js`
- [Emergency Priority](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/services/agenticAI/mlModels.js): `backend/services/agenticAI/mlModels.js`
- [Signal Optimization](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/services/agenticAI/mlModels.js): `backend/services/agenticAI/mlModels.js`
- [Agent Utilities](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/services/agenticAI/utils.js): `backend/services/agenticAI/utils.js`

### Identity

- [Auth Endpoints](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/routes/auth.js): `backend/routes/auth.js`
- [Auth Controller](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`
- [Google OAuth](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/config/passport.js): `backend/config/passport.js`
- [User Records](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/models/User.js): `backend/models/User.js`
- [Activity Logs](https://github.com/tharunsai01/capstone_smarttraffic/blob/main/backend/models/ActivityLog.js): `backend/models/ActivityLog.js`

### Other components

- **Operator**
- **MongoDB**
- **Google**

## Connections

- Operator → React Router: uses
- React Router → Operations Dashboard: routes
- React Router → Login and Signup: routes
- React Router → Citizen Portal: routes
- Operations Dashboard → Express Server: requests status
- Operations Dashboard → AI Endpoint: posts zones
- Express Server → AI Endpoint: mounts endpoint
- Express Server → Auth Endpoints: mounts endpoints
- Login and Signup → Auth Endpoints: authenticates
- Auth Endpoints → User Records: reads and writes
- Auth Endpoints → Google OAuth: starts OAuth
- Google OAuth → User Records: reads and writes
- Google OAuth → Google: federated login
- Auth Controller → User Records: reads and writes
- Auth Controller → Activity Logs: records events
- User Records → MongoDB: persists
- Activity Logs → MongoDB: persists
- AI Endpoint → Agent Orchestrator: runs cycle
- Agent Orchestrator → Traffic Perception: invokes
- Agent Orchestrator → Flow Forecasting: invokes
- Agent Orchestrator → Incident Detection: invokes
- Agent Orchestrator → Emergency Priority: invokes
- Agent Orchestrator → Signal Optimization: invokes
- Agent Orchestrator → Agent Utilities: uses helpers
- Agent Orchestrator → AI Endpoint: returns results
- AI Endpoint → Operations Dashboard: returns payload
