# red-coder-27/smart-traffic-light-and-violation-monitoring-system architecture

> Architecture diagram of the GitHub repository red-coder-27/smart-traffic-light-and-violation-monitoring-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system
- Repository: https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system

## Overview

The repository combines a Java traffic-monitoring logic prototype with a web application: a React interface calls an Express API for authentication, profiles, role-gated intersection management, and traffic-signal configuration. The Java modules implement a separate core for vehicle counting, congestion analysis, and signal control; no connection from that core to the web API is shown. Backend excerpts support its route, controller, authorization, and Prisma relationships. The README describes PostgreSQL deployment, but says the application is not deployed.

Main entry points: [`backend/src/server.ts`](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/server.ts) (Express server), [`backend/src/lib/prisma.ts`](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/lib/prisma.ts) (Prisma client), [`backend/src/routes/intersectionRoutes.ts`](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/routes/intersectionRoutes.ts) (Intersection routes), [`backend/src/routes/trafficSignalRoutes.ts`](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/routes/trafficSignalRoutes.ts) (Signal routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_app["React app<br/>[App.tsx]"]
end

subgraph group_api["Backend API"]
  node_server["Express server<br/>[server.ts]"]
  node_authroutes["Authentication routes<br/>[authRoutes.ts]"]
  node_authcontroller["Authentication<br/>[authController.ts]"]
  node_profile_routes["Profile routes<br/>[profileRoutes.ts]"]
  node_profile_controller["Profile management"]
  node_rbac["Role access routes<br/>[rbacRoutes.ts]"]
  node_authmw["Token authentication<br/>[authMiddleware.ts]"]
  node_rolemw["Role authorization<br/>[roleMiddleware.ts]"]
  node_intersection_routes["Intersection routes"]
  node_intersection_controller["Intersection management"]
  node_signal_routes["Signal routes"]
  node_signal_controller["Signal configuration"]
end

subgraph group_domain["Traffic logic"]
  node_counter["Vehicle counting"]
  node_vehicle_type["Vehicle types<br/>[VehicleType.java]"]
  node_congestion["Congestion analysis"]
  node_signal_logic["Signal control logic"]
end

subgraph group_storage["Persistence"]
  node_prisma["Prisma client<br/>[prisma.ts]"]
  node_postgres[("PostgreSQL")]
end

node_browser(("Browser user"))

node_browser -->|"uses"| node_app
node_app -->|"calls API"| node_server
node_server -->|"mounts"| node_authroutes
node_server -->|"mounts"| node_profile_routes
node_server -->|"mounts"| node_rbac
node_server -->|"mounts"| node_intersection_routes
node_server -->|"mounts"| node_signal_routes
node_authroutes -->|"routes to"| node_authcontroller
node_profile_routes -->|"routes to"| node_profile_controller
node_rbac -->|"authenticates"| node_authmw
node_rbac -->|"checks role"| node_rolemw
node_intersection_routes -->|"authenticates"| node_authmw
node_intersection_routes -->|"checks role"| node_rolemw
node_intersection_routes -->|"routes to"| node_intersection_controller
node_signal_routes -->|"authenticates"| node_authmw
node_signal_routes -->|"checks role"| node_rolemw
node_signal_routes -->|"routes to"| node_signal_controller
node_authcontroller -->|"reads and writes"| node_prisma
node_profile_controller -->|"reads and writes"| node_prisma
node_intersection_controller -->|"reads and writes"| node_prisma
node_signal_controller -->|"reads and writes"| node_prisma
node_prisma -->|"connects"| node_postgres
node_counter -->|"uses"| node_vehicle_type
node_signal_logic -->|"uses"| node_congestion

click node_app "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/frontend/src/App.tsx"
click node_server "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/server.ts"
click node_authroutes "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/routes/authRoutes.ts"
click node_authcontroller "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/controllers/authController.ts"
click node_profile_routes "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/routes/profileRoutes.ts"
click node_profile_controller "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/controllers/profileController.ts"
click node_rbac "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/routes/rbacRoutes.ts"
click node_authmw "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/middleware/authMiddleware.ts"
click node_rolemw "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/middleware/roleMiddleware.ts"
click node_intersection_routes "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/routes/intersectionRoutes.ts"
click node_intersection_controller "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/controllers/intersectionController.ts"
click node_signal_routes "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/routes/trafficSignalRoutes.ts"
click node_signal_controller "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/controllers/trafficSignalController.ts"
click node_prisma "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/lib/prisma.ts"
click node_counter "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/src/main/java/com/trafficmonitor/VehicleCounter.java"
click node_vehicle_type "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/src/main/java/com/trafficmonitor/VehicleType.java"
click node_congestion "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/src/main/java/com/trafficmonitor/CongestionAnalyzer.java"
click node_signal_logic "https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/src/main/java/com/trafficmonitor/TrafficSignalController.java"

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_browser toneBlue
class node_server,node_authroutes,node_authcontroller,node_profile_routes,node_profile_controller,node_rbac,node_authmw,node_rolemw,node_intersection_routes,node_intersection_controller,node_signal_routes,node_signal_controller toneAmber
class node_counter,node_vehicle_type,node_congestion,node_signal_logic toneMint
class node_prisma,node_postgres toneRose
```

## Components

### Web interface

- [React app](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`

### Backend API

- [Express server](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/server.ts): `backend/src/server.ts`
- [Authentication routes](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/routes/authRoutes.ts): `backend/src/routes/authRoutes.ts`
- [Authentication](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/controllers/authController.ts): `backend/src/controllers/authController.ts`
- [Profile routes](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/routes/profileRoutes.ts): `backend/src/routes/profileRoutes.ts`
- [Profile management](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/controllers/profileController.ts): `backend/src/controllers/profileController.ts`
- [Role access routes](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/routes/rbacRoutes.ts): `backend/src/routes/rbacRoutes.ts`
- [Token authentication](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/middleware/authMiddleware.ts): `backend/src/middleware/authMiddleware.ts`
- [Role authorization](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/middleware/roleMiddleware.ts): `backend/src/middleware/roleMiddleware.ts`
- [Intersection routes](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/routes/intersectionRoutes.ts): `backend/src/routes/intersectionRoutes.ts`
- [Intersection management](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/controllers/intersectionController.ts): `backend/src/controllers/intersectionController.ts`
- [Signal routes](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/routes/trafficSignalRoutes.ts): `backend/src/routes/trafficSignalRoutes.ts`
- [Signal configuration](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/controllers/trafficSignalController.ts): `backend/src/controllers/trafficSignalController.ts`

### Traffic logic

- [Vehicle counting](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/src/main/java/com/trafficmonitor/VehicleCounter.java): `src/main/java/com/trafficmonitor/VehicleCounter.java`
- [Vehicle types](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/src/main/java/com/trafficmonitor/VehicleType.java): `src/main/java/com/trafficmonitor/VehicleType.java`
- [Congestion analysis](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/src/main/java/com/trafficmonitor/CongestionAnalyzer.java): `src/main/java/com/trafficmonitor/CongestionAnalyzer.java`
- [Signal control logic](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/src/main/java/com/trafficmonitor/TrafficSignalController.java): `src/main/java/com/trafficmonitor/TrafficSignalController.java`

### Persistence

- [Prisma client](https://github.com/red-coder-27/smart-traffic-light-and-violation-monitoring-system/blob/main/backend/src/lib/prisma.ts): `backend/src/lib/prisma.ts`
- **PostgreSQL**

### Other components

- **Browser user**

## Connections

- Browser user → React app: uses (evidence: `README.md`)
- React app → Express server: calls API (evidence: `frontend/src/App.tsx`)
- Express server → Authentication routes: mounts (evidence: `backend/src/server.ts`)
- Express server → Profile routes: mounts (evidence: `backend/src/server.ts`)
- Express server → Role access routes: mounts (evidence: `backend/src/server.ts`)
- Express server → Intersection routes: mounts (evidence: `backend/src/server.ts`)
- Express server → Signal routes: mounts (evidence: `backend/src/server.ts`)
- Authentication routes → Authentication: routes to (evidence: `backend/src/routes/authRoutes.ts`)
- Profile routes → Profile management: routes to (evidence: `backend/src/routes/profileRoutes.ts`)
- Role access routes → Token authentication: authenticates (evidence: `backend/src/routes/rbacRoutes.ts`)
- Role access routes → Role authorization: checks role (evidence: `backend/src/routes/rbacRoutes.ts`)
- Intersection routes → Token authentication: authenticates (evidence: `backend/src/routes/intersectionRoutes.ts`)
- Intersection routes → Role authorization: checks role (evidence: `backend/src/routes/intersectionRoutes.ts`)
- Intersection routes → Intersection management: routes to (evidence: `backend/src/routes/intersectionRoutes.ts`)
- Signal routes → Token authentication: authenticates (evidence: `backend/src/routes/trafficSignalRoutes.ts`)
- Signal routes → Role authorization: checks role (evidence: `backend/src/routes/trafficSignalRoutes.ts`)
- Signal routes → Signal configuration: routes to (evidence: `backend/src/routes/trafficSignalRoutes.ts`)
- Authentication → Prisma client: reads and writes (evidence: `backend/src/controllers/authController.ts`)
- Profile management → Prisma client: reads and writes (evidence: `backend/src/controllers/profileController.ts`)
- Intersection management → Prisma client: reads and writes (evidence: `backend/src/controllers/intersectionController.ts`)
- Signal configuration → Prisma client: reads and writes (evidence: `backend/src/controllers/trafficSignalController.ts`)
- Prisma client → PostgreSQL: connects (evidence: `backend/src/lib/prisma.ts`)
- Vehicle counting → Vehicle types: uses (evidence: `src/main/java/com/trafficmonitor/VehicleCounter.java`)
- Signal control logic → Congestion analysis: uses (evidence: `src/main/java/com/trafficmonitor/TrafficSignalController.java`)
