# devravik/go-license-api architecture

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

- Interactive diagram: https://gitdiagram.com/devravik/go-license-api
- Repository: https://github.com/devravik/go-license-api

## Overview

Go License API is a self-hosted, multi-tenant licensing service. In the main online workflow, a client submits a license validation request; routing and middleware protect it, a bounded worker pool runs validation, and the service checks cached license and tenant data before returning a result. The control plane manages tenants, licenses, plans, and products, with database updates and cache consistency. Documented capabilities also include activation and usage, offline signed licenses, audit logging, webhooks, key rotation, and rate limiting. Some links reflect README-described behavior because the corresponding implementation excerpts were not available.

Main entry points: [`internal/http/router.go`](https://github.com/devravik/go-license-api/blob/main/internal/http/router.go) (Route Setup), [`internal/http/license/handler.go`](https://github.com/devravik/go-license-api/blob/main/internal/http/license/handler.go) (License Handler), [`internal/http/admin/handler.go`](https://github.com/devravik/go-license-api/blob/main/internal/http/admin/handler.go) (Admin Handler), [`internal/app/validation_service.go`](https://github.com/devravik/go-license-api/blob/main/internal/app/validation_service.go) (License Validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_router["Route Setup<br/>[router.go]"]
  node_license_handler["License Handler<br/>[handler.go]"]
  node_activation_handler["Activation Handler"]
  node_admin_handler["Admin Handler<br/>[handler.go]"]
  node_middleware["Request Guards"]
end

subgraph group_runtime["Validation Runtime"]
  node_validation["License Validation"]
  node_activation["Activation Service"]
  node_worker_pool["Worker Pool<br/>[pool.go]"]
  node_worker["Validation Worker<br/>[worker.go]"]
  node_signed_license["Offline Licenses"]
end

subgraph group_control["Control Plane"]
  node_admin_service["Admin Services<br/>[admin_service.go]"]
  node_tenant_api["Tenant API<br/>[handler.go]"]
end

subgraph group_infra["Infrastructure"]
  node_postgres[("PostgreSQL<br/>[postgres.go]")]
  node_license_cache["License Cache<br/>[license_store.go]"]
  node_redis[("Redis L2 Cache<br/>[l2_redis.go]")]
  node_audit["Audit Pipeline<br/>[worker.go]"]
  node_webhooks["Webhook Delivery<br/>[dispatcher.go]"]
  node_signing["License Signing<br/>[signer.go]"]
end

node_client(("License Client"))

node_client -->|"sends request"| node_router
node_router -->|"applies guards"| node_middleware
node_router -->|"routes validation"| node_license_handler
node_license_handler -.->|"submits validation"| node_worker_pool
node_worker_pool -->|"dispatches jobs"| node_worker
node_worker -->|"executes validation"| node_validation
node_validation -->|"checks cache"| node_license_cache
node_license_cache -.->|"checks L2"| node_redis
node_license_handler -->|"serves activation routes"| node_activation_handler
node_activation_handler -->|"handles activation"| node_activation
node_router -->|"routes admin requests"| node_admin_handler
node_admin_handler -->|"invokes management"| node_admin_service
node_router -->|"routes tenant requests"| node_tenant_api
node_admin_service -.->|"persists changes"| node_postgres
node_admin_service -->|"updates cache"| node_license_cache
node_validation -.->|"records events"| node_audit
node_admin_handler -.->|"registers callbacks"| node_webhooks
node_client -.->|"verifies offline"| node_signed_license
node_signed_license -.->|"verifies signature"| node_signing

click node_router "https://github.com/devravik/go-license-api/blob/main/internal/http/router.go"
click node_license_handler "https://github.com/devravik/go-license-api/blob/main/internal/http/license/handler.go"
click node_activation_handler "https://github.com/devravik/go-license-api/blob/main/internal/http/handlers/activation_handler.go"
click node_admin_handler "https://github.com/devravik/go-license-api/blob/main/internal/http/admin/handler.go"
click node_middleware "https://github.com/devravik/go-license-api/tree/main/internal/http/middleware"
click node_validation "https://github.com/devravik/go-license-api/blob/main/internal/app/validation_service.go"
click node_activation "https://github.com/devravik/go-license-api/blob/main/internal/app/activation_service.go"
click node_worker_pool "https://github.com/devravik/go-license-api/blob/main/internal/worker/pool.go"
click node_worker "https://github.com/devravik/go-license-api/blob/main/internal/worker/worker.go"
click node_signed_license "https://github.com/devravik/go-license-api/blob/main/internal/http/handlers/signed_license_handler.go"
click node_admin_service "https://github.com/devravik/go-license-api/blob/main/internal/app/admin_service.go"
click node_tenant_api "https://github.com/devravik/go-license-api/blob/main/internal/http/tenant/handler.go"
click node_postgres "https://github.com/devravik/go-license-api/blob/main/internal/infrastructure/db/postgres.go"
click node_license_cache "https://github.com/devravik/go-license-api/blob/main/internal/infrastructure/cache/license_store.go"
click node_redis "https://github.com/devravik/go-license-api/blob/main/internal/infrastructure/cache/l2_redis.go"
click node_audit "https://github.com/devravik/go-license-api/blob/main/internal/infrastructure/audit/worker.go"
click node_webhooks "https://github.com/devravik/go-license-api/blob/main/internal/webhook/dispatcher.go"
click node_signing "https://github.com/devravik/go-license-api/blob/main/internal/security/signer.go"

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_router,node_license_handler,node_activation_handler,node_admin_handler,node_middleware,node_client toneBlue
class node_validation,node_activation,node_worker_pool,node_worker,node_signed_license toneAmber
class node_admin_service,node_tenant_api toneMint
class node_postgres,node_license_cache,node_redis,node_audit,node_webhooks,node_signing toneRose
```

## Components

### HTTP API

- [Route Setup](https://github.com/devravik/go-license-api/blob/main/internal/http/router.go): `internal/http/router.go`
- [License Handler](https://github.com/devravik/go-license-api/blob/main/internal/http/license/handler.go): `internal/http/license/handler.go`
- [Activation Handler](https://github.com/devravik/go-license-api/blob/main/internal/http/handlers/activation_handler.go): `internal/http/handlers/activation_handler.go`
- [Admin Handler](https://github.com/devravik/go-license-api/blob/main/internal/http/admin/handler.go): `internal/http/admin/handler.go`
- [Request Guards](https://github.com/devravik/go-license-api/tree/main/internal/http/middleware): `internal/http/middleware`

### Validation Runtime

- [License Validation](https://github.com/devravik/go-license-api/blob/main/internal/app/validation_service.go): `internal/app/validation_service.go`
- [Activation Service](https://github.com/devravik/go-license-api/blob/main/internal/app/activation_service.go): `internal/app/activation_service.go`
- [Worker Pool](https://github.com/devravik/go-license-api/blob/main/internal/worker/pool.go): `internal/worker/pool.go`
- [Validation Worker](https://github.com/devravik/go-license-api/blob/main/internal/worker/worker.go): `internal/worker/worker.go`
- [Offline Licenses](https://github.com/devravik/go-license-api/blob/main/internal/http/handlers/signed_license_handler.go): `internal/http/handlers/signed_license_handler.go`

### Control Plane

- [Admin Services](https://github.com/devravik/go-license-api/blob/main/internal/app/admin_service.go): `internal/app/admin_service.go`
- [Tenant API](https://github.com/devravik/go-license-api/blob/main/internal/http/tenant/handler.go): `internal/http/tenant/handler.go`

### Infrastructure

- [PostgreSQL](https://github.com/devravik/go-license-api/blob/main/internal/infrastructure/db/postgres.go): `internal/infrastructure/db/postgres.go`
- [License Cache](https://github.com/devravik/go-license-api/blob/main/internal/infrastructure/cache/license_store.go): `internal/infrastructure/cache/license_store.go`
- [Redis L2 Cache](https://github.com/devravik/go-license-api/blob/main/internal/infrastructure/cache/l2_redis.go): `internal/infrastructure/cache/l2_redis.go`
- [Audit Pipeline](https://github.com/devravik/go-license-api/blob/main/internal/infrastructure/audit/worker.go): `internal/infrastructure/audit/worker.go`
- [Webhook Delivery](https://github.com/devravik/go-license-api/blob/main/internal/webhook/dispatcher.go): `internal/webhook/dispatcher.go`
- [License Signing](https://github.com/devravik/go-license-api/blob/main/internal/security/signer.go): `internal/security/signer.go`

### Other components

- **License Client**

## Connections

- License Client → Route Setup: sends request
- Route Setup → Request Guards: applies guards (evidence: `internal/http/router.go`)
- Route Setup → License Handler: routes validation (evidence: `internal/http/router.go`)
- License Handler → Worker Pool: submits validation
- Worker Pool → Validation Worker: dispatches jobs (evidence: `internal/worker/worker.go`)
- Validation Worker → License Validation: executes validation (evidence: `internal/worker/worker.go`)
- License Validation → License Cache: checks cache
- License Cache → Redis L2 Cache: checks L2
- License Handler → Activation Handler: serves activation routes
- Activation Handler → Activation Service: handles activation (evidence: `internal/http/handlers/activation_handler.go`)
- Route Setup → Admin Handler: routes admin requests (evidence: `internal/http/router.go`)
- Admin Handler → Admin Services: invokes management (evidence: `internal/http/admin/handler.go`)
- Route Setup → Tenant API: routes tenant requests (evidence: `internal/http/router.go`)
- Admin Services → PostgreSQL: persists changes
- Admin Services → License Cache: updates cache (evidence: `internal/app/admin_service.go`)
- License Validation → Audit Pipeline: records events
- Admin Handler → Webhook Delivery: registers callbacks
- License Client → Offline Licenses: verifies offline
- Offline Licenses → License Signing: verifies signature
