A comprehensive, offline-first home security system designed for Orange Pi 5 Plus that provides real-time camera monitoring, AI-powered detection, and intelligent alerting without requiring internet connectivity.
- π Offline-First Architecture: Runs entirely on your local network without internet dependency
- πΉ Multi-Camera Support: RTSP, USB, and ONVIF camera integration
- π€ Edge AI Processing: Real-time object detection, person recognition, and custom model training
- β‘ Real-time Processing: Sub-second event detection and alerting
- π¨ Modern Web UI: Responsive React-based interface with live updates
- π§ Modular Architecture: Microservices-based design with MQTT messaging
- π± Mobile Optimized: Works great on phones and tablets
- π Privacy First: All processing happens locally - no video leaves your device
The system uses a microservices architecture with MQTT as the message bus:
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Web Frontend β β Web API β β MQTT Broker β
β (React/Vite) βββββΊβ (Express.js) βββββΊβ (Mosquitto) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ
β SQLite DB β β Camera Ingest β
β β β Worker β
βββββββββββββββββββ βββββββββββββββββββ
β
βββββββββββββββββββ βΌ
β Rules Engine β βββββββββββββββββββ
β β β Inference β
βββββββββββββββββββ β Worker β
β βββββββββββββββββββ
βΌ β
βββββββββββββββββββ βΌ
β Actions Service β βββββββββββββββββββ
β β β Custom Models β
βββββββββββββββββββ β (ONNX Runtime) β
βββββββββββββββββββ
- Docker and Docker Compose
- Node.js 18+ (for development)
- Orange Pi 5 Plus or similar ARM64 device (optimized for)
-
Clone and Setup
git clone <repository-url> cd security-system
-
Environment Configuration
cp .env.example .env # Edit .env with your settings -
Deploy with Docker
docker-compose up -d
-
Access the System
- Web UI: http://localhost:8080
- API: http://localhost:3000
- MQTT WebSocket: ws://localhost:9001
- Node.js 18+
- FFmpeg installed (
brew install ffmpegon macOS,sudo apt install ffmpegon Linux) - Mosquitto MQTT broker (
brew install mosquittoon macOS,sudo apt install mosquittoon Linux)
npm installCreate .env in project root with local overrides:
JWT_SECRET=dev-secret-change-me
# API CORS origin (Vite dev server)
FRONTEND_URL=http://localhost:5173
# MQTT broker URLs
MQTT_BROKER_URL=mqtt://localhost:1883
# SQLite database path (used by API and workers)
DATABASE_PATH=./data/security.db
# Optional tuning
CONFIDENCE_THRESHOLD=0.5
RECORDING_DURATION=30
GPIO_ENABLED=falseCreate local data folder and start Mosquitto with WebSockets enabled:
mkdir -p configs mosquitto-data
mosquitto -c configs/mosquitto-local.confThe local config listens on 1883 (MQTT) and 9001 (WebSocket). If you installed via Homebrew, you can also run:
brew services start mosquittoEnsure a WebSocket listener on 9001 is enabled if using system service.
- API:
npm run dev --workspace=apps/api- Camera Ingest:
npm run dev --workspace=workers/ingest- Inference Worker:
npm run dev --workspace=workers/inference- Rules Engine:
npm run dev --workspace=workers/rules-engine- Actions Service:
npm run dev --workspace=workers/actions-service- Web UI (Vite):
npm run dev --workspace=apps/webTip: You can also start API + UI + workers together:
npm run dev:local- API health:
http://localhost:3001/health - UI:
http://localhost:5173 - MQTT WebSocket:
ws://localhost:9001(UI connects automatically)
- Add a camera in UI (RTSP URL)
- Confirm
Camera Ingestlogs show frames - Confirm
Inference Workeremits detections - See events on the Timeline
- Build and deploy a Custom Detector in the Studio
- Web UI cannot connect: verify Mosquitto is running with WebSocket on
9001 - CORS errors: set
FRONTEND_URL=http://localhost:5173in.env - Database missing: API initializes SQLite and applies migrations automatically on first start
- Username:
admin - Password:
admin123
| Service | Port | Description |
|---|---|---|
| Web UI | 8080 | React-based frontend |
| API | 3000 | REST API and authentication |
| MQTT Broker | 1883/9001 | Message broker (MQTT/WebSocket) |
| Camera Ingest | - | RTSP stream processing |
| Inference | - | AI model processing |
| Rules Engine | - | Event rule processing |
| Actions | - | Alert and notification execution |
Create a .env file with:
# Security
JWT_SECRET=your-secret-key-here
# MQTT
MQTT_BROKER_URL=mqtt://mqtt:1883
# GPIO (for hardware actions)
GPIO_ENABLED=false
# Email notifications
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-app-password
SMTP_FROM=Security System <your-email@gmail.com>
# Recording settings
RECORDING_DURATION=30
MAX_STORAGE_GB=100Cameras support multiple protocols:
- RTSP:
rtsp://username:password@ip:port/stream - HTTP:
http://ip:port/video.mjpg - USB:
/dev/video0 - ONVIF: Auto-discovery supported
- Person Detection: YOLO-based person identification
- Motion Detection: Frame difference analysis
- Package Detection: Package/courier identification
- Face Recognition: Basic face matching
The system includes a "Detector Studio" for training custom models:
- Upload sample images
- Few-shot learning with embeddings
- Real-time model testing
- Easy deployment to production
- Live camera tiles with real-time feeds
- System status overview
- Recent events timeline
- Quick action buttons
- Camera management and configuration
- Zone drawing for detection areas
- Stream quality settings
- Health monitoring
- Event timeline with filtering
- Event details with media playback
- Incident correlation
- Export capabilities
- Visual rule builder
- Multiple conditions and actions
- Time-based scheduling
- Custom notifications
- Model training interface
- Dataset management
- Model testing and validation
- Deployment controls
- System configuration
- User management
- Storage settings
- Network configuration
- JWT Authentication: Secure token-based auth
- Role-based Access: Admin and user roles
- Local Processing: No cloud dependencies
- Encrypted Storage: Sensitive data encryption
- Network Isolation: Runs on local network only
Optimized for Orange Pi 5 Plus:
- 4K Camera Support: Up to 4 simultaneous 4K streams
- Real-time Processing: < 500ms detection latency
- Efficient Storage: Smart recording and cleanup
- Memory Usage: ~2GB RAM for full system
- CPU Usage: Optimized for ARM64 architecture
# Install dependencies
npm install
# Start development services
npm run dev
# Run tests
npm test
# Build for production
npm run buildsecurity-system/
βββ apps/
β βββ api/ # Express.js API server
β βββ web/ # React frontend
βββ workers/
β βββ ingest/ # Camera stream processor
β βββ inference/ # AI model worker
β βββ rules-engine/ # Rule processing
β βββ actions-service/ # Action execution
βββ packages/
β βββ shared/ # Shared types and utilities
βββ migrations/ # Database schemas
βββ docker/ # Docker configurations
POST /api/auth/login
Content-Type: application/json
{
"username": "admin",
"password": "admin123"
}GET /api/cameras
POST /api/cameras
PUT /api/cameras/:id
DELETE /api/cameras/:idGET /api/events
GET /api/events/:id
POST /api/events/exportPOST /api/custom-models/train
POST /api/custom-models/test
GET /api/custom-models/deploy/:id-
Camera Connection Failed
- Check RTSP URL format
- Verify network connectivity
- Check camera credentials
-
AI Detection Not Working
- Verify ONNX models are downloaded
- Check inference worker logs
- Ensure sufficient memory
-
MQTT Connection Issues
- Verify Mosquitto is running
- Check port availability
- Review firewall settings
-
Storage Full
- Adjust recording duration
- Enable automatic cleanup
- Check disk space
# View all service logs
docker-compose logs -f
# View specific service logs
docker-compose logs -f api
docker-compose logs -f ingest- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built for Orange Pi 5 Plus
- Uses ONNX Runtime for AI inference
- Powered by React and Express.js
- MQTT messaging with Mosquitto