Distributed Telemetry & Surveillance System
Real-time acoustic and visual threat detection using edge AI, mesh networking, and multi-agent correlation.
Architecture β’ Quick Start β’ Components β’ Documentation β’ License
NISHA Sentinel is a production-grade surveillance platform that connects distributed audio/video sensor agents to a central AI backend for real-time threat detection. The system employs:
- Edge Agents: ESP32 microcontrollers + mobile phones streaming audio/video
- Master Nodes: Raspberry Pi aggregators with local buffering and failover
- Central Backend: FastAPI service with YOLOv8+LSTM violence detection
- Dashboard: Next.js web app with real-time maps, topology graphs, and alerts
- AI Pipeline: Pose estimation + behavior classification + multi-agent correlation
Key Features:
- β Binary NISHA protocol (24-byte header, priority queues)
- β Continuous video streaming + audio capture
- β GPS location tracking with background updates
- β AI violence detection (78% accuracy, real-time)
- β Multi-agent event correlation (spatio-temporal)
- β Mesh topology with handoff & failover
- β Delta-based configuration management
- β WebSocket real-time updates
- β Docker Compose deployment
βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ
β ESP32 β β Mobile β β Master β β Backend β
β Agent ββββββΊβ Agent ββββββΊβ Node ββββββΊβ (FastAPI) β
β (Audio) β β (AV+GPS) β β (Pi) β β β
βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ
β
βΌ
ββββββββββββββββββββ
β PostgreSQL β
β + Redis β
ββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββ
β Next.js β
β Dashboard β
ββββββββββββββββββββ
Protocol: NISHA binary frames (TELEMETRY, VIDEO, AUDIO, LOCATION streams with 4 priority levels).
AI Models: YOLOv8-nano/pose (6.8 MB) + Bi-LSTM (7 MB) for violence classification.
Streaming: WebSocket with exponential reconnection, RAM+disk buffering.
- Docker & Docker Compose (recommended)
- OR: Python 3.11+, Node.js 20+, PostgreSQL 16, Redis 7
git clone <your-fork>
cd NISHA_SENTINEL
docker-compose up -d
# Services start:
# - Backend: http://localhost:8000
# - Frontend: http://localhost:3000
# - Master: http://localhost:8080
# - Postgres: localhost:5432
# - Redis: localhost:6379See component-specific guides in docs/:
| Component | Language | Port | Purpose |
|---|---|---|---|
| Backend | Python 3.11 | 8000 | Central API, AI, WebSocket hub |
| Frontend | TypeScript | 3000 | Real-time dashboard |
| Master | Python 3.11 | 8080/8082 | Agent aggregator, buffer, local UI |
| Mobile Agent | React Native | N/A | iOS/Android sensor app |
| ESP32 Agent | C++ | N/A | Edge audio sensor |
| AI Models | Python/PyTorch | N/A | Violence detection |
Data Flow: Agent β Master β Backend β Dashboard
Protocol: Binary NISHA frames over WebSocket
- Full Architecture Guide - System design, patterns, data model
- Integration PRD - Product requirements, API specs, scaling strategy
- System Operations - Startup sequence, troubleshooting, monitor
- Startup Guide - Quick command reference
- Backend - FastAPI, Docker, AI integration, gitignore
- Frontend - Next.js, state, visualizations, gitignore
- Master Node - Raspberry Pi software, buffering, dashboard
- Mobile Agent - Expo app, streaming, permissions
- ESP32 Agent - Firmware, I2S, flashing, security
- Documentation Index - Complete guide to all docs
cd Backend
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
uvicorn nisha.main:app --reload --port 8000
# API docs: http://localhost:8000/docs
# Tests:
pytest tests/ -m unitcd Frontend
npm install
npm run dev # β http://localhost:3000
# Lint
npm run lint
# Build
npm run buildcd masters
python -m venv .venv
source .venv/bin/activate
pip install -e .
uvicorn nisha_master.main:app --port 8080
# Dashboard: http://localhost:8080cd Nisha-mobile-agent/frontend
npm install
npx expo start
# a β Android emulator
# i β iOS simulator
# Scan QR β Expo Go appcd agents/esp32_s3_agent
# Edit config.h with WiFi + Master IP
pio run -e esp32-s3-box -t upload
pio run -e esp32-s3-box -t monitor # Serial @ 115200# Backend unit tests (fast, no DB)
cd Backend && pytest tests/ -m unit
# Backend integration (requires Postgres+Redis)
cd Backend && pytest tests/ -m integration
# Frontend type check
cd Frontend && npx tsc --noEmit
# Frontend lint
cd Frontend && npm run lint# Full stack
docker-compose up -d
# Single service
docker-compose up -d backend postgres redis
# View logs
docker-compose logs -f backend
# Stop
docker-compose down
# Rebuild
docker-compose build --no-cache backendβββββββββββββββββββββββββββββββββββββββββββββββ
β Header (24 bytes, big-endian) β
ββββββββββββββ¬ββββββββ¬βββββββ¬βββββββ¬ββββββββββ€
β magic[2] β ver β type β prio β resvd β
β "NI" β 1 β 0x01 β 0-3 β 0 β
ββββββββββββββΌββββββββΌβββββββΌβββββββΌββββββββββ€
β sequence β timestamp β payload β
β uint32 β uint64 (ms) β uint32 β
ββββββββββββββ΄ββββββββ΄βββββββ΄βββββββ΄ββββββββββ€
β meta_len[2] (uint16) β
β metadata (JSON, variable) β
β payload (raw bytes) β
βββββββββββββββββββββββββββββββββββββββββββββββ
Stream Types:
0x01 = TELEMETRY (heartbeat, RSSI, battery)
0x02 = VIDEO (MP4 clip)
0x03 = AUDIO (AAC/WAV)
0x04 = LOCATION (GPS JSON)
Priorities:
0 = CRITICAL (alerts, commands)
1 = EVENT (detections)
2 = CONTINUOUS (video/audio streams)
3 = BACKGROUND (telemetry)
Implemented in:
- Backend:
Backend/src/nisha/infrastructure/websocket/protocol.py - Master:
masters/src/nisha_master/interfaces/agent_ws.py(struct unpack) - Mobile:
Nisha-mobile-agent/frontend/src/utils/protocol.ts(TypeScript DataView) - ESP32:
agents/esp32_s3_agent/src/main.cpp(pragma pack struct)
We follow Conventional Commits.
feat(agent): add health evaluation state machine
fix(ws): handle queue overflow gracefully
refactor(master): separate buffer manager
See component-specific commit templates in docs/.
Before deploying:
- Change all default secrets:
API_KEYin Backend.envJWT_SECRET_KEY
- Enable TLS/WSS (production)
- Rotate ESP32 WiFi credentials (move to config.h)
- Enable PostgreSQL encryption (pgcrypto)
- Configure Redis AUTH
- Set up firewall (-agent ports only)
- Enable audit logging
See docs/backend_setup.md for detailed security checklist.
| Metric | Target |
|---|---|
| Heartbeat latency | <2s |
| Video frame pipeline | <100ms |
| Alert delivery | <5s |
| WS broadcast | <100ms |
| DB write throughput | 1000+ events/s |
| Agents per master | 50 |
- Audio ML model not implemented (heuristic only)
- No OTA updates for ESP32
- Single-threaded ESP32 firmware
- No mesh networking (ESP-NOW planned)
- Limited test coverage (~20%)
- No RBAC (all-or-nothing)
- Mobile background video restricted by OS
See docs/ARCHITECTURE.md for full technical debt list.
MIT License - see LICENSE file in repository.
- Docs:
/docsdirectory - PRD:
Nisha_integration_PRD.md - Ops:
SYSTEM_OPERATIONS.md - Issues: GitHub Issues
Version: 0.1.0-alpha
Last Updated: 2026-05-04
Status: Active Development