Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

134 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

UBC OCPI Adaptor

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.

What is this?

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

Who is it for?

  • 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

Quick Start

Prerequisites

  • Docker >= 24.0.0
  • Docker Compose v2.0.0+
  • 8GB RAM recommended

5-Minute Setup

# 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/health

That's it! Your OCPI adaptor is now running.

πŸ‘‰ For detailed setup instructions, see QUICK_START.md or docs/SETUP.md

Service URLs

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)

Smoke Tests

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

Documentation

Features

OCPI 2.2.1 EMSP Implementation

  • βœ… 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

UBC/Beckn Integration

  • βœ… Select - Location discovery
  • βœ… Init - Session initialization
  • βœ… Confirm - Session confirmation
  • βœ… Track - Real-time session tracking
  • βœ… Update - Session updates

Additional Features

  • βœ… 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

Project Structure

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

Development

Running in Development Mode

# Start dependencies
docker compose up -d postgres

# Install dependencies
npm install

# Run in development mode (with hot reload)
npm run dev

Available Scripts

npm 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 Studio

Configuration

Key environment variables (see .env.example for full list):

  • DATABASE_URL - PostgreSQL connection string
  • JWT_SECRET - JWT secret key (generate with openssl rand -base64 32)
  • OCPI_HOST - OCPI host URL
  • CDS_BASE_URL - Catalog Discover Service API URL (optional)
  • EV_CHARGING_UBC_BPP_CLIENT_HOST - BPP client host for Beckn callbacks

API Endpoints

OCPI Endpoints (EMSP Receiver)

  • GET /ocpi/versions - OCPI versions
  • GET /ocpi/2.2.1 - Version details
  • POST /ocpi/2.2.1/credentials - Credential exchange
  • PUT /ocpi/2.2.1/locations/{country_code}/{party_id}/{location_id} - Location updates
  • PUT /ocpi/2.2.1/sessions/{country_code}/{party_id}/{session_id} - Session updates
  • POST /ocpi/2.2.1/cdrs/{country_code}/{party_id} - CDR submission
  • And more... (see OCPI_FLOWS.md)

Admin Endpoints

  • POST /api/admin/auth/login - Admin login
  • GET /api/admin/locations - List locations
  • POST /api/admin/locations/fetch - Fetch locations from CPO
  • POST /api/admin/commands/start - Start charging session
  • POST /api/admin/commands/stop - Stop charging session
  • And more...

Health Check

  • GET /api/health - Health check endpoint

Docker Deployment

Development

docker compose up -d

Production

# Set NODE_ENV=production in .env
docker compose build
docker compose up -d

Troubleshooting

Having issues? Check out:

  1. TROUBLESHOOTING.md - Common issues and solutions
  2. Application logs: docker compose logs -f app
  3. Database logs: docker compose logs -f postgres

Support


Ready to get started? β†’ docs/SETUP.md

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages