How karinzaa/junctionkanshi works
Project type and purpose
• This is an IoT-enabled full-stack traffic monitoring and control system.
• Purpose: collect real-time vehicle counts from edge devices, analyze congestion, notify stakeholders (police, tech providers, public), and present data in a web dashboard.
File structure
• Top-level modules:
• Traffic-Monitoring (backend Python service)
• Traffic-Notif (edge device firmware in C++/PlatformIO)
• JunctionKanshi-web (static web frontend)
• Traffic-Monitoring contains
• comm_task/mqtt_client.py – subscribes to device data via MQTT
• analysis.py – runs AI/vehicle-detection logic (uses vech.xml)
• main.py – orchestrates data ingestion, analysis, and output
• traffic_data/traffic_data.json – stores or exports processed counts
• static/ – possibly holds assets for dashboard or API
• Traffic-Notif contains firmware for microcontrollers to read sensors and publish MQTT messages.
• JunctionKanshi-web is a PWA-style static site (HTML, CSS, JS, service worker) that fetches traffic_data.json and renders live/offline views.
Extract insights from the README
• Stakeholders: traffic controller, tech providers, general public
• User stories require real-time monitoring, device status map, push notifications on congestion
Components
a. Devices layer (edge)
• Traffic-Notif microcontrollers (sensor + firmware)
• Communication via MQTT protocol to an MQTT broker
b. Backend services
• MQTT broker (e.g., Mosquitto)
• Python ingestion service (mqtt_client)
• Analysis engine (analysis.py using vech.xml for vehicle detection)
• Data store (traffic_data.json or a database)
• Notification module (triggers alerts when thresholds met)
c. Frontend layer
• Static web application (JunctionKanshi-web) served from web server or CDN
• Service worker for offline support (sw.js)
• Web push or SMS/email gateway for notifications to users
d. External/third-party services
• Mapping API for device location map
• Push notification service (Firebase, Web Push)
Relationships and data flows
• Edge device → (MQTT publish) → MQTT broker
• MQTT broker → (MQTT subscribe) → Python ingestion (comm_task)
• Ingestion → (inter-process call) → Analysis engine
• Analysis → (write) → Data store
• Analysis → (trigger) → Notification module → (push) → Stakeholders
• Frontend → (HTTP GET) → Data store or backend API → Renders dashboards
• Frontend → (Web Push registration) → Notification service
Architectural patterns and design principles
• Layered architecture: edge, middleware (messaging), backend, frontend
• Event-driven (MQTT topics for data ingestion and notifications)
• Microservices style separation between ingestion, analysis, notifications
• Static-site PWA for scalability and offline support
Technologies and frameworks to call out
• MQTT (broker and mqtt_client.py)
• Python 3 for server logic (main.py, analysis.py)
• OpenCV or similar (implied by vech.xml cascade file)
• PlatformIO/C++ for firmware on microcontrollers
• Plain HTML/CSS/JavaScript PWA for frontend
• JSON for data interchange