# abbas-gheydi/radotp architecture

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

- Interactive diagram: https://gitdiagram.com/abbas-gheydi/radotp
- Repository: https://github.com/abbas-gheydi/radotp

## Overview

RadOTP is a RADIUS server that provides VPN authentication with password, OTP, or combined modes, alongside an administrator web interface and REST API. The main runtime loads configuration and initializes storage, then starts the web and RADIUS services; optional Prometheus metrics are started when enabled. RADIUS challenges can request an OTP, which is checked against stored secrets, while LDAP supports directory credential checks. The README also documents user administration, logs, and monitoring. Some subsystem links rely on README statements because their implementation was not sampled.

Main entry points: [`pkgs/web/router.go`](https://github.com/abbas-gheydi/radotp/blob/main/pkgs/web/router.go) (Web router), [`pkgs/storage/storage.go`](https://github.com/abbas-gheydi/radotp/blob/main/pkgs/storage/storage.go) (Storage interface), [`cmd/server/main.go`](https://github.com/abbas-gheydi/radotp/blob/main/cmd/server/main.go) (Server entrypoint), [`pkgs/rad`](https://github.com/abbas-gheydi/radotp/tree/main/pkgs/rad) (Auth and challenge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and configuration"]
  node_entry["Server entrypoint<br/>[main.go]"]
  node_config["Configuration"]
end

subgraph group_radius["RADIUS authentication"]
  node_radiusserver["RADIUS server<br/>[Start.go]"]
  node_radiusflow["Auth and challenge"]
  node_radiusreply["RADIUS responses<br/>[actions.go]"]
  node_vendorattrs["Vendor attributes"]
end

subgraph group_identity["Identity and secrets"]
  node_ldap["LDAP authentication<br/>[ldap.go]"]
  node_otpflow["OTP validation<br/>[otp.go]"]
  node_storageapi["Storage interface<br/>[storage.go]"]
  node_otpstore[("OTP records<br/>[postgres_otp.go]")]
  node_adminstore[("Admin credentials")]
end

subgraph group_admin["Administration API"]
  node_webrouter["Web router<br/>[router.go]"]
  node_webadmin["Web user management<br/>[web.go]"]
  node_restapi["REST API<br/>[api.go]"]
  node_weblog["Activity logs<br/>[weblog.go]"]
end

subgraph group_observability["Monitoring"]
  node_metrics["Prometheus metrics"]
end

node_vpn(("VPN firewall"))
node_adminuser(("Administrator"))
node_prometheus(("Prometheus"))
node_directory(("Directory service"))

node_entry -->|"loads"| node_config
node_entry -->|"starts"| node_radiusserver
node_entry -->|"starts"| node_webrouter
node_entry -->|"starts optionally"| node_metrics
node_config -->|"configures"| node_radiusserver
node_config -->|"configures"| node_metrics
node_vpn -.->|"authenticates via RADIUS"| node_radiusserver
node_radiusserver -.->|"dispatches requests"| node_radiusflow
node_radiusflow -.->|"checks credentials"| node_ldap
node_radiusflow -->|"validates OTP"| node_otpflow
node_radiusflow -->|"sends challenge or result"| node_radiusreply
node_radiusreply -->|"adds group attributes"| node_vendorattrs
node_otpflow -->|"reads secret"| node_storageapi
node_storageapi -->|"uses OTP storage"| node_otpstore
node_ldap -.->|"checks directory"| node_directory
node_webrouter -.->|"routes requests"| node_webadmin
node_webrouter -.->|"routes API"| node_restapi
node_webrouter -.->|"serves logs"| node_weblog
node_adminuser -.->|"manages users"| node_webrouter
node_webadmin -->|"creates and edits OTPs"| node_storageapi
node_webadmin -->|"checks admin credentials"| node_storageapi
node_storageapi -->|"uses admin storage"| node_adminstore
node_radiusreply -->|"records outcomes"| node_metrics
node_metrics -.->|"exposes metrics"| node_prometheus

click node_entry "https://github.com/abbas-gheydi/radotp/blob/main/cmd/server/main.go"
click node_config "https://github.com/abbas-gheydi/radotp/tree/main/pkgs/confs"
click node_radiusserver "https://github.com/abbas-gheydi/radotp/blob/main/pkgs/rad/Start.go"
click node_radiusflow "https://github.com/abbas-gheydi/radotp/tree/main/pkgs/rad"
click node_radiusreply "https://github.com/abbas-gheydi/radotp/blob/main/pkgs/rad/actions.go"
click node_vendorattrs "https://github.com/abbas-gheydi/radotp/tree/main/pkgs/rad/vendors"
click node_ldap "https://github.com/abbas-gheydi/radotp/blob/main/pkgs/authentiate/ldap.go"
click node_otpflow "https://github.com/abbas-gheydi/radotp/blob/main/pkgs/authentiate/otp.go"
click node_storageapi "https://github.com/abbas-gheydi/radotp/blob/main/pkgs/storage/storage.go"
click node_otpstore "https://github.com/abbas-gheydi/radotp/blob/main/pkgs/storage/postgres_otp.go"
click node_adminstore "https://github.com/abbas-gheydi/radotp/blob/main/pkgs/storage/postgres_webadmin.go"
click node_webrouter "https://github.com/abbas-gheydi/radotp/blob/main/pkgs/web/router.go"
click node_webadmin "https://github.com/abbas-gheydi/radotp/blob/main/pkgs/web/web.go"
click node_restapi "https://github.com/abbas-gheydi/radotp/blob/main/pkgs/web/api.go"
click node_weblog "https://github.com/abbas-gheydi/radotp/blob/main/pkgs/web/weblog.go"
click node_metrics "https://github.com/abbas-gheydi/radotp/tree/main/pkgs/monitoring"

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_entry,node_config toneBlue
class node_radiusserver,node_radiusflow,node_radiusreply,node_vendorattrs toneAmber
class node_ldap,node_otpflow,node_storageapi,node_otpstore,node_adminstore toneMint
class node_webrouter,node_webadmin,node_restapi,node_weblog toneRose
class node_metrics,node_vpn,node_adminuser,node_prometheus,node_directory toneIndigo
```

## Components

### Runtime and configuration

- [Server entrypoint](https://github.com/abbas-gheydi/radotp/blob/main/cmd/server/main.go): `cmd/server/main.go`
- [Configuration](https://github.com/abbas-gheydi/radotp/tree/main/pkgs/confs): `pkgs/confs`

### RADIUS authentication

- [RADIUS server](https://github.com/abbas-gheydi/radotp/blob/main/pkgs/rad/Start.go): `pkgs/rad/Start.go`
- [Auth and challenge](https://github.com/abbas-gheydi/radotp/tree/main/pkgs/rad): `pkgs/rad`
- [RADIUS responses](https://github.com/abbas-gheydi/radotp/blob/main/pkgs/rad/actions.go): `pkgs/rad/actions.go`
- [Vendor attributes](https://github.com/abbas-gheydi/radotp/tree/main/pkgs/rad/vendors): `pkgs/rad/vendors`

### Identity and secrets

- [LDAP authentication](https://github.com/abbas-gheydi/radotp/blob/main/pkgs/authentiate/ldap.go): `pkgs/authentiate/ldap.go`
- [OTP validation](https://github.com/abbas-gheydi/radotp/blob/main/pkgs/authentiate/otp.go): `pkgs/authentiate/otp.go`
- [Storage interface](https://github.com/abbas-gheydi/radotp/blob/main/pkgs/storage/storage.go): `pkgs/storage/storage.go`
- [OTP records](https://github.com/abbas-gheydi/radotp/blob/main/pkgs/storage/postgres_otp.go): `pkgs/storage/postgres_otp.go`
- [Admin credentials](https://github.com/abbas-gheydi/radotp/blob/main/pkgs/storage/postgres_webadmin.go): `pkgs/storage/postgres_webadmin.go`

### Administration API

- [Web router](https://github.com/abbas-gheydi/radotp/blob/main/pkgs/web/router.go): `pkgs/web/router.go`
- [Web user management](https://github.com/abbas-gheydi/radotp/blob/main/pkgs/web/web.go): `pkgs/web/web.go`
- [REST API](https://github.com/abbas-gheydi/radotp/blob/main/pkgs/web/api.go): `pkgs/web/api.go`
- [Activity logs](https://github.com/abbas-gheydi/radotp/blob/main/pkgs/web/weblog.go): `pkgs/web/weblog.go`

### Monitoring

- [Prometheus metrics](https://github.com/abbas-gheydi/radotp/tree/main/pkgs/monitoring): `pkgs/monitoring`

### Other components

- **VPN firewall**
- **Administrator**
- **Prometheus**
- **Directory service**

## Connections

- Server entrypoint → Configuration: loads (evidence: `cmd/server/main.go`)
- Server entrypoint → RADIUS server: starts (evidence: `cmd/server/main.go`)
- Server entrypoint → Web router: starts (evidence: `cmd/server/main.go`)
- Server entrypoint → Prometheus metrics: starts optionally (evidence: `cmd/server/main.go`)
- Configuration → RADIUS server: configures (evidence: `pkgs/confs/load.go`)
- Configuration → Prometheus metrics: configures (evidence: `pkgs/confs/load.go`)
- VPN firewall → RADIUS server: authenticates via RADIUS (evidence: `README.md`)
- RADIUS server → Auth and challenge: dispatches requests
- Auth and challenge → LDAP authentication: checks credentials (evidence: `README.md`)
- Auth and challenge → OTP validation: validates OTP (evidence: `pkgs/rad/otp.go`)
- Auth and challenge → RADIUS responses: sends challenge or result (evidence: `pkgs/rad/otp.go`)
- RADIUS responses → Vendor attributes: adds group attributes (evidence: `pkgs/rad/actions.go`)
- OTP validation → Storage interface: reads secret (evidence: `pkgs/authentiate/otp.go`)
- Storage interface → OTP records: uses OTP storage (evidence: `pkgs/storage/storage.go`)
- LDAP authentication → Directory service: checks directory (evidence: `README.md`)
- Web router → Web user management: routes requests (evidence: `pkgs/web/router.go`)
- Web router → REST API: routes API (evidence: `README.md`)
- Web router → Activity logs: serves logs (evidence: `README.md`)
- Administrator → Web router: manages users (evidence: `README.md`)
- Web user management → Storage interface: creates and edits OTPs (evidence: `pkgs/web/web.go`)
- Web user management → Storage interface: checks admin credentials
- Storage interface → Admin credentials: uses admin storage (evidence: `pkgs/storage/storage.go`)
- RADIUS responses → Prometheus metrics: records outcomes (evidence: `pkgs/rad/actions.go`)
- Prometheus metrics → Prometheus: exposes metrics (evidence: `README.md`)
