TO
tommasinigiovanni/SunPulse
SunPulse is a comprehensive platform for monitoring photovoltaic systems that uses ZCS Azzurro Portal APIs. The system offers real-time data visualisation, historical analysis, intelligent alerts and automation.
βοΈ SunPulse
Solar photovoltaic monitoring platform with ZCS Azzurro Portal integration
SunPulse is a comprehensive dashboard for real-time monitoring of solar PV systems. It integrates with ZCS Azzurro APIs to collect production, consumption, battery and alarm data.
β¨ Features
- π Real-time Dashboard - Live data visualization
- π Historical Analysis - Production/consumption charts with aggregations
- π Alarm Management - Device alarm monitoring and notifications
- π Battery Status - SOC and battery cycle monitoring
- β‘ Smart Caching - Multi-layer caching (Memory + Redis)
- π‘οΈ Resilience - Circuit breaker for fault tolerance
- π Authentication - Auth0 integration
- π³ Docker Ready - Deploy with a single command
- π’ Multi-Building - Manage multiple buildings with shared access
- π‘οΈ Weather Integration - Real-time temperature and weather data per building
- π Google Places - Address autocomplete and geolocation
π’ Data Model
SunPulse uses a Building-centric architecture where the building is the central entity:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β USERS β
β (Auth0 authenticated users) β
βββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ
β N:M (shared access)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BUILDINGS β
β β’ Name & Address (Google Places Autocomplete) β
β β’ GPS Coordinates β
β β’ Real-time Weather Data β
βββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ
β 1:N
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DEVICES β
β (Inverters, Batteries, Smart Meters) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Key Features:
- Multiple users can access the same building
- Each building has its own weather service
- Devices are always associated with a building
ποΈ Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β NGINX (80/443) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββ ββββββββββββ ββββββββββββ
β Frontend β β Backend β β N8N β
β (React) β β(FastAPI) β β(Workflow)β
β :3000 β β :8000 β β :5678 β
ββββββββββββ ββββββββββββ ββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββ
βΌ βΌ βΌ
ββββββββββββ ββββββββββββ ββββββββββββ
βPostgreSQLβ β InfluxDB β β Redis β
β :5432 β β :8086 β β :6379 β
ββββββββββββ ββββββββββββ ββββββββββββ
β
βββββββββββ΄ββββββββββ
βΌ βΌ
ββββββββββββ ββββββββββββ
β Celery β β Celery β
β Worker β β Beat β
ββββββββββββ ββββββββββββ
β
βββββββββ΄ββββββββ
βΌ βΌ
ββββββββββββββ ββββββββββββββ
βZCS Azzurro β β Weather β
β API β β API β
ββββββββββββββ ββββββββββββββ
π Quick Start
Prerequisites
- Docker & Docker Compose
- 8GB available RAM
- ZCS Azzurro API credentials
Installation
# 1. Clone the repository
git clone https://github.com/tommasinigiovanni/SunPulse.git
cd sunpulse
# 2. Copy and configure environment variables
cp .env.example .env
# Edit .env with your credentials
# 3. Start all services
docker-compose up -d
# 4. Check status
docker-compose psAccess
| Service | URL | Description |
|---|---|---|
| Frontend | http://localhost:3000 | Main dashboard |
| Backend API | http://localhost:8000 | REST API |
| API Docs | http://localhost:8000/docs | Swagger UI |
| N8N | http://localhost:5678 | Automations |
βοΈ Configuration
Environment Variables
# ZCS API (required)
ZCS_API_URL=https://third.zcsazzurroportal.com:19003/
ZCS_API_AUTH=Zcs YOUR_TOKEN
ZCS_CLIENT_CODE=YOUR_CLIENT_CODE
ZCS_DEVICE_KEYS=YOUR_DEVICE_KEY
# Auth0
AUTH0_DOMAIN=your-domain.eu.auth0.com
AUTH0_CLIENT_ID=your_client_id
AUTH0_CLIENT_SECRET=your_client_secret
# Google APIs (for Building features)
GOOGLE_MAPS_API_KEY=your_google_maps_api_key
# Weather API
WEATHER_API_PROVIDER=openweathermap
OPENWEATHERMAP_API_KEY=your_openweathermap_api_key
# Database
POSTGRES_PASSWORD=your_secure_password
REDIS_PASSWORD=your_secure_password
INFLUXDB_ADMIN_PASSWORD=your_secure_passwordGetting ZCS Credentials
- Contact ZCS Azzurro to request API access
- You will receive:
client codeandauthorization token - Identify your devices'
thingKey
π Project Structure
sunpulse/
βββ docker-compose.yml # Service orchestration
βββ .env.example # Environment template
βββ README.md # Documentation
βββ TODO.md # Tasks and roadmap
βββ LICENSE # MIT License
βββ doc/ # Technical documentation
β βββ context.md # Project knowledge base
β βββ *.pdf # ZCS specifications
βββ modules/
β βββ backend/ # FastAPI application
β β βββ app/
β β β βββ api/ # REST endpoints
β β β βββ config/ # Configuration
β β β βββ models/ # Data models
β β β βββ services/ # Business logic
β β β βββ utils/ # Utilities
β β βββ Dockerfile
β β βββ requirements.txt
β βββ frontend/ # React/Refine application
β β βββ src/
β β β βββ components/ # UI components
β β β βββ hooks/ # React hooks
β β β βββ pages/ # Page components
β β β βββ utils/ # Utilities
β β βββ Dockerfile
β β βββ package.json
β βββ auth/ # Auth service
β βββ postgres/ # Database init
β βββ influxdb/ # Time-series DB
β βββ redis/ # Cache
β βββ n8n/ # Automations
β βββ nginx/ # Reverse proxy
βββ scripts/ # Utility scripts
π API Endpoints
Health
GET /api/v1/health/ # Health check
GET /api/v1/health/detailed # Detailed status
Devices
GET /api/v1/devices/ # List devices
GET /api/v1/devices/{id} # Device details
GET /api/v1/devices/{id}/realtime # Real-time data
GET /api/v1/devices/{id}/historic # Historical data
Data
GET /api/v1/data/realtime # Aggregated real-time data
GET /api/v1/data/historical # System historical data
GET /api/v1/data/summary # Daily summary
Alarms
GET /api/v1/alarms/ # List alarms
GET /api/v1/alarms/summary # Active alarms summary
Buildings
GET /api/v1/buildings/ # List user's buildings
POST /api/v1/buildings/ # Create building
GET /api/v1/buildings/{id} # Building details
PUT /api/v1/buildings/{id} # Update building
DELETE /api/v1/buildings/{id} # Delete building
GET /api/v1/buildings/{id}/devices # Building devices
GET /api/v1/buildings/{id}/weather # Building weather data
GET /api/v1/buildings/{id}/members # Building members
Address
GET /api/v1/address/autocomplete # Google Places autocomplete
GET /api/v1/address/details/{place_id} # Address details + coordinates
π οΈ Tech Stack
Backend
- FastAPI - Async web framework
- PostgreSQL - Relational database
- InfluxDB - Time-series database
- Redis - Cache and message broker
- Celery - Task queue and scheduling
Frontend
- React 18 - UI library
- Refine - Admin framework
- Ant Design - Component library
- Auth0 - Authentication
Infrastructure
- Docker - Containerization
- Nginx - Reverse proxy
- N8N - Workflow automation
π Task Scheduling
| Task | Frequency | Description |
|---|---|---|
collect_realtime_data |
2 min | Production data collection |
collect_alarm_data |
30 sec | Alarm status check |
health_check_task |
5 min | System health check |
collect_weather_data |
15 min | Weather data for each building |
π§ͺ Development
# Start in development mode
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d
# Real-time logs
docker-compose logs -f backend
# Rebuild after changes
docker-compose build backend
docker-compose up -d backend
# Tests
cd modules/backend && pytest
cd modules/frontend && npm testπ Documentation
- Context File - Complete project knowledge base
- TODO - Tasks, bugs and roadmap
- ZCS API - ZCS Azzurro API specifications
π€ Contributing
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
π License
Distributed under MIT License. See LICENSE for more information.
π Acknowledgments
- ZCS Azzurro - API and documentation
- Refine - Admin framework
- FastAPI - Backend framework
βοΈ SunPulse - Monitor your solar energy