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 β¦