ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
The most comprehensive open-source edge AI platform.
Simulate β Process β Decide β Act β all locally, all free.
Zero paid APIs Β· Zero cloud lock-in Β· Zero proprietary dependencies
# Clone & run in under 2 minutes
git clone https://github.com/rudra496/EdgeBrain.git && cd EdgeBrain
docker compose up --build -d
# Open http://localhost:3000 β done.What you'll see:
- π‘οΈ Live temperature, humidity, energy, light charts
- π€ AI agents making decisions in real-time
- π¨ Alerts firing when anomalies are detected
- π‘ Lights auto-on with motion, auto-off after 5 min
- π Fan activation when temperature exceeds 30Β°C
- π Full agent message pipeline visualization
π Smart Device Simulation (11 devices)
- 3 rooms β Living Room (5 sensors), Bedroom (3 sensors), Server Room (3 sensors)
- 5 sensor types β Temperature, Motion, Energy, Humidity, Light
- Realistic patterns β circadian rhythms, Gaussian noise, mean reversion
- Rare event simulation β temperature spikes (1%), energy surges (0.5%)
- Configurable β base values, noise scale, spike probability per device
- Time-aware β energy peaks during work hours, light follows sunrise/sunset
π€ Multi-Agent AI System
- Data Agent β validates ranges, stores readings, routes to decision pipeline
- Decision Agent β runs all strategies, deduplicates, ranks by confidence
- Action Agent β creates alerts, sends MQTT commands, updates actuator state
- Message Bus β full queryable log with agent performance tracking
- Per-agent metrics β average processing time, message count, error rate
π§ AI Decision Engine (3 strategies)
- Threshold Rules β configurable per device type, with hysteresis to prevent flapping
- Anomaly Detection β 3 statistical methods vote: Z-Score, IQR, Gradient
- Requires 2+ methods to agree (reduces false positives by ~70%)
- No-Motion Timeout β turns off lights after configurable inactivity period
- Plugin Architecture β add custom strategies via
DecisionStrategyinterface- Just implement
evaluate()andnameβ that's it
- Just implement
π Predictive Analytics
- Trend Prediction β linear regression on recent readings to forecast next value
- Moving Averages β SMA and EMA for smoothing noisy sensor data
- Anomaly Score β combined confidence from all detection methods
- Forecasting β 10-step ahead prediction for temperature and energy
π Real-Time Dashboard (5 pages)
- Dashboard β stats overview, live charts, event feed, recent alerts
- Devices β all sensor states with room grouping, online/offline status
- Analytics β historical charts, trend predictions, device comparisons
- Agents β pipeline visualization, message log, strategy config, performance
- Settings β system configuration, thresholds, export data, system info
π Communication & Integration
- MQTT 5.0 β topic-based architecture with QoS support
- WebSocket β real-time bidirectional dashboard updates
- REST API β 20+ endpoints with auto-generated OpenAPI docs
- Data Export β CSV and JSON export for any device's readings
- Webhook Support β configurable webhook for alert notifications
ποΈ Production Infrastructure
- Docker Compose β 6 services, health checks, restart policies, volumes
- PostgreSQL β composite indexes, JSONB fields, time-series optimized
- Redis β event queuing, pub/sub, alert cache, live telemetry
- GitHub Actions β CI (tests + lint) + Release (Docker + Git tag)
- Makefile β one-command operations:
make dev,make test,make release
π§ Optional Hardware
- ESP32 firmware β Arduino C++ with WiFi + MQTT
- DHT11 β temperature & humidity sensor
- PIR β passive infrared motion sensor
- LED + Buzzer β actuator control
- Configurable β just edit WiFi + MQTT credentials
- Docker v20+ & Docker Compose v2+
- 4GB RAM (8GB recommended)
- ~2GB disk space
git clone https://github.com/rudra496/EdgeBrain.git
cd EdgeBrain
docker compose up --build -dmake setup # Clone (if not already), build, and start
make dev # Start in development mode
make test # Run test suite
make logs # Tail all service logs
make stop # Stop all services
make clean # Stop + remove volumes| Service | URL | Description |
|---|---|---|
| π₯οΈ Dashboard | http://localhost:3000 | React real-time dashboard |
| π‘ Swagger API | http://localhost:8000/docs | Interactive API explorer |
| π ReDoc | http://localhost:8000/redoc | Alternative API docs |
| β€οΈ Health | http://localhost:8000/api/v1/health | System health check |
| π MQTT | localhost:1883 |
Mosquitto broker |
| π‘ MQTT/WS | localhost:9001 |
MQTT over WebSocket |
# Health check
curl -s http://localhost:8000/api/v1/health | python3 -m json.tool
# System statistics
curl -s http://localhost:8000/api/v1/stats | python3 -m json.tool
# Device list
curl -s http://localhost:8000/api/v1/devices | python3 -m json.tool
# Recent alerts
curl -s http://localhost:8000/api/v1/alerts | python3 -m json.tool
# Agent performance
curl -s http://localhost:8000/api/v1/agents/stats | python3 -m json.toolgraph TB
subgraph Edge["π Edge Layer"]
S1["π‘οΈ Temp β Room 1"]
S2["π Motion β Room 1"]
S3["β‘ Energy β Room 1"]
S4["π§ Humidity β Room 1"]
S5["βοΈ Light β Room 1"]
S6["π‘οΈ Temp β Room 2"]
S7["π Motion β Room 2"]
S8["β‘ Energy β Room 2"]
S9["π‘οΈ Temp β Server Room"]
S10["π§ Humidity β Server Room"]
S11["β‘ Energy β Server Room"]
ESP["π‘ ESP32 β Optional"]
end
subgraph Comms["π‘ Communication Layer"]
MQTT["Mosquitto MQTT 5.0"]
end
subgraph BE["π§ Backend (FastAPI)"]
API["REST + WebSocket API"]
PIPE["Data Pipeline"]
EVT["Event Engine"]
EXEC["Execution Engine"]
PRED["Prediction Engine"]
end
subgraph AI["π€ AI / Decision Engine"]
DA["Data Agent"]
DEC["Decision Agent"]
AA["Action Agent"]
RULE["Rule Engine<br/>+ Hysteresis"]
ANOM["Anomaly Detector<br/>Z-Score Β· IQR Β· Gradient"]
PREDAI["Predictor<br/>Linear Regression"]
PLUG["Plugin System"]
end
subgraph Data["πΎ Data Layer"]
PG[("PostgreSQL 16")]
REDIS[("Redis 7")]
end
subgraph FE["π₯οΈ Frontend"]
DASH["React Dashboard<br/>5 Pages Β· WebSocket"]
end
S1 & S2 & S3 & S4 & S5 & S6 & S7 & S8 & S9 & S10 & S11 & ESP -->|"device/+/data"| MQTT
MQTT -->|"subscribe"| PIPE
PIPE -->|"store"| PG
PIPE -->|"route"| DA
DA -->|"validate"| DEC
RULE & ANOM & PREDAI --> DEC
PLUG --> DEC
DEC -->|"decisions"| AA
AA -->|"alerts"| EVT
AA -->|"commands"| EXEC
EVT --> REDIS
REDIS -->|"broadcast"| DASH
EXEC -->|"device/+/command"| MQTT
MQTT -->|"actuate"| S1 & S2 & S3
API <-->|"HTTP/WS"| DASH
API --> PG
API --> REDIS
sequenceDiagram
participant S as Sensor
participant M as MQTT
participant DA as Data Agent
participant DB as PostgreSQL
participant DEC as Decision Agent
participant AA as Action Agent
participant A as Alert/Redis
participant CMD as MQTT Command
participant ACT as Actuator
S->>M: device/room-1/data {temp: 35Β°C}
M->>DA: route message
DA->>DA: validate range
DA->>DB: store reading
DA->>DEC: evaluate(device, type, value)
DEC->>DEC: ThresholdStrategy β fan ON
DEC->>DEC: AnomalyDetector β normal
DEC->>DEC: deduplicate + rank
DEC->>AA: [Decision: activate fan]
AA->>A: push alert to Redis
AA->>CMD: device/room-1-actuator-fan/command
CMD->>ACT: activate fan
A-->>Dashboard: WebSocket broadcast
EdgeBrain/
βββ .github/
β βββ ISSUE_TEMPLATE/
β β βββ bug_report.yml # Structured bug reports
β β βββ feature_request.yml # Structured feature requests
β βββ PULL_REQUEST_TEMPLATE.md # PR checklist
β
βββ backend/
β βββ app/
β β βββ api/
β β β βββ routes.py # 20+ REST endpoints + WebSocket
β β β βββ schemas.py # Pydantic request/response models
β β βββ core/
β β β βββ config.py # Settings with env vars
β β β βββ database.py # SQLAlchemy engine + sessions
β β β βββ mqtt_client.py # Thread-safe MQTT with reconnect
β β β βββ events.py # Redis queue + pub/sub
β β βββ ai/
β β β βββ rules.py # Rule engine + hysteresis + plugin
β β β βββ anomaly.py # Z-Score + IQR + Gradient detection
β β β βββ prediction.py # Linear regression + forecasting
β β βββ agents/
β β β βββ multi_agent.py # Data β Decision β Action pipeline
β β βββ models/
β β β βββ models.py # 5 SQLAlchemy models + indexes
β β βββ services/
β β β βββ ingestion.py # Data validation + storage
β β β βββ execution.py # Commands + alerts + actuator state
β β βββ main.py # FastAPI app + lifespan
β βββ tests/
β β βββ test_ai.py # 20+ AI engine tests
β β βββ test_api.py # API endpoint tests
β βββ requirements.txt
β βββ Dockerfile
β
βββ frontend/
β βββ src/
β β βββ App.js # Main app + 5-page router
β β βββ App.css # Complete dark theme design system
β β βββ index.js # React entry point
β βββ public/index.html
β βββ package.json
β βββ Dockerfile
β
βββ device-simulator/
β βββ simulator.py # 11 devices, 3 rooms, realistic data
β
βββ esp32-firmware/
β βββ main/main.ino # ESP32 Arduino firmware
β βββ README.md # Hardware setup guide
β
βββ docker/
β βββ init.sql # Database schema + indexes
β βββ mosquitto.conf # MQTT broker config
β
βββ docs/
β βββ ARCHITECTURE.md # Detailed system design
β βββ SETUP.md # Setup with/without Docker
β βββ ROADMAP.md # Development roadmap
β
βββ Makefile # Convenience commands
βββ docker-compose.yml # 6-service orchestration
βββ LICENSE # MIT
βββ CODE_OF_CONDUCT.md # CoC
βββ CONTRIBUTING.md # Contribution guide
βββ README.md # This file
from app.ai.rules import DecisionStrategy, Decision
class MyCustomStrategy(DecisionStrategy):
"""Example: Alert when humidity exceeds threshold."""
@property
def name(self) -> str:
return "humidity_alert"
def evaluate(self, device_id, device_type, value, history):
if device_type != "humidity":
return []
if value > 80:
return [Decision(
action="activate",
device_id=device_id,
params={"actuator": "alarm"},
reason=f"High humidity: {value:.1f}%",
confidence=0.85,
severity="warning",
source=self.name,
)]
return []
# Register:
from app.agents.multi_agent import agents
agents.engine.add_strategy(MyCustomStrategy())| Layer | Technology | Version | Purpose |
|---|---|---|---|
| Backend | Python | 3.11+ | Runtime |
| Framework | FastAPI | 0.110 | Async REST + WebSocket |
| Database | PostgreSQL | 16 | Time-series storage |
| Cache | Redis | 7.2 | Queue, pub/sub, cache |
| Messaging | Mosquitto | 2.0 | MQTT broker |
| AI/Math | NumPy + SciPy | 1.26 / 1.12 | Anomaly detection, prediction |
| Frontend | React | 18.3 | Dashboard UI |
| Charts | Recharts | 2.12 | Real-time visualizations |
| Icons | Lucide | 0.344 | Icon library |
| Infra | Docker Compose | 2.x | Local orchestration |
| Hardware | ESP32 | Arduino | Optional real sensors |
| Document | Description |
|---|---|
| Architecture | System design, data flow, plugin system |
| Setup Guide | Docker + native setup instructions |
| Roadmap | Future plans and milestones |
| Contributing | How to contribute code |
| API Reference | Interactive Swagger (when running) |
Releases are versioned using Semantic Versioning:
- v1.x.x β Current stable. Core features complete.
- v2.x.x β Planned: distributed edge, TimescaleDB, Grafana.
- v3.x.x β Planned: plugin marketplace, multi-tenant.
See Releases for changelog.
We β€οΈ contributions! See CONTRIBUTING.md.
# Fork, branch, code, PR
git clone https://github.com/rudra496/EdgeBrain.git
cd EdgeBrain
make dev # Start development environment
make test # Run tests
# Make changes, then open PRThanks to all contributors! Your PRs make EdgeBrain better.
MIT β free for personal and commercial use.
EdgeBrain β Intelligence at the edge, not the cloud.
Built with π§ by Rudra