metadata
title: SolarWine API
emoji: πΏ
colorFrom: green
colorTo: yellow
sdk: docker
app_port: 7860
private: true
SolarWine API
FastAPI backend for the SolarWine agrivoltaic vineyard control system.
Endpoints
Health & Monitoring
GET|HEAD /api/healthβ system health (uptime, Redis, TB, IMS, Gemini status)GET /api/health/dataβ data freshness per source (age, ok/degraded)GET /api/health/data-sourcesβ per-source green/yellow/red status with thresholds
Weather (IMS Station 43)
GET /api/weather/currentβ latest weather readings + data ageGET /api/weather/history?start_date&end_date&formatβ historical weather (hourly)GET /api/weather/forecastβ weather forecast
Vine Sensors (ThingsBoard)
GET /api/sensors/snapshotβ latest readings (treatment vs reference)GET /api/sensors/history?type&area&hoursβ sensor time-seriesGET /api/sensors/soil-moisture?hoursβ soil moisture historyGET /api/sensors/rain?hoursβ rainfall history
Energy
GET /api/energy/currentβ current power output (kW)GET /api/energy/daily/{date}β daily production + hourly profileGET /api/energy/historyβ energy generation time-seriesGET /api/energy/predict/{date}β predicted daily generation
Photosynthesis
GET /api/photosynthesis/current?modelβ current A rate (FvCB or ML)GET /api/photosynthesis/forecastβ 24h predicted A profile
Control System
GET /api/control/statusβ last control loop tickGET /api/control/planβ current day-ahead planGET /api/control/budgetβ energy budget statusGET /api/control/trackersβ tracker angles and modes
Chatbot (Gemini AI)
POST /api/chatbot/messageβ send message to vineyard advisorPOST /api/chatbot/feedbackβ submit feedback on responseGET /api/chatbot/briefingβ current system status briefing
Biology
GET /api/biology/phenologyβ current growth stageGET /api/biology/rulesβ all biology rulesGET /api/biology/rules/{name}β single rule detailGET /api/biology/chill-units?season_startβ accumulated chill units
Auth
POST /api/auth/loginβ JWT token (guest mode when JWT_SECRET unset)
Events
GET /api/events/streamβ SSE stream for live frontend updates
Interactive docs at /docs.
Environment Variables
| Variable | Required | Description |
|---|---|---|
IMS_API_TOKEN |
Yes | IMS weather API token |
THINGSBOARD_HOST |
Yes | ThingsBoard server URL |
THINGSBOARD_USERNAME |
Yes | ThingsBoard login |
THINGSBOARD_PASSWORD |
Yes | ThingsBoard password |
GOOGLE_API_KEY |
No | Gemini AI for chatbot/advisor |
JWT_SECRET |
No | JWT signing key (guest mode if unset) |
ADMIN_PASSWORD |
No | Login password |
REDIS_URL |
No | Upstash Redis for shared cache |
SENTRY_DSN |
No | Sentry error tracking |
SMTP_HOST |
No | Email alerts (with ALERT_EMAIL_TO) |
ALERT_EMAIL_TO |
No | Alert recipient email(s) |