# sap-labs-france/ev-server architecture

> Architecture diagram of the GitHub repository sap-labs-france/ev-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sap-labs-france/ev-server
- Repository: https://github.com/sap-labs-france/ev-server

## Overview

##### Project Type & Purpose
- This is a full-stack system:
- A NodeJS “Central Service” server (CSS) implementing OCPP (SOAP & JSON/WS) for Charging Stations.
- A NodeJS REST server (CSRS) exposing APIs to an Angular Dashboard front-end (separate repo).
- A MongoDB database.
- Background schedulers & asynchronous workers for tasks (OCPI pulls/pushes, billing, migrations, notifications).
- Integrations with external services: Stripe, SAP-Concur, OCPI, OICP, Car connectors, Smart Charging, Analytics.

##### Lay Out the Top-Level Containers
A. Charging Stations (external actors)
B. CSS – Central Service Server (NodeJS)
– Modules:
- OCPPServer (SOAP & JSON WebSocket)
- OCPPService, OCPPUtils, Validators (src/server/ocpp)
- OCPI Server (src/server/ocpi)
- OICP Server (src/server/oicp)
- OData Server (src/server/odata)
C. CSRS – REST API Server (NodeJS + Express)
– Modules:
- REST routers & services under src/server/rest/v1
- Authentication & ABAC (src/authorization)
- Validation (src/validator & storage/validator)
D. MongoDB (dockerized, replica set)
E. Scheduler & Async Task Worker (NodeJS processes)
– src/scheduler and src/async-task
F. External Services (3rd-party systems):
- Angular Dashboard (client)
- Stripe Billing
- SAP Concur refund
- OCPI/CPO / OICP networks
- Car Connector APIs
- SAP Analytics
- Email SMTP
G. Monitoring (Prometheus)

##### Architectural Patterns
- Layered architecture:
- Presentation Layer: REST API, OCPP endpoints
- Business Layer: Services (src/server/*/service), Authorization (ABAC)
- Integration Layer: src/integration/*, src/client/* for external protocols
- Persistence Layer: src/storage/mongodb + Validators
- Infrastructure/Support: Scheduler, AsyncTask, Migration, Monitoring, Caching, Locking
- Modularization by domain (asset, car, billing, pricing, smart-charging, notification)
- Use of ABAC for authorization (src/authorization)
- Asynchronous task execution and scheduling (src/async-task, src/scheduler)

##### Technologies & Frameworks
- Inside each container/component, list key frameworks and libraries:
- NodeJS + TypeScript
- Express, WebSocket, SOAP (wsdl)
- MongoDB (docker-compose, initdb scripts)
- Jest (unit tests, test/ folder)
- Dockerfiles, Docker Compose, AWS deployment scripts (src/aws)
- Prometheus monitoring (src/monitoring/prometheus)
- ABAC engine (src/authorization)
- OData (src/server/odata)

##### Drill-down Components
- OCPPServer, OCPI Server, OICP Server, OData Server as separate modules.
- How each module uses common utilities, validation, storage repositories, and the central AuthorizationManager.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Actors
    ChargingStations["Charging Stations"]:::external

    %% CSS Container
    subgraph "CSS - Central Service Server (NodeJS)" 
        direction TB
        CSS_OCPPServer["OCPPServer<br/>(SOAP & JSON WS)"]:::service
        CSS_OCPPService["OCPPService"]:::service
        CSS_OCPPUtils["OCPPUtils"]:::service
        CSS_OCPPValidator["OCPP Validators"]:::service
        CSS_OCPI["OCPI Server"]:::service
        CSS_OICP["OICP Server"]:::service
        CSS_OData["OData Server"]:::service
    end

    %% CSRS Container
    subgraph "CSRS - REST API Server (NodeJS + Express)"
        direction TB
        CSRS_RestServer["RestServer"]:::service
        CSRS_Routers["REST Routers"]:::service
        CSRS_Services["REST Services"]:::service
        CSRS_Auth["Authentication & ABAC"]:::service
        CSRS_SchemaVal["HTTP Schema Validator"]:::service
        CSRS_StorageVal["Storage Validators"]:::service
    end

    %% Database
    MongoDB["MongoDB<br/>(dockerized replica set)"]:::database

    %% Scheduler & Async
    subgraph "Scheduler & Async Task Worker"
        direction TB
        Scheduler["Scheduler"]:::service
        AsyncTask["Async Task Worker"]:::service
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Angular["Angular Dashboard"]:::external
        Stripe["Stripe Billing"]:::integration
        SAPConcur["SAP Concur Refund"]:::integration
        OCPIExt["OCPI/CPO Networks"]:::integration
        OICPExt["OICP Networks"]:::integration
        CarConn["Car Connector APIs"]:::integration
        SmartCharge["Smart Charging"]:::integration
        Analytics["SAP Analytics"]:::integration
        Email["Email SMTP"]:::integration
    end

    %% Monitoring
    Monitoring["Prometheus Monitoring"]:::monitoring

    %% Data Flows
    ChargingStations -->|"OCPP (SOAP/WS)"| CSS_OCPPServer
    CSS_OCPPServer -->|"uses"| CSS_OCPPService
    CSS_OCPPService -->|"utils/validation"| CSS_OCPPUtils
    CSS_OCPPService -->|"validate"| CSS_OCPPValidator
    CSS_OCPPServer -->|"OCPI endpoints"| CSS_OCPI
    CSS_OCPPServer -->|"OICP endpoints"| CSS_OICP
    CSS_OCPPServer -->|"OData endpoints"| CSS_OData
    CSS_OCPPServer -->|writes/reads| MongoDB

    Angular -->|"HTTPS/REST"| CSRS_RestServer
    CSRS_RestServer -->|"routes to"| CSRS_Routers
    CSRS_Routers -->|"invoke"| CSRS_Services
    CSRS_Services -->|"auth check"| CSRS_Auth
    CSRS_Services -->|"validate"| CSRS_SchemaVal
    CSRS_Services -->|"validate"| CSRS_StorageVal
    CSRS_Services -->|reads/writes| MongoDB

    Scheduler -->|"periodic tasks"| MongoDB
    AsyncTask -->|"async jobs"| MongoDB
    Scheduler -->|pull/push| OCPIExt
    Scheduler -->|pull/push| OICPExt
    AsyncTask -->|calls| Stripe
    AsyncTask -->|calls| SAPConcur
    AsyncTask -->|calls| CarConn
    AsyncTask -->|calls| SmartCharge
    AsyncTask -->|sends| Email

    Monitoring -->|"scrape metrics"| CSS_OCPPServer
    Monitoring -->|"scrape metrics"| CSRS_RestServer
    Monitoring -->|"scrape metrics"| Scheduler

    %% Click Events
    click CSS "https://github.com/sap-labs-france/ev-server/tree/master-qa/src/server"
    click CSS_OCPPServer "https://github.com/sap-labs-france/ev-server/blob/master-qa/src/server/ocpp/OCPPServer.ts"
    click CSS_OCPPService "https://github.com/sap-labs-france/ev-server/blob/master-qa/src/server/ocpp/services/OCPPService.ts"
    click CSS_OCPPUtils "https://github.com/sap-labs-france/ev-server/blob/master-qa/src/server/ocpp/utils/OCPPUtils.ts"
    click CSS_OCPPValidator "https://github.com/sap-labs-france/ev-server/blob/master-qa/src/server/ocpp/validator/OCPPValidator.ts"
    click CSS_OCPI "https://github.com/sap-labs-france/ev-server/blob/master-qa/src/server/ocpi/OCPIServer.ts"
    click CSS_OICP "https://github.com/sap-labs-france/ev-server/blob/master-qa/src/server/oicp/OICPServer.ts"
    click CSS_OData "https://github.com/sap-labs-france/ev-server/blob/master-qa/src/server/odata/ODataServer.ts"

    click CSRS_RestServer "https://github.com/sap-labs-france/ev-server/blob/master-qa/src/server/rest/RestServer.ts"
    click CSRS_Routers "https://github.com/sap-labs-france/ev-server/tree/master-qa/src/server/rest/v1/router"
    click CSRS_Services "https://github.com/sap-labs-france/ev-server/tree/master-qa/src/server/rest/v1/service"
    click CSRS_Auth "https://github.com/sap-labs-france/ev-server/tree/master-qa/src/authorization"
    click CSRS_SchemaVal "https://github.com/sap-labs-france/ev-server/blob/master-qa/src/validator/SchemaValidator.ts"
    click CSRS_StorageVal "https://github.com/sap-labs-france/ev-server/tree/master-qa/src/storage/validator"

    click MongoDB "https://github.com/sap-labs-france/ev-server/tree/master-qa/docker/initdb"
    click MongoDB "https://github.com/sap-labs-france/ev-server/tree/master-qa/src/storage/mongodb"

    click Scheduler "https://github.com/sap-labs-france/ev-server/tree/master-qa/src/scheduler"
    click AsyncTask "https://github.com/sap-labs-france/ev-server/tree/master-qa/src/async-task"

    click Stripe "https://github.com/sap-labs-france/ev-server/blob/master-qa/src/integration/billing/stripe/StripeBillingIntegration.ts"
    click SAPConcur "https://github.com/sap-labs-france/ev-server/blob/master-qa/src/integration/refund/sap-concur/SapConcurRefundIntegration.ts"
    click OCPIExt "https://github.com/sap-labs-france/ev-server/blob/master-qa/src/client/ocpi/OCPIClient.ts"
    click OCPIExt "https://github.com/sap-labs-france/ev-server/blob/master-qa/src/client/ocpi/OCPIClientFactory.ts"
    click OICPExt "https://github.com/sap-labs-france/ev-server/blob/master-qa/src/client/oicp/OICPClient.ts"
    click OICPExt "https://github.com/sap-labs-france/ev-server/blob/master-qa/src/client/oicp/OICPClientFactory.ts"
    click CarConn "https://github.com/sap-labs-france/ev-server/tree/master-qa/src/integration/car-connector"
    click SmartCharge "https://github.com/sap-labs-france/ev-server/blob/master-qa/src/integration/smart-charging/SmartChargingIntegration.ts"
    click Monitoring "https://github.com/sap-labs-france/ev-server/blob/master-qa/src/monitoring/prometheus/PrometheusMonitoringServer.ts"

    %% Styles
    classDef external fill:#F9F,stroke:#333,stroke-width:1px;
    classDef service fill:#BBF,stroke:#333,stroke-width:1px;
    classDef database fill:#FFD700,stroke:#333,stroke-width:1px;
    classDef integration fill:#BFB,stroke:#333,stroke-width:1px;
    classDef monitoring fill:#FDD,stroke:#333,stroke-width:1px;
```
