# mobilityhouse/ocpp architecture

> Architecture diagram of the GitHub repository mobilityhouse/ocpp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mobilityhouse/ocpp
- Repository: https://github.com/mobilityhouse/ocpp

## Overview

This is a Python library for implementing the JSON Open Charge Point Protocol (OCPP), with protocol models for versions 1.6, 2.0.1, and 2.1. Its main workflow receives a message over a caller-provided connection, routes and validates it, invokes a registered handler, and sends a response; callers can also send requests and await responses. Version-specific modules define message payloads, datatypes, and enums. The README and tree establish the supported protocol versions and schema-backed message capability; the excerpts do not show all schema-loading details or the full outbound workflow.

Main entry points: [`ocpp/charge_point.py`](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/charge_point.py) (Charge-point runtime), [`ocpp/v16/enums.py`](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v16/enums.py) (Protocol enums), [`ocpp/v201/enums.py`](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v201/enums.py) (Protocol enums), [`ocpp/v16/call.py`](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v16/call.py) (Request payloads)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Message runtime"]
  node_chargepoint["Charge-point runtime<br/>[charge_point.py]"]
  node_messages["Message encoding<br/>[messages.py]"]
  node_errors["Protocol errors<br/>[exceptions.py]"]
  node_schemas["Message schemas"]
end

subgraph group_routing["Handler routing"]
  node_routes["Route decorators<br/>[routing.py]"]
end

subgraph group_v16["OCPP 1.6"]
  node_v16call["Request payloads<br/>[call.py]"]
  node_v16result["Response payloads<br/>[call_result.py]"]
  node_v16data["Data structures<br/>[datatypes.py]"]
  node_v16enums["Protocol enums<br/>[enums.py]"]
end

subgraph group_v201["OCPP 2.0.1"]
  node_v201call["Request payloads<br/>[call.py]"]
  node_v201result["Response payloads<br/>[call_result.py]"]
  node_v201data["Data structures<br/>[datatypes.py]"]
  node_v201enums["Protocol enums<br/>[enums.py]"]
end

subgraph group_v21["OCPP 2.1"]
  node_v21call["Request payloads<br/>[call.py]"]
  node_v21result["Response payloads<br/>[call_result.py]"]
  node_v21data["Data structures<br/>[datatypes.py]"]
  node_v21enums["Protocol enums<br/>[enums.py]"]
end

node_client(("Library user"))
node_connection["Connection"]

node_client -->|"uses"| node_chargepoint
node_chargepoint -->|"receives and sends"| node_connection
node_chargepoint -->|"parses messages"| node_messages
node_chargepoint -->|"looks up handlers"| node_routes
node_chargepoint -->|"raises protocol errors"| node_errors
node_chargepoint -->|"uses enums"| node_v16enums
node_chargepoint -->|"uses enums"| node_v201enums
node_chargepoint -->|"reports parse errors"| node_messages
node_v16call -->|"uses types"| node_v16data
node_v16call -->|"uses enums"| node_v16enums
node_v16result -->|"uses types"| node_v16data
node_v16result -->|"uses enums"| node_v16enums
node_v201call -->|"uses types"| node_v201data
node_v201call -->|"uses enums"| node_v201enums
node_v201result -->|"uses types"| node_v201data
node_v201result -->|"uses enums"| node_v201enums
node_v21call -->|"uses types"| node_v21data
node_v21call -->|"uses enums"| node_v21enums
node_v21result -->|"uses types"| node_v21data
node_v21result -->|"uses enums"| node_v21enums

click node_chargepoint "https://github.com/mobilityhouse/ocpp/blob/master/ocpp/charge_point.py"
click node_messages "https://github.com/mobilityhouse/ocpp/blob/master/ocpp/messages.py"
click node_errors "https://github.com/mobilityhouse/ocpp/blob/master/ocpp/exceptions.py"
click node_routes "https://github.com/mobilityhouse/ocpp/blob/master/ocpp/routing.py"
click node_v16call "https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v16/call.py"
click node_v16result "https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v16/call_result.py"
click node_v16data "https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v16/datatypes.py"
click node_v16enums "https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v16/enums.py"
click node_v201call "https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v201/call.py"
click node_v201result "https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v201/call_result.py"
click node_v201data "https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v201/datatypes.py"
click node_v201enums "https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v201/enums.py"
click node_v21call "https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v21/call.py"
click node_v21result "https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v21/call_result.py"
click node_v21data "https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v21/datatypes.py"
click node_v21enums "https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v21/enums.py"
click node_schemas "https://github.com/mobilityhouse/ocpp/tree/master/ocpp/v201/schemas"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_chargepoint,node_messages,node_errors,node_schemas,node_client toneBlue
class node_routes toneAmber
class node_v16call,node_v16result,node_v16data,node_v16enums toneMint
class node_v201call,node_v201result,node_v201data,node_v201enums toneRose
class node_v21call,node_v21result,node_v21data,node_v21enums,node_connection toneIndigo
```

## Components

### Message runtime

- [Charge-point runtime](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/charge_point.py): `ocpp/charge_point.py`
- [Message encoding](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/messages.py): `ocpp/messages.py`
- [Protocol errors](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/exceptions.py): `ocpp/exceptions.py`
- [Message schemas](https://github.com/mobilityhouse/ocpp/tree/master/ocpp/v201/schemas): `ocpp/v201/schemas`

### Handler routing

- [Route decorators](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/routing.py): `ocpp/routing.py`

### OCPP 1.6

- [Request payloads](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v16/call.py): `ocpp/v16/call.py`
- [Response payloads](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v16/call_result.py): `ocpp/v16/call_result.py`
- [Data structures](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v16/datatypes.py): `ocpp/v16/datatypes.py`
- [Protocol enums](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v16/enums.py): `ocpp/v16/enums.py`

### OCPP 2.0.1

- [Request payloads](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v201/call.py): `ocpp/v201/call.py`
- [Response payloads](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v201/call_result.py): `ocpp/v201/call_result.py`
- [Data structures](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v201/datatypes.py): `ocpp/v201/datatypes.py`
- [Protocol enums](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v201/enums.py): `ocpp/v201/enums.py`

### OCPP 2.1

- [Request payloads](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v21/call.py): `ocpp/v21/call.py`
- [Response payloads](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v21/call_result.py): `ocpp/v21/call_result.py`
- [Data structures](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v21/datatypes.py): `ocpp/v21/datatypes.py`
- [Protocol enums](https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v21/enums.py): `ocpp/v21/enums.py`

### Other components

- **Library user**
- **Connection**

## Connections

- Library user → Charge-point runtime: uses (evidence: `README.rst`)
- Charge-point runtime → Connection: receives and sends (evidence: `ocpp/charge_point.py`)
- Charge-point runtime → Message encoding: parses messages (evidence: `ocpp/charge_point.py`)
- Charge-point runtime → Route decorators: looks up handlers (evidence: `ocpp/charge_point.py`)
- Charge-point runtime → Protocol errors: raises protocol errors (evidence: `ocpp/charge_point.py`)
- Charge-point runtime → Protocol enums: uses enums (evidence: `ocpp/charge_point.py`)
- Charge-point runtime → Protocol enums: uses enums (evidence: `ocpp/charge_point.py`)
- Charge-point runtime → Message encoding: reports parse errors (evidence: `ocpp/messages.py`)
- Request payloads → Data structures: uses types (evidence: `ocpp/v16/call.py`)
- Request payloads → Protocol enums: uses enums (evidence: `ocpp/v16/call.py`)
- Response payloads → Data structures: uses types (evidence: `ocpp/v16/call_result.py`)
- Response payloads → Protocol enums: uses enums (evidence: `ocpp/v16/call_result.py`)
- Request payloads → Data structures: uses types (evidence: `ocpp/v201/call.py`)
- Request payloads → Protocol enums: uses enums (evidence: `ocpp/v201/call.py`)
- Response payloads → Data structures: uses types (evidence: `ocpp/v201/call_result.py`)
- Response payloads → Protocol enums: uses enums (evidence: `ocpp/v201/call_result.py`)
- Request payloads → Data structures: uses types (evidence: `ocpp/v21/call.py`)
- Request payloads → Protocol enums: uses enums (evidence: `ocpp/v21/call.py`)
- Response payloads → Data structures: uses types (evidence: `ocpp/v21/call_result.py`)
- Response payloads → Protocol enums: uses enums (evidence: `ocpp/v21/call_result.py`)
