A Farm Management Information System with sovereign edge computing β built for a 3-node Raspberry Pi 5 cluster with Hailo-10H AI acceleration, real-time sensor telemetry, and on-device LLM-powered agronomy.
AgriPulse runs entirely on edge hardware: no cloud dependencies, no data leaving the farm. A FastAPI backend orchestrates sensor sampling, actuator control, and AI inference via a local Ollama model, while a lightweight HTML/CSS/JS frontend delivers a responsive dashboard accessible from any browser on the LAN.
- Highlights
- Tech Stack
- Architecture
- Quick Start
- Configuration
- Pages
- API Reference
- Project Structure
- Hardware Bill of Materials
- Documentation
- Contributing
- Security
- License
| Feature | Description | |
|---|---|---|
| Edge | Edge-native architecture | 3-node Raspberry Pi 5 cluster with a Hailo-10H NPU (26 TOPS) for on-device vision inference. |
| Realtime | Real-time telemetry | WebSocket streaming of sensor data (temperature, humidity, soil moisture, NPK, pH) at 2.5 s intervals. |
| AI | AI Agronomist | Chat with a local Llama 3.1 model via Ollama for crop planning, troubleshooting, and task tool-calling. |
| AI | AI Farm Onboarding | Describe your farm in plain language; the AI streams its reasoning, extracts a structured template (fields, crop cycles, tasks), and creates it in one transaction. |
| Domain | Full FMIS domain model | Farms, fields, crop cycles, soil & plant-health readings, irrigation, fertilization, harvests, and tasks. |
| Control | Actuator control | Pump, misters, lights, fans, and fertilizer lines, exposed via WebSocket tool calls. |
| DevOps | Deployment-ready | Docker Compose and Kubernetes (Kustomize) manifests included. |
Backend
AI / LLM
Frontend
Database
Deployment
Edge Hardware
The frontend ships as vanilla HTML/CSS/JS with no build step and no framework, and real-time communication flows over a single WebSocket (/ws) for telemetry, chat, onboarding, and tool calls.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (HTML / CSS / JS) β
β Dashboard Β· Fields Β· Soil Β· Plants Β· Tasks Β· Irrigation β
β Chat Β· BOM Β· Setup (AI Onboarding) β
βββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ
β REST + WebSocket
βββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββ
β FastAPI Backend (Python) β
β Routes Β· WebSocket Manager Β· Sensor Manager β
β SQLAlchemy ORM Β· Ollama Service Β· Onboarding Service β
β Actuator Control β
βββββββββββββββ¬ββββββββββββββββββββββββββββββββ¬ββββββββββββββββ
β β
βββββββββ΄βββββββββ βββββββββββ΄ββββββββββ
β SQLite / β β Ollama (LLM) β
β PostgreSQL β β llama3.1:8b β
ββββββββββββββββββ βββββββββββββββββββββ
β
βββββββββ΄βββββββββββββββββββββββββββββββββββββββββ
β Edge Hardware (Raspberry Pi 5 cluster) β
β Sensors Β· Actuators Β· Hailo NPU Β· Camera β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
- Python 3.12+
- Ollama running locally with a pulled model (
ollama pull llama3.1:8b) β optional; the app falls back to a deterministic parser if Ollama is unreachable. - pip, and optionally Docker / kubectl for containerized deployment.
# 1. Install dependencies
pip install -r backend/requirements.txt
# 2. (Optional) Start Ollama and pull the model
ollama serve &
ollama pull llama3.1:8b
# 3. Launch the server
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000Or use the bundled launcher, which sources .env and prints startup diagnostics:
chmod +x run.sh && ./run.shOpen http://127.0.0.1:8000 in your browser.
Spins up the AgriPulse app alongside an Ollama container:
docker-compose up --buildThe app is served on http://localhost:8000; Ollama listens on http://localhost:11434. Persistent volumes are created for both the database and Ollama models.
Note: The first run will download the Llama 3.1 model inside the Ollama container β attach to it and run
ollama pull llama3.1:8b, or pre-pull on the host.
Manifests are provided as a Kustomize bundle under k8s/:
kubectl apply -k k8s/Includes namespace, configmap, deployment, service, ingress, and storage resources.
All settings are read from environment variables (or a .env file at the project root β copy .env.example to get started).
| Variable | Default | Description |
|---|---|---|
SENSOR_MODE |
simulated |
simulated (no hardware) or real (Raspberry Pi GPIO) |
DATABASE_URL |
sqlite:///./agripulse.db |
SQLAlchemy connection string (SQLite or PostgreSQL) |
OLLAMA_BASE_URL |
http://localhost:11434 |
Ollama API endpoint |
OLLAMA_MODEL |
llama3.1:8b |
LLM model identifier for the AI Architect & onboarding |
HOST |
0.0.0.0 |
Server bind address |
PORT |
8000 |
Server port |
For PostgreSQL, set DATABASE_URL=postgresql://user:password@localhost:5432/agripulse.
| Page | Description |
|---|---|
| Dashboard | Farm selector, live stats, field status, quick actions |
| Fields | Field list & detail, crop cycles, soil & activity timeline |
| Soil | Soil readings, NPK analysis, reading history |
| Plants | Plant health, disease risk, pest pressure |
| Tasks | Task management with priority, status, and filtering |
| Irrigation | Irrigation & fertilization logging and scheduling |
| Chat | AI Architect β LLM-powered agronomy assistant |
| BOM | Bill of Materials β hardware inventory & status |
| Setup | AI Farm Onboarding β describe your farm, review & confirm |
All REST endpoints are prefixed with /api/v1.
| Resource | Endpoints |
|---|---|
| Farms | GET/POST /farms/, GET/PUT/DELETE /farms/{id} |
| Onboarding | POST /farms/onboard/confirm β create a farm from an AI template |
| Fields | GET/POST /fields/, GET/PUT/DELETE /fields/{id} |
| Crop Cycles | GET/POST /crop-cycles/, GET/PUT/DELETE /crop-cycles/{id} |
| Soil Readings | GET/POST /soil-readings/, GET /soil-readings/latest/{field_id} |
| Plant Health | GET/POST /plant-health/, GET /plant-health/latest/{field_id} |
| Irrigation | GET/POST /irrigation/, POST /irrigation/schedule |
| Fertilization | GET/POST /fertilization/ |
| Harvests | GET/POST /harvests/, PUT/DELETE /harvests/{id} |
| Tasks | GET/POST /tasks/, PUT/DELETE /tasks/{id} |
| Dashboard | GET /dashboard/summary, GET /dashboard/alerts |
| Weather | GET /dashboard/weather/{field_id} (Open-Meteo) |
Connect to ws://host:8000/ws and send JSON frames with an action field:
| Action | Payload | Description |
|---|---|---|
subscribe |
β | Stream real-time sensor data every 2.5 s |
get_nodes |
β | Request a current node-status snapshot |
chat |
{ "messages": [...] } |
Send a conversation to the AI Architect |
onboard |
{ "spec": "farm description" } |
Stream AI analysis of a farm spec β template |
exec_tool |
{ "name", "args" } |
Execute an actuator command (pump, lights, fans, β¦) |
Inbound message types: data, alert, chat_response, onboard_thought, onboard_template, onboard_error, tool_result.
AgriPulse-EdgeCluster/
βββ backend/
β βββ main.py # FastAPI app, WebSocket endpoint, actuator tools
β βββ routes.py # REST routers (farms, fields, tasks, onboarding, β¦)
β βββ models.py # SQLAlchemy ORM models & Pydantic schemas
β βββ database.py # Engine & session factory
β βββ websocket_manager.py # Connection manager & WS action dispatch
β βββ onboarding_service.py # AI farm-onboarding (Ollama streaming + fallback)
β βββ ollama_service.py # AI Architect chat service
β βββ sensors.py # Simulated & real sensor managers
β βββ requirements.txt
β βββ Dockerfile
βββ frontend/
β βββ *.html # One page per view (no framework)
β βββ static/
β βββ css/style.css
β βββ js/{api.js, app.js}
βββ k8s/ # Kubernetes manifests (Kustomize)
βββ wiki/ # Project documentation
βββ docker-compose.yml
βββ run.sh # Local launcher (sources .env)
βββ .env.example
- 3Γ Raspberry Pi 5 (16 GB)
- 1Γ AI HAT+ Hailo-10H (26 TOPS)
- 1Γ Sense HAT
- 1Γ NVMe HAT + 512 GB SSD
- 3Γ Capacitive Soil Moisture Sensors
- 1Γ Industrial pH Probe + ADS1115 ADC
- 2Γ DS18B20 Temperature Sensors
- 1Γ Global Shutter Camera
- Actuators: pump, mister, solenoid valve, LED grow lights, fans, relay module
- IP65 vented enclosure
See wiki/Hardware-BOM.md for sourcing details.
In-depth guides live in the wiki/ directory:
- Architecture β system design and data flow
- API Reference β detailed endpoint documentation
- WebSocket Protocol β real-time messaging spec
- Frontend Pages β UI tour
- Onboarding β the AI farm-onboarding workflow
- AI Architect β the LLM agronomy assistant
- Hardware BOM β component list & sourcing
- Deployment Guide β local, Docker & Kubernetes
- Kubernetes Deployment β k8s specifics
- Sensor System β real vs. simulated sensors
- Troubleshooting β common issues & fixes
Contributions are welcome. Please read CONTRIBUTING.md for guidelines and CODE_OF_CONDUCT.md for our community standards before opening a pull request.
Found a vulnerability? Please review SECURITY.md for responsible disclosure instructions β do not open a public issue for security-related problems.
Released under the MIT License.