How narusornruengchot/traffic-project works
KU SRC is a real-time traffic analytics product: users configure a video or CCTV source and tripwire, start a stream, and receive annotated video, vehicle counts, congestion metrics, and incident alerts; they can also review and export historical reports. The main path runs from the React dashboard through WebSocket commands to a background stream worker and traffic pipeline, with events persisted for reporting. README capabilities also include uploads, model selection, CCTV testing, calibration, and CSV export. Relationships for unsampled modules are included only where the README or SOURCE INDEX supports them.
Main entry points: traffic_pipeline.py Frame pipeline · App.jsx Dashboard shell · stream.py Stream commands · state.py Runtime state
Components 29
Dashboard
- Dashboard shell
frontend/src/App.jsx - Stream controls
frontend/src/components/ControlPanel.jsx - Live telemetry
frontend/src/components/VideoPlayer.jsx - Metrics and charts
frontend/src/components/AnalyticsCharts.jsx - Event log
frontend/src/components/EventLogTable.jsx - History reports
frontend/src/components/HistoryReport.jsx - Incident alerts
frontend/src/components/IncidentAlerts.jsx - WebSocket client
frontend/src/hooks/useTrafficWebSocket.js - REST client
frontend/src/services/api.js
API and control
- FastAPI server
server.py - Stream commands
src/api/routers/stream.py - Media endpoints
src/api/routers/media.py - CCTV testing
src/api/routers/cctv.py - Report endpoints
src/api/routers/reports.py - Runtime state
src/api/state.py - Runtime settings
src/config/settings.py
Traffic processing
- Stream worker
src/services/stream_worker.py - Frame pipeline
src/core/traffic_pipeline.py - Vehicle detection
src/core/vehicle_detector.py - Vehicle tracking
src/core/vehicle_tracker.py - Tripwire counting
src/core/lane_counter.py - Speed estimation
src/core/speed_estimator.py - Congestion analytics
src/core/analytics.py - Incident detection
src/core/incident_detector.py - Frame annotation
src/visualizer/annotator.py - Source discovery
src/utils/file_helper.py - Telemetry schema
src/schema/telemetry.py
History and reporting
- SQLite analytics
src/database/db_manager.py
Other components
- Traffic operator
Connections 39
- Traffic operator → Dashboard shell: uses
README.md - Dashboard shell → Stream controls: renders
frontend/src/App.jsx - Dashboard shell → Live telemetry: renders
frontend/src/App.jsx - Dashboard shell → Metrics and charts: renders
frontend/src/App.jsx - Dashboard shell → Event log: renders
frontend/src/App.jsx - Dashboard shell → History reports: renders
frontend/src/App.jsx - Dashboard shell → Incident alerts: renders
frontend/src/App.jsx - Dashboard shell → WebSocket client: uses
frontend/src/App.jsx - Stream controls → REST client: requests
frontend/src/components/ControlPanel.jsx - History reports → REST client: requests
frontend/src/components/HistoryReport.jsx - Event log → REST client: requests
frontend/src/components/EventLogTable.jsx - WebSocket client → Stream commands: sends commands
README.md - REST client → Media endpoints: calls media routes
frontend/src/services/api.js - REST client → Report endpoints: calls report routes
frontend/src/services/api.js - FastAPI server → Stream commands: registers
server.py - FastAPI server → Media endpoints: registers
server.py - FastAPI server → Report endpoints: registers
server.py - FastAPI server → CCTV testing: registers
server.py - Stream commands → Runtime state: gets runtime state
src/api/routers/stream.py - Stream commands → Stream worker: dispatches commands
src/api/routers/stream.py - Runtime state → Runtime settings: configures defaults
src/api/state.py - Runtime state → Frame pipeline: creates engine
src/api/state.py - Runtime state → Stream worker: manages worker
src/api/state.py - Stream commands → Source discovery: resolves sources
src/api/routers/stream.py - Media endpoints → Source discovery: discovers media
src/api/routers/media.py - Media endpoints → Frame pipeline: requests previews
src/api/routers/media.py - CCTV testing → Runtime state: uses runtime state
src/api/routers/cctv.py - Stream worker → Frame pipeline: processes frames
src/services/stream_worker.py - Frame pipeline → Vehicle detection: detects vehicles
src/core/traffic_pipeline.py - Frame pipeline → Vehicle tracking: tracks detections
src/core/traffic_pipeline.py - Frame pipeline → Tripwire counting: counts crossings
src/core/traffic_pipeline.py - Frame pipeline → Speed estimation: estimates speed
src/core/traffic_pipeline.py - Frame pipeline → Congestion analytics: scores traffic
src/core/traffic_pipeline.py - Frame pipeline → Incident detection: detects incidents
src/core/traffic_pipeline.py - Frame pipeline → Frame annotation: annotates frames
src/core/traffic_pipeline.py - Frame pipeline → Telemetry schema: produces telemetry
src/core/traffic_pipeline.py - Congestion analytics → Telemetry schema: uses schema
src/core/analytics.py - Stream worker → SQLite analytics: persists events and snapshots
src/services/stream_worker.py - Report endpoints → SQLite analytics: queries history
src/api/routers/reports.py