An end-to-end local-network intelligent parking surveillance and ticket generation system. This system integrates an ESP32-CAM edge client with a FastAPI AI processing backend and a real-time React visualization dashboard.
graph TD
subgraph ESP32-CAM Client
A[Trigger Event / Motion / Button] --> B[Capture JPEG Frame]
B --> C[HTTP POST /api/upload]
end
subgraph FastAPI Backend
C --> D{YOLOv8 Detection}
D -- "Vehicle Detected" --> E[Generate QR Code Ticket]
E --> F[Save to SQLite Database]
F --> G[Broadcast ws:// Event NEW_TICKET]
D -- "No Vehicle" --> H[Broadcast ws:// Event REJECTED]
end
subgraph React Dashboard
G --> I[Real-time Ticket UI Update]
H --> J[Real-time Rejection UI Update]
end
- ESP_CAM_32/: PlatformIO project containing ESP32-CAM firmware (C++).
- parking_backend/: FastAPI application featuring YOLOv8 vehicle detection, SQLite database modeling, QR code generation, and WebSocket broadcasts.
- parking_dashboard/: Single Page Application built on React, Vite, and Tailwind CSS.
- CP210x_Universal_Windows_Driver.zip: Essential USB-to-UART Silicon Labs bridge driver for flashing the ESP32-CAM module on Windows.
- Extract CP210x_Universal_Windows_Driver.zip.
- Right-click on
silabser.infand select Install to register the Silicon Labs CP210x USB-to-UART driver. - Connect your ESP32-CAM module to your PC via a micro-USB cable or FTDI adapter. It should now map to a valid COM port.
- Environment: Python 3.9 or higher.
- Navigate to the backend directory:
cd parking_backend - Create and activate a Python virtual environment:
python -m venv venv .\venv\Scripts\Activate.ps1
- Install dependencies:
pip install -r requirements.txt
- Run the FastAPI development server:
The server starts on
python main.py
http://0.0.0.0:8000. The YOLOv8 model weightsyolov8n.ptwill download automatically on the first execution.
- Environment: Node.js v18 or higher.
- Navigate to the frontend directory:
cd parking_dashboard - Install the package dependencies:
npm install
- Boot up the Vite dev server:
Access the web UI at
npm run dev
http://localhost:5173.
- Endpoint:
http://<SERVER_IP>:8000/api/upload - Method:
POST - Payload Format:
multipart/form-data - Parameter Name:
file(must contain image file bytes, filename ending with.jpg,.jpeg, or.png)
Detection Success (200 OK):
{
"status": "success",
"ticket": {
"id": 12,
"ticket_id": "PKG-20260525-F3E8A9",
"vehicle_type": "car",
"confidence": 0.94,
"timestamp": "2026-05-25T11:16:00.000",
"image_path": "/static/images/F3E8A9.jpg",
"qr_path": "/static/qrs/PKG-20260525-F3E8A9.png"
}
}Detection Failure (200 OK):
{
"status": "rejected",
"message": "No vehicle detected",
"image": "F3E8A9.jpg"
}- Edge Frame Capture: The ESP32-CAM wakes upon button click or sensor trigger, captures a frame, and transmits an HTTP POST payload to the FastAPI
/api/uploadendpoint. - AI Inference: The FastAPI backend receives the binary stream, runs YOLOv8 deep learning model checks to detect vehicles (
car,motorcycle,bus,truck), and evaluates prediction confidence. - Database & Generation:
- If a vehicle is detected, a unique alphanumeric identifier is generated. A ticket entry is saved in SQLite, and a custom QR code is created.
- If no vehicle is found, the entry is logged as rejected.
- WebSocket Broadcast: Events (
NEW_TICKETorREJECTED) are pushed instantly through active WebSocket channels (ws://<SERVER_IP>:8000/ws). - Dashboard Visualization: The React frontend maps incoming WebSocket updates to update the reactive grid display without requiring page refreshes.