K-NET: Distributed Energy Resource Management System (DERMS) with Green Fintech for the Moroccan market. Solar PV monitoring, battery storage, EV charging, billing, and carbon tracking. Microservices architecture with Python/FastAPI, TimescaleDB, and Modbus integration.
# K-NET Platform
A distributed Energy Resource Management System (DERMS) combined with Green Fintech for the Moroccan market.
## 🏗️ Architecture
K-NET is built as **microservices from day one**:
- **User Service** - Authentication, authorization, user management
- **Energy Service** - Site/device management, Modbus integration, measurements
- **Fintech Service** - Contracts, billing engine, invoice generation
- **API Gateway** - Kong/Envoy for routing and rate limiting
Services communicate via:
- **gRPC** (synchronous service-to-service calls)
- **Kafka** (asynchronous events and data streaming)
## 📁 Project Structure
```
knet/
├── services/ # Microservices
│ ├── user-service/ # Authentication & users
│ ├── energy-service/ # Sites, devices, measurements
│ ├── fintech-service/ # Contracts, billing, invoices
│ └── api-gateway/ # Gateway configuration
├── shared/ # Shared code
│ ├── proto/ # gRPC definitions
│ └── python/knet_common/ # Common utilities
├── infrastructure/ # Infrastructure as code
│ ├── docker/ # Docker Compose
│ ├── kubernetes/ # K8s manifests
│ └── terraform/ # AWS infrastructure
├── docs/ # Technical documentation
├── scripts/ # Utility scripts
└── docker-compose.yml # Local development
```
## 🚀 Quick Start
### Prerequisites
- Python 3.11+
- Node.js 18+
- Docker & Docker Compose
- PostgreSQL 15+ (local or via Docker)
### Local Development
```bash
# Clone and navigate
cd knet
# Start infrastructure (PostgreSQL, Redis, Kafka)
docker-compose up postgres redis zookeeper kafka -d
# Start User Service (first terminal)
cd services/user-service
pip install -e ".[dev]"
cp .env.example .env
alembic upgrade head
uvicorn app.main:app --reload
# Or use Docker Compose for everything
docker-compose up
```
### Access Points
- **User Servi …