How wydoinn/traffic-vision works
Project Type and Purpose
• Full-stack AI + IoT system for traffic monitoring and adaptive signal control.
• Combines a desktop GUI (PyQt6), ML inference (YOLOv8), database storage (SQLite), web dashboard (Streamlit), hardware simulation (Arduino), and notification service (Telegram Bot).
File Structure
Top-level modules:
– app.py / main.py: Application startup & main UI window
– controller/: Traffic light control logic
– db/: Data collection and SQLite interaction
– hardware_simulation/: Arduino sketches & PCB design
– inference.py: Video processing & ML inference pipeline
– manager.py: Zone management & overall workflow
– models/: Trained YOLOv8 model configs & results
– static/: UI assets & styles
– ui/: PyQt6 UI components (controls, monitoring, settings, traffic light)
– utils/: Constants, error handling, health monitoring, notification
– visualizer.py: Streamlit analytics dashboard
– config_manager.py: Centralized configuration loader
– logger.py: Application logging
– version.py: Version tracking
README for Architecture Clues
• Tech stack: YOLOv8m, PyQt6, SQLite, Streamlit, Arduino, Telegram Bot.
Main Components
a. Presentation Layer
– PyQt6 GUI (app.py, main.py, ui/)
– Streamlit Dashboard (visualizer.py)
b. Business Logic Layer
– Zone Manager (manager.py)
– Inference Engine (inference.py + models/)
– Traffic Controller (controller/light_controller.py)
– Configuration Manager (config_manager.py)
– Notification Service (utils/notifier.py → Telegram Bot)
– Logging & Error Handler (logger.py, utils/error_handler.py)
c. Data Layer
– SQLite Database (db/database.py, db/data_collector.py → /data/traffic_data.db)
d. Hardware Layer
– Arduino Traffic Light Simulation (hardware_simulation/*.ino)
e. Auxiliary Services
– Health Monitor (utils/health_monitor.py)
– Constants & Utilities (utils/constants.py)
Relationships and Data Flows
1. User launches PyQt6 GUI → loads settings via Config Manager.
2. UI actions (start inference, define zones) → Zone Manager.
3. Zone Manager orchestrates:
• Inference Engine reads video frames → performs Object Detection, Tracking, Heatmap Generation using YOLOv8 models.
• Sends detection events to:
– Traffic Controller → computes signal timings → communicates via Serial to Arduino Simulation.
– Data Collector → writes metrics to SQLite.
– Notification Service → sends Telegram alerts for accidents/emergencies.
4. Database is read by Streamlit Dashboard for historical analysis and real-time charts.
5. Logger captures events/errors at each stage; Health Monitor oversees system status.
Architectural Patterns and Design Principles
• Layered architecture (Presentation / Logic / Data / Hardware).
• Modular design: each major function (inference, control, storage, UI) in its own module.
• Event-driven notifications and data collection.
• Clear separation of configuration (config_manager) and logging (logger).
[ ] Main components clearly labeled
[ ] Modular containers for subsystems
[ ] External services and hardware interfaces depicted
[ ] ML models and configuration loading highlighted
[ ] Logging and error handling included