GitHunt
TO

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.

Version License Python Node Docker

β˜€οΈ 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 ps

Access

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_password

Getting ZCS Credentials

  1. Contact ZCS Azzurro to request API access
  2. You will receive: client code and authorization token
  3. 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

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

Distributed under MIT License. See LICENSE for more information.


πŸ™ Acknowledgments


β˜€οΈ SunPulse - Monitor your solar energy

tommasinigiovanni/SunPulse | GitHunt