# evtivity/evtivity-csms architecture

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

- Interactive diagram: https://gitdiagram.com/evtivity/evtivity-csms
- Repository: https://github.com/evtivity/evtivity-csms

## Overview

EVtivity is an EV charging management platform: operator and driver interfaces reach a REST API, while charging stations and roaming partners use OCPP and OCPI services. The API and protocol services share PostgreSQL and Redis; workers handle background tasks. The README also documents station operations, payments, and AI-assisted workflows. Relationships below rely on README architecture and feature descriptions plus sampled source references; unsampled route and service internals are represented at directory level, so their internal call paths are not asserted.

Main entry points: [`packages/api/src/app.ts`](https://github.com/evtivity/evtivity-csms/blob/main/packages/api/src/app.ts) (REST API), [`packages/csms/src/App.tsx`](https://github.com/evtivity/evtivity-csms/blob/main/packages/csms/src/App.tsx) (Operator dashboard), [`packages/ocpp/src/server`](https://github.com/evtivity/evtivity-csms/tree/main/packages/ocpp/src/server) (OCPP server), [`packages/ocpi/src/app.ts`](https://github.com/evtivity/evtivity-csms/blob/main/packages/ocpi/src/app.ts) (OCPI service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User interfaces"]
  node_operator["Operator dashboard<br/>[App.tsx]"]
  node_driver["Driver portal<br/>[App.tsx]"]
end

subgraph group_backend["Platform services"]
  node_api["REST API<br/>[app.ts]"]
  node_workers["Background workers"]
  node_payments["Payments<br/>[webhooks.ts]"]
  node_pricing["Pricing engine<br/>[pricing-engine.ts]"]
end

subgraph group_protocols["Charging protocols"]
  node_ocpp["OCPP server"]
  node_ocpp_auth["Station authorization<br/>[authorize-token.ts]"]
  node_ocpi["OCPI service<br/>[app.ts]"]
  node_ocpi_push["Roaming sync<br/>[push.service.ts]"]
end

subgraph group_ai["AI operations"]
  node_ai_assistant["AI assistant<br/>[turn-runner.ts]"]
  node_ai_tools["Assistant tools<br/>[execute.ts]"]
  node_ai_providers["Model providers"]
  node_support_ai["Support assist"]
end

subgraph group_data["Shared data"]
  node_database[("PostgreSQL")]
  node_redis[("Redis<br/>[redis-client.ts]")]
end

node_operator_actor(("Operator"))
node_driver_actor(("Driver"))
node_stations(("Charging stations"))
node_partners(("OCPI partners"))

node_operator_actor -->|"uses"| node_operator
node_driver_actor -->|"uses"| node_driver
node_operator -->|"REST requests"| node_api
node_driver -->|"REST requests"| node_api
node_api -->|"reads and writes"| node_database
node_api -->|"uses pub/sub"| node_redis
node_ocpp -->|"reads and writes"| node_database
node_ocpp -->|"uses pub/sub"| node_redis
node_ocpi -->|"reads and writes"| node_database
node_ocpi -->|"uses pub/sub"| node_redis
node_workers -->|"uses"| node_database
node_workers -->|"uses"| node_redis
node_stations -->|"OCPP messages"| node_ocpp
node_ocpp -->|"authorizes tokens"| node_ocpp_auth
node_partners -->|"OCPI requests"| node_ocpi
node_ocpi -.->|"registers service routes"| node_ocpi_push
node_operator -->|"asks questions"| node_ai_assistant
node_ai_assistant -->|"reads and proposes"| node_ai_tools
node_ai_tools -->|"accesses data"| node_api
node_ai_assistant -->|"streams responses"| node_ai_providers
node_operator -->|"assists cases"| node_support_ai
node_api -.->|"coordinates payments"| node_payments
node_api -.->|"prices sessions"| node_pricing

click node_operator "https://github.com/evtivity/evtivity-csms/blob/main/packages/csms/src/App.tsx"
click node_driver "https://github.com/evtivity/evtivity-csms/blob/main/packages/portal/src/App.tsx"
click node_api "https://github.com/evtivity/evtivity-csms/blob/main/packages/api/src/app.ts"
click node_workers "https://github.com/evtivity/evtivity-csms/tree/main/packages/worker/src"
click node_payments "https://github.com/evtivity/evtivity-csms/blob/main/packages/payments/src/webhooks.ts"
click node_pricing "https://github.com/evtivity/evtivity-csms/blob/main/packages/lib/src/pricing-engine.ts"
click node_ocpp "https://github.com/evtivity/evtivity-csms/tree/main/packages/ocpp/src/server"
click node_ocpp_auth "https://github.com/evtivity/evtivity-csms/blob/main/packages/ocpp/src/authorization/authorize-token.ts"
click node_ocpi "https://github.com/evtivity/evtivity-csms/blob/main/packages/ocpi/src/app.ts"
click node_ocpi_push "https://github.com/evtivity/evtivity-csms/blob/main/packages/ocpi/src/services/push.service.ts"
click node_ai_assistant "https://github.com/evtivity/evtivity-csms/blob/main/packages/api/src/services/ai/engine/turn-runner.ts"
click node_ai_tools "https://github.com/evtivity/evtivity-csms/blob/main/packages/api/src/services/ai/tools/execute.ts"
click node_ai_providers "https://github.com/evtivity/evtivity-csms/tree/main/packages/ai/src/providers"
click node_support_ai "https://github.com/evtivity/evtivity-csms/blob/main/packages/api/src/services/ai/engine/support-insights.ts"
click node_database "https://github.com/evtivity/evtivity-csms/tree/main/packages/database/src"
click node_redis "https://github.com/evtivity/evtivity-csms/blob/main/packages/lib/src/redis-client.ts"

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_operator,node_driver toneBlue
class node_api,node_workers,node_payments,node_pricing toneAmber
class node_ocpp,node_ocpp_auth,node_ocpi,node_ocpi_push toneMint
class node_ai_assistant,node_ai_tools,node_ai_providers,node_support_ai toneRose
class node_database,node_redis,node_operator_actor,node_driver_actor,node_stations,node_partners toneIndigo
```

## Components

### User interfaces

- [Operator dashboard](https://github.com/evtivity/evtivity-csms/blob/main/packages/csms/src/App.tsx): `packages/csms/src/App.tsx`
- [Driver portal](https://github.com/evtivity/evtivity-csms/blob/main/packages/portal/src/App.tsx): `packages/portal/src/App.tsx`

### Platform services

- [REST API](https://github.com/evtivity/evtivity-csms/blob/main/packages/api/src/app.ts): `packages/api/src/app.ts`
- [Background workers](https://github.com/evtivity/evtivity-csms/tree/main/packages/worker/src): `packages/worker/src`
- [Payments](https://github.com/evtivity/evtivity-csms/blob/main/packages/payments/src/webhooks.ts): `packages/payments/src/webhooks.ts`
- [Pricing engine](https://github.com/evtivity/evtivity-csms/blob/main/packages/lib/src/pricing-engine.ts): `packages/lib/src/pricing-engine.ts`

### Charging protocols

- [OCPP server](https://github.com/evtivity/evtivity-csms/tree/main/packages/ocpp/src/server): `packages/ocpp/src/server`
- [Station authorization](https://github.com/evtivity/evtivity-csms/blob/main/packages/ocpp/src/authorization/authorize-token.ts): `packages/ocpp/src/authorization/authorize-token.ts`
- [OCPI service](https://github.com/evtivity/evtivity-csms/blob/main/packages/ocpi/src/app.ts): `packages/ocpi/src/app.ts`
- [Roaming sync](https://github.com/evtivity/evtivity-csms/blob/main/packages/ocpi/src/services/push.service.ts): `packages/ocpi/src/services/push.service.ts`

### AI operations

- [AI assistant](https://github.com/evtivity/evtivity-csms/blob/main/packages/api/src/services/ai/engine/turn-runner.ts): `packages/api/src/services/ai/engine/turn-runner.ts`
- [Assistant tools](https://github.com/evtivity/evtivity-csms/blob/main/packages/api/src/services/ai/tools/execute.ts): `packages/api/src/services/ai/tools/execute.ts`
- [Model providers](https://github.com/evtivity/evtivity-csms/tree/main/packages/ai/src/providers): `packages/ai/src/providers`
- [Support assist](https://github.com/evtivity/evtivity-csms/blob/main/packages/api/src/services/ai/engine/support-insights.ts): `packages/api/src/services/ai/engine/support-insights.ts`

### Shared data

- [PostgreSQL](https://github.com/evtivity/evtivity-csms/tree/main/packages/database/src): `packages/database/src`
- [Redis](https://github.com/evtivity/evtivity-csms/blob/main/packages/lib/src/redis-client.ts): `packages/lib/src/redis-client.ts`

### Other components

- **Operator**
- **Driver**
- **Charging stations**
- **OCPI partners**

## Connections

- Operator → Operator dashboard: uses (evidence: `README.md`)
- Driver → Driver portal: uses (evidence: `README.md`)
- Operator dashboard → REST API: REST requests (evidence: `README.md`)
- Driver portal → REST API: REST requests (evidence: `README.md`)
- REST API → PostgreSQL: reads and writes (evidence: `README.md`)
- REST API → Redis: uses pub/sub (evidence: `README.md`)
- OCPP server → PostgreSQL: reads and writes (evidence: `README.md`)
- OCPP server → Redis: uses pub/sub (evidence: `README.md`)
- OCPI service → PostgreSQL: reads and writes (evidence: `README.md`)
- OCPI service → Redis: uses pub/sub (evidence: `README.md`)
- Background workers → PostgreSQL: uses (evidence: `README.md`)
- Background workers → Redis: uses (evidence: `README.md`)
- Charging stations → OCPP server: OCPP messages (evidence: `README.md`)
- OCPP server → Station authorization: authorizes tokens (evidence: `packages/ocpp/src/handlers/v2_1/authorize.handler.ts`)
- OCPI partners → OCPI service: OCPI requests (evidence: `README.md`)
- OCPI service → Roaming sync: registers service routes
- Operator dashboard → AI assistant: asks questions (evidence: `README.md`)
- AI assistant → Assistant tools: reads and proposes (evidence: `README.md`)
- Assistant tools → REST API: accesses data (evidence: `README.md`)
- AI assistant → Model providers: streams responses (evidence: `README.md`)
- Operator dashboard → Support assist: assists cases (evidence: `README.md`)
- REST API → Payments: coordinates payments
- REST API → Pricing engine: prices sessions
