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 devs@pulseenergy.io
Ready to get started? → docs/SETUP.md