Skip to content

biesiad/dabrowskiego

Repository files navigation

Traffic monitoring system. A Raspberry Pi captures street frames every 10 seconds, a detection worker runs YOLOv8n vehicle detection and computes a congestion score, and a React dashboard displays live and historical data.

Architecture

Architecture diagram

  • Capture (Python, Raspberry Pi Zero 2W): reads USB camera, rotates frame 90°, encodes JPEG→Base64, sends to SQS every 10s. Managed by systemd on the Pi.
  • Detection (Python, Raspberry Pi Zero 2W): polls SQS, runs YOLOv8n via cv2.dnn on vehicle classes, filters to a configured lane polygon, computes congestion score, uploads images to S3, stores metadata in DynamoDB. Managed by systemd on the Pi.
  • API (Node.js, Raspberry Pi Zero 2W): Express server reading DynamoDB and generating pre-signed S3 URLs. Exposed publicly via Cloudflare Tunnel (api.dabrowskiego.autos → localhost:5001).
  • Frontend (React + TypeScript, S3/CloudFront): subscribes to API via SSE, shows live feed, congestion badge, and daily history graph.

Development

Install

npm install

Run frontend + API together

npm run dev

Starts:

Run separately

npm run dev:web   # Vite SPA only
npm run dev:api   # Express API only
npm run build     # production build for SPA

Environment

Copy .env.example to .env for local development:

Variable Description
VITE_API_BASE_URL API base URL, e.g. http://127.0.0.1:5001

In production the SPA is a static build — the API URL is baked in at build time via the VITE_API_BASE_URL environment variable set in the CI workflow. See each service's README for its own environment variables.

Capture worker (Raspberry Pi)

Deploy to the Pi (requires SSH access via rpi-zero-dabrowskiego):

cd capture && ./deploy.sh

Idempotent — handles both first-time setup and updates. Installs a systemd service with auto-restart. Logs go to journald (volatile, to protect the SD card).

Logs:

ssh rpi-zero-dabrowskiego journalctl -u dabrowskiego-capture -f

API (Raspberry Pi Zero 2W)

Deploy manually from a local machine (requires SSH access via rpi-zero-camera):

cd api && ./deploy.sh

Detection worker (Raspberry Pi Zero 2W)

Deploy manually from a local machine (requires SSH access via rpi-zero-camera):

./detection/deploy.sh

Logs:

ssh rpi-zero-camera journalctl -u dabrowskiego-detection -f

Deployment (AWS)

The SPA is deployed automatically via GitHub Actions on push to main (deploy-spa.yml — S3 + CloudFront).

About

Traffic Congestion on Dabrowskiego in Krakow

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors