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.
- 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.dnnon 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.
npm installnpm run devStarts:
- SPA at http://localhost:5173
- Express API at http://127.0.0.1:5001
npm run dev:web # Vite SPA only
npm run dev:api # Express API only
npm run build # production build for SPACopy .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.
Deploy to the Pi (requires SSH access via rpi-zero-dabrowskiego):
cd capture && ./deploy.shIdempotent — 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 -fDeploy manually from a local machine (requires SSH access via rpi-zero-camera):
cd api && ./deploy.shDeploy manually from a local machine (requires SSH access via rpi-zero-camera):
./detection/deploy.shLogs:
ssh rpi-zero-camera journalctl -u dabrowskiego-detection -fThe SPA is deployed automatically via GitHub Actions on push to main (deploy-spa.yml — S3 + CloudFront).