An EMSP (eMobility Service Provider) OCPI server that integrates with CPO (Charge Point Operator) systems via OCPI 2.2.1 protocol and provides UBC (Unified Bharat e-Charge) Beckn protocol integration for EV charging discovery and transactions.
This repository implements a complete OCPI 2.2.1 EMSP server that:
- Receives and manages charging locations, tariffs, sessions, and CDRs from CPOs
- Provides OCPI-compliant APIs for CPO integration
- Integrates with UBC/Beckn protocol for EV charging discovery
- Offers administrative APIs for managing OCPI connections and data synchronization
- CPOs (Charge Point Operators): Integrate with EMSPs using OCPI 2.2.1
- EMSPs (eMobility Service Providers): Manage charging infrastructure and sessions
- Developers: Build EV charging applications with OCPI and Beckn protocols
- System Integrators: Deploy and customize OCPI adapters
- Docker >= 24.0.0
- Docker Compose v2.0.0+
- 8GB RAM recommended
# 1. Clone the repository
git clone <repository-url>
cd ubc-ocpi-adaptor
# 2. Configure environment
cp .env.example .env
# Edit .env with your configuration
# 3. Start services
docker compose up -d
# 4. Initialize database
docker compose exec app npm run prisma:migrate
# 5. Verify installation
curl http://localhost:6001/api/healthThat's it! Your OCPI adaptor is now running.
π For detailed setup instructions, see QUICK_START.md or docs/SETUP.md
After starting, services are available at:
| Service | URL | Description |
|---|---|---|
| API | http://localhost:6001 | Main application API |
| Health Check | http://localhost:6001/api/health | Health check endpoint |
| OCPI Versions | http://localhost:6001/ocpi/versions | OCPI versions endpoint |
| PostgreSQL | localhost:5432 | Database (if port exposed) |
Run these commands to verify everything is working:
# 1. Health check
curl http://localhost:6001/api/health
# 2. Root endpoint
curl http://localhost:6001/
# 3. OCPI versions
curl http://localhost:6001/ocpi/versions- QUICK_START.md - Quick setup guide (start here)
- docs/SETUP.md - Detailed setup guide with troubleshooting
- docs/OCPI_FLOWS.md - OCPI protocol flows and examples
- docs/ARCHITECTURE.md - System architecture and design
- docs/TROUBLESHOOTING.md - Common issues and solutions
- β Versions - Version discovery and endpoint listing
- β Credentials - Partner registration and token exchange
- β Locations - Charging location management (with EVSEs and connectors)
- β Tariffs - Pricing and tariff management
- β Sessions - Charging session lifecycle management
- β CDRs - Charge Detail Records for billing
- β Tokens - Token authorization and whitelist management
- β Commands - Start/Stop session commands
- β Select - Location discovery
- β Init - Session initialization
- β Confirm - Session confirmation
- β Track - Real-time session tracking
- β Update - Session updates
- β Admin API - RESTful APIs for managing OCPI connections
- β Request Logging - Comprehensive OCPI request/response logging
- β Multi-cloud Logging - Support for GCP, AWS CloudWatch, Azure Monitor
- β PostgreSQL Database - Robust data persistence with Prisma ORM
ubc-ocpi-adaptor/
βββ docs/ # Documentation
β βββ SETUP.md # Setup guide
βββ scripts/ # Utility scripts
β βββ init-db.sh # Database initialization
β βββ healthcheck.sh # Health check script
βββ src/ # Source code
β βββ ocpi/ # OCPI implementation
β βββ ubc/ # UBC/Beckn integration
β βββ admin/ # Admin APIs
β βββ services/ # Business logic
β βββ db-services/ # Database services
βββ prisma/ # Database schema
βββ docker-compose.yml # Docker Compose configuration
βββ Dockerfile # Docker image definition
# Start dependencies
docker compose up -d postgres
# Install dependencies
npm install
# Run in development mode (with hot reload)
npm run devnpm run build # Build TypeScript
npm start # Start production server
npm run dev # Start development server (hot reload)
npm test # Run tests
npm run lint # Lint code
npm run prisma:studio # Open Prisma StudioKey environment variables (see .env.example for full list):
DATABASE_URL- PostgreSQL connection stringJWT_SECRET- JWT secret key (generate withopenssl rand -base64 32)OCPI_HOST- OCPI host URLCDS_BASE_URL- Catalog Discover Service API URL (optional)EV_CHARGING_UBC_BPP_CLIENT_HOST- BPP client host for Beckn callbacks
GET /ocpi/versions- OCPI versionsGET /ocpi/2.2.1- Version detailsPOST /ocpi/2.2.1/credentials- Credential exchangePUT /ocpi/2.2.1/locations/{country_code}/{party_id}/{location_id}- Location updatesPUT /ocpi/2.2.1/sessions/{country_code}/{party_id}/{session_id}- Session updatesPOST /ocpi/2.2.1/cdrs/{country_code}/{party_id}- CDR submission- And more... (see OCPI_FLOWS.md)
POST /api/admin/auth/login- Admin loginGET /api/admin/locations- List locationsPOST /api/admin/locations/fetch- Fetch locations from CPOPOST /api/admin/commands/start- Start charging sessionPOST /api/admin/commands/stop- Stop charging session- And more...
GET /api/health- Health check endpoint
docker compose up -d# Set NODE_ENV=production in .env
docker compose build
docker compose up -dHaving issues? Check out:
- TROUBLESHOOTING.md - Common issues and solutions
- Application logs:
docker compose logs -f app - Database logs:
docker compose logs -f postgres
- π Read the documentation
- π Check GitHub issues
- π¬ Contact the development team on [email protected]
Ready to get started? β docs/SETUP.md