Real-time AI-powered surveillance system for schools using YOLOv8 object detection with zone-based threat analysis.
This project is structured for Vercel (frontend) + Render (backend) deployment.
SecVidA/
├── frontend/ # Next.js app (Vercel)
│ ├── pages/ # Monitor, config pages
│ ├── components/ # React components
│ └── .env.example # Environment template
├── backend/ # FastAPI server (Render)
│ ├── main.py # API endpoints
│ ├── engine.py # Event scoring
│ ├── service.py # Alert generation
│ ├── worker/ # YOLOv8 detection
│ ├── zones/ # Zone processors
│ ├── models/ # YOLO model weights
│ ├── Dockerfile # Container config
│ └── requirements.txt
└── test_videos/ # Sample test videos
backendPORT=10000MODULE=schoolFRONTEND_URL=https://your-app.vercel.appfrontendNEXT_PUBLIC_API_BASE=https://your-render-app.onrender.comcd backend
pip install -r requirements.txt
cd frontend
npm install
cd backend
uvicorn main:app --reload --port 8000
cd frontend
npm run dev
cd backend/worker
python test_worker.py corridor "../../test_videos/school/your_video.mp4"
| Zone | Detects | YOLO Classes Used |
|---|---|---|
outgate | Vehicles, Gate Accidents | car, bus, truck, motorcycle |
corridor | Crowd Formation, Fights | person |
school_ground | Crowd Formation, Fights | person |
classroom | Mobile Phone Usage | person, cell phone |
POST /event - Submit detection eventGET /incidents - List all incidentsGET /incident/{id}/summary - LLM-generated summaryGET /incident/{id}/pdf - Download PDF reportGET /api/zones - Get zone definitionsGET /api/cameras - List camera configurationsPOST /api/camera/{id} - Update camera configGET /video/{camera_id} - MJPEG stream for cameraGET /live_feed - Default camera feedWS /ws/alerts - Real-time alert WebSocketbackend/.env)PORT=8000
MODULE=school
FRONTEND_URL=*
LLM_API_BASE=http://localhost:11434/v1
LLM_API_KEY=your-api-key
frontend/.env)NEXT_PUBLIC_API_BASE=https://your-render-app.onrender.com
For local development, omit NEXT_PUBLIC_API_BASE to use http://localhost:8000.
Status: ✅ FULLY IMPLEMENTED AND TESTED
This project now includes a comprehensive, production-ready event delivery pipeline with detailed logging at every step:
# Terminal 1: Backend
cd backend && uvicorn main:app --reload --port 8000
# Terminal 2: Frontend
cd dashboard && npm run dev
# Terminal 3: Test (pick one)
python scripts/test_event_flow.py # Full test suite
curl http://localhost:8000/api/debug/ping # Quick debug ping
python ai_worker/test_worker.py school_ground test_videos/school/demo.mp4 # Real detection
✅ Worker event emission with detailed logging
✅ EventCooldownManager prevents flooding with escalation detection
✅ SharedDetectors singleton for optimized GPU memory
✅ Backend event reception with schema validation
✅ WebSocket broadcasting with per-client tracking
✅ Frontend console logging for debugging
✅ Debug ping endpoint for testing without worker
✅ Production-ready error handling throughout
| Component | Key Tags |
|---|---|
| Worker | [EVENT_EMIT] [EVENT_DELIVERY_OK] [EVENT_SUPPRESSED] |
| Backend | [EVENT_RX_ACCEPT] [EVENT_INCIDENT_DETECTED] [BROADCAST_QUEUED] |
| WebSocket | [WS_BROADCAST_START] [WS_SEND_OK] [WS_CLIENT_CONNECTED] |
| Frontend | [WS_MESSAGE_RX] [ALERT_DISPLAYED] (browser console F12) |
See QUICK_REFERENCE.md for complete reference.
MIT License
Real-time AI-powered surveillance system for schools using YOLOv8 object detection with zone-based threat analysis.
This project is structured for Vercel (frontend) + Render (backend) deployment.
SecVidA/
├── frontend/ # Next.js app (Vercel)
│ ├── pages/ # Monitor, config pages
│ ├── components/ # React components
│ └── .env.example # Environment template
├── backend/ # FastAPI server (Render)
│ ├── main.py # API endpoints
│ ├── engine.py # Event scoring
│ ├── service.py # Alert generation
│ ├── worker/ # YOLOv8 detection
│ ├── zones/ # Zone processors
│ ├── models/ # YOLO model weights
│ ├── Dockerfile # Container config
│ └── requirements.txt
└── test_videos/ # Sample test videos
backendPORT=10000MODULE=schoolFRONTEND_URL=https://your-app.vercel.appfrontendNEXT_PUBLIC_API_BASE=https://your-render-app.onrender.comcd backend
pip install -r requirements.txt
cd frontend
npm install
cd backend
uvicorn main:app --reload --port 8000
cd frontend
npm run dev
cd backend/worker
python test_worker.py corridor "../../test_videos/school/your_video.mp4"
| Zone | Detects | YOLO Classes Used |
|---|---|---|
outgate | Vehicles, Gate Accidents | car, bus, truck, motorcycle |
corridor | Crowd Formation, Fights | person |
school_ground | Crowd Formation, Fights | person |
classroom | Mobile Phone Usage | person, cell phone |
POST /event - Submit detection eventGET /incidents - List all incidentsGET /incident/{id}/summary - LLM-generated summaryGET /incident/{id}/pdf - Download PDF reportGET /api/zones - Get zone definitionsGET /api/cameras - List camera configurationsPOST /api/camera/{id} - Update camera configGET /video/{camera_id} - MJPEG stream for cameraGET /live_feed - Default camera feedWS /ws/alerts - Real-time alert WebSocketbackend/.env)PORT=8000
MODULE=school
FRONTEND_URL=*
LLM_API_BASE=http://localhost:11434/v1
LLM_API_KEY=your-api-key
frontend/.env)NEXT_PUBLIC_API_BASE=https://your-render-app.onrender.com
For local development, omit NEXT_PUBLIC_API_BASE to use http://localhost:8000.
Status: ✅ FULLY IMPLEMENTED AND TESTED
This project now includes a comprehensive, production-ready event delivery pipeline with detailed logging at every step:
# Terminal 1: Backend
cd backend && uvicorn main:app --reload --port 8000
# Terminal 2: Frontend
cd dashboard && npm run dev
# Terminal 3: Test (pick one)
python scripts/test_event_flow.py # Full test suite
curl http://localhost:8000/api/debug/ping # Quick debug ping
python ai_worker/test_worker.py school_ground test_videos/school/demo.mp4 # Real detection
✅ Worker event emission with detailed logging
✅ EventCooldownManager prevents flooding with escalation detection
✅ SharedDetectors singleton for optimized GPU memory
✅ Backend event reception with schema validation
✅ WebSocket broadcasting with per-client tracking
✅ Frontend console logging for debugging
✅ Debug ping endpoint for testing without worker
✅ Production-ready error handling throughout
| Component | Key Tags |
|---|---|
| Worker | [EVENT_EMIT] [EVENT_DELIVERY_OK] [EVENT_SUPPRESSED] |
| Backend | [EVENT_RX_ACCEPT] [EVENT_INCIDENT_DETECTED] [BROADCAST_QUEUED] |
| WebSocket | [WS_BROADCAST_START] [WS_SEND_OK] [WS_CLIENT_CONNECTED] |
| Frontend | [WS_MESSAGE_RX] [ALERT_DISPLAYED] (browser console F12) |
See QUICK_REFERENCE.md for complete reference.
MIT License