An open API service indexing awesome lists of open source software.

https://github.com/opencpo/opencpo-admin

๐Ÿ–ฅ๏ธ CPO admin dashboard โ€” chargers, sessions, tariffs, PKI, skin gallery, OCPP message viewer
https://github.com/opencpo/opencpo-admin

admin cpo dashboard ev-charging fastapi htmx jinja2 ocpp

Last synced: about 22 hours ago
JSON representation

๐Ÿ–ฅ๏ธ CPO admin dashboard โ€” chargers, sessions, tariffs, PKI, skin gallery, OCPP message viewer

Awesome Lists containing this project

README

          

# OCPP Admin

**Network management dashboard for OCPP Core.**

FastAPI + Jinja2 + HTMX. No React, no npm, no build step.

> โœ… **Built-in authentication.** JWT-based login with bcrypt password hashing. First-time setup wizard on first visit. No hardcoded credentials.

---

## Features

| Feature | Description |
|---------|-------------|
| ๐Ÿ“Š **Dashboard** | Network overview โ€” charger status, session counts, PKI health |
| ๐Ÿ”Œ **Chargers** | List, filter, manage chargers; remote control (start/stop/reset/unlock) |
| โšก **Sessions** | Live session monitoring with enriched data (RFID, energy, duration) |
| ๐Ÿ’ฐ **Tariffs** | Create and manage pricing configurations |
| ๐Ÿท๏ธ **RFID / Tokens** | Token management, whitelist/blacklist, group assignment |
| ๐Ÿ‘ฅ **Groups** | Charger groups and load-balancing configuration |
| ๐Ÿงพ **Invoices** | Session-based invoicing and export |
| ๐Ÿ” **PKI** | Certificate lifecycle dashboard โ€” issue, revoke, inspect |
| ๐Ÿ“ก **OCPP Messages** | Real-time OCPP event stream viewer |
| ๐Ÿ›ก๏ธ **Security** | Security events, alert history, PKI health |
| ๐ŸŽ›๏ธ **Features** | Feature flags and runtime configuration |
| ๐Ÿš€ **Onboarding** | Self-service PKI onboarding for operators (Root CA + personal cert) |

---

## Authentication

The admin panel uses JWT-based authentication against the OCPP Core API. On first access, you'll be redirected to `/setup` โ€” a 6-step wizard where you create your admin account, configure the organization name, and set up SMTP. After setup, login uses email + password with bcrypt-hashed credentials stored in the `ocpp.users` table. Session tokens are stored as HTTP-only cookies (`opencpo_session`).

### First-time Setup Flow

1. Visit `http://localhost:8080` โ†’ redirected to `/setup`
2. Step 1: Create admin account (email + password)
3. Step 2: Configure organization name and public URL
4. Step 3: SMTP settings (can be skipped)
5. Step 4: PKI configuration (can be skipped)
6. Step 5: Default pricing (can be skipped)
7. Step 6: Feature flags (can be skipped)
8. Redirected to `/login` โ€” sign in with your new credentials

All steps are skippable. You can return to `/setup` anytime to fill in missing configuration.

## Quick Start

### 1. Install dependencies

```bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```

### 2. Configure

Copy the example env file and fill in your values:

```bash
cp .env.example .env
```

At minimum you need:

```bash
OCPP_CORE_API=http://localhost:8000
```

### 3. Run

```bash
# With .env file
python-dotenv run -- python main.py

# Or export vars manually
export OCPP_CORE_API=http://localhost:8000
python main.py
```

Open http://localhost:8080 โ€” you'll be redirected to the setup wizard on first visit.

---

## Configuration Reference

All configuration is via environment variables (`.env` file supported via `python-dotenv`).

| Variable | Default | Description |
|----------|---------|-------------|
| `APP_TITLE` | `OCPP Admin` | Application name shown in UI |
| `HOST` | `127.0.0.1` | Bind address for uvicorn |
| `PORT` | `8080` | Bind port |
| `DB_HOST` | `127.0.0.1` | PostgreSQL host |
| `DB_PORT` | `5432` | PostgreSQL port |
| `DB_NAME` | `ocppcore` | PostgreSQL database name |
| `DB_USER` | `ocpp` | PostgreSQL user |
| `DB_PASS` | *(required)* | PostgreSQL password |
| `OCPP_CORE_API` | `http://localhost:8000` | OCPP Core REST API base URL |
| `PKI_DATA_DIR` | `../ocpp-core/data/pki` | Path to PKI data dir (contains `root-ca.crt` and `users/`) |

---

## Architecture

```
Browser โ†โ”€HTMXโ”€โ†’ CPO Admin (FastAPI)
โ”‚
โ”œโ”€ PostgreSQL (sessions, tokens, tariffs, groups)
โ”‚
โ””โ”€ OCPP Core API (chargers, PKI, OCPP commands)
```

- **OCPP Core** handles the WebSocket charger connections and exposes a REST API
- **CPO Admin** is a pure UI layer โ€” it reads from Postgres and calls OCPP Core
- **HTMX** powers live updates via SSE and partial HTML swaps (no WebSocket from browser)
- **Tailwind CSS** (CDN) โ€” no build step required
- `python main.py` and it runs

---

## Skin Customization

The UI supports swappable skins via the `skins/` directory.

```
skins/
base/ โ† generic default skin
```

The `logo.svg` in `static/` is the primary branding asset (generic OpenCPO lightning bolt). Replace `static/logo.png` with your own PNG logo; it is not generated automatically.

Set `SKIN=base` (default) to use the generic skin. To use a custom skin:

1. Copy `skins/base/` to `skins/my-brand/`
2. Edit colors, logo, and CSS in your skin directory
3. Set `SKIN=my-brand` in your `.env`

Copy `skins/base/` as a starting point for your own branded skin.

---

## PKI / Onboarding

The `/onboarding` page provides self-service certificate distribution:

1. Operators visit `/onboarding`
2. They download the Root CA certificate and install it in their OS trust store
3. They enter their email to request a personal certificate (PKCS#12 or PEM)
4. The admin authenticates via mutual TLS with their personal cert

PKI operations are delegated to OCPP Core via `POST /api/v1/pki/issue/user`.

The PKI data directory (cert storage) is configured via `PKI_DATA_DIR`.

---

## Requirements

- Python 3.11+
- PostgreSQL 14+
- OCPP Core service running (for charger control and PKI)
- `openssl` CLI available (for DER conversion in onboarding)

---

## License

Apache 2.0 โ€” see [LICENSE](LICENSE).