EdgeBrain
agent
Warn
Health Warn
- License รขโฌโ License: MIT
- Description รขโฌโ Repository has a description
- Active repo รขโฌโ Last push 0 days ago
- Low visibility รขโฌโ Only 6 GitHub stars
Code Pass
- Code scan รขโฌโ Scanned 12 files during light audit, no dangerous patterns found
Permissions Pass
- Permissions รขโฌโ No dangerous permissions requested
No AI report is available for this listing yet.
๐ง EdgeBrain โ Lightweight edge AI inference engine. Run ML models locally with sub-100ms latency. No cloud. No API keys. Just fast, private AI.
README.md
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ง EdgeBrain โ AI-Powered Edge Intelligence Platform
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Autonomous real-world decision systems. Runs locally. No paid APIs required.
https://github.com/rudra496/EdgeBrain
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
A comprehensive open-source edge AI platform.
Simulate โ Process โ Decide โ Act โ all locally, all free.
Zero paid APIs ยท Zero cloud lock-in ยท Zero proprietary dependencies
๐ฌ Demo
# 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
โจ Features
๐ 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
- 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
- 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
- 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
- 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
- MQTT 3.1.1 โ 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
- 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
- ESP32 firmware โ Arduino C++ with WiFi + MQTT
- DHT11 โ temperature sensor (code simulated by default, real sensor supported)
- PIR โ passive infrared motion sensor
- LED โ actuator indicator
- Configurable โ just edit WiFi + MQTT credentials
โก Quick Start
Prerequisites
- Docker v20+ & Docker Compose v2+
- 4GB RAM (8GB recommended)
- ~2GB disk space
Install & Run
git clone https://github.com/rudra496/EdgeBrain.git
cd EdgeBrain
docker compose up --build -d
Or use Make
make 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
Access Points
| 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 |
Verify Everything
# 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.tool
๐๏ธ Architecture
graph 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 3.1.1"]
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
Decision Pipeline
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
๐ Project Structure
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
โ
โโโ simulator/
โ โโโ Dockerfile # Simulator container
โ
โโโ 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
๐ Custom Strategies
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())
๐ ๏ธ Tech Stack
| 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 |
๐ Documentation
| 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) |
๐ Release Strategy
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.
๐ค Contributing
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 PR
Contributors
Thanks to all contributors! Your PRs make EdgeBrain better.
๐ License
MIT โ free for personal and commercial use.
โญ Star History
EdgeBrain โ Intelligence at the edge, not the cloud.
Built with ๐ง by Rudra
More Open Source Projects
| Project | Stars | Description |
|---|---|---|
| StealthHumanizer | Free AI text humanizer โ 13 providers, no login | |
| DevRoadmaps | 17 career paths, 1700+ free resources | |
| CodeVista | AI code analysis & security scanner | |
| Nexus Agent | Self-evolving local AI agent framework | |
| MindWell | Free mental health support platform | |
| ScienceLab 3D | 40+ virtual STEM experiments | |
| SightlineAI | AI smart glasses for the blind |
Reviews (0)
Sign in to leave a review.
Leave a reviewNo results found