# eziokwuche/webhook-relay architecture

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

- Interactive diagram: https://gitdiagram.com/eziokwuche/webhook-relay
- Repository: https://github.com/eziokwuche/webhook-relay

## Overview

Webhook Relay accepts and validates webhook submissions, persists them as pending events, and asynchronously forwards them with bounded concurrency and retry/backoff handling. The same API also exposes health, event listing, lookup, and aggregate statistics. Source excerpts show the server wiring and runtime calls; the SQL schema and any additional implementation details were not excerpted.

Main entry points: [`internal/db/repository.go`](https://github.com/eziokwuche/webhook-relay/blob/main/internal/db/repository.go) (Event Repository), [`cmd/server/main.go`](https://github.com/eziokwuche/webhook-relay/blob/main/cmd/server/main.go) (Server Bootstrap), [`internal/worker/relay.go`](https://github.com/eziokwuche/webhook-relay/blob/main/internal/worker/relay.go) (Relay Worker), [`internal/api/routes.go`](https://github.com/eziokwuche/webhook-relay/blob/main/internal/api/routes.go) (HTTP Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_router["HTTP Routes<br/>[routes.go]"]
  node_handlers["API Handlers<br/>[handlers.go]"]
end

subgraph group_delivery["Async Delivery"]
  node_worker["Relay Worker<br/>[relay.go]"]
end

subgraph group_persistence["Persistence"]
  node_repository["Event Repository<br/>[repository.go]"]
  node_postgres[("PostgreSQL Events<br/>[schema.sql]")]
  node_event["Webhook Event Model<br/>[event.go]"]
end

subgraph group_runtime["Runtime"]
  node_server["Server Bootstrap<br/>[main.go]"]
end

node_sender(("Webhook Sender"))
node_target(("Webhook Target"))

node_sender -->|"sends requests"| node_router
node_server -->|"creates"| node_repository
node_server -->|"starts"| node_worker
node_server -->|"serves"| node_router
node_router -->|"routes requests"| node_handlers
node_handlers -->|"reads and writes"| node_repository
node_repository -->|"queries and updates"| node_postgres
node_repository -->|"maps rows"| node_event
node_worker -->|"polls and updates"| node_repository
node_worker -->|"POSTs payload"| node_target

click node_router "https://github.com/eziokwuche/webhook-relay/blob/main/internal/api/routes.go"
click node_handlers "https://github.com/eziokwuche/webhook-relay/blob/main/internal/api/handlers.go"
click node_server "https://github.com/eziokwuche/webhook-relay/blob/main/cmd/server/main.go"
click node_worker "https://github.com/eziokwuche/webhook-relay/blob/main/internal/worker/relay.go"
click node_repository "https://github.com/eziokwuche/webhook-relay/blob/main/internal/db/repository.go"
click node_postgres "https://github.com/eziokwuche/webhook-relay/blob/main/sql/schema.sql"
click node_event "https://github.com/eziokwuche/webhook-relay/blob/main/internal/models/event.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_handlers toneBlue
class node_worker toneAmber
class node_repository,node_postgres,node_event,node_sender,node_target toneMint
class node_server toneRose
```

## Components

### HTTP API

- [HTTP Routes](https://github.com/eziokwuche/webhook-relay/blob/main/internal/api/routes.go): `internal/api/routes.go`
- [API Handlers](https://github.com/eziokwuche/webhook-relay/blob/main/internal/api/handlers.go): `internal/api/handlers.go`

### Async Delivery

- [Relay Worker](https://github.com/eziokwuche/webhook-relay/blob/main/internal/worker/relay.go): `internal/worker/relay.go`

### Persistence

- [Event Repository](https://github.com/eziokwuche/webhook-relay/blob/main/internal/db/repository.go): `internal/db/repository.go`
- [PostgreSQL Events](https://github.com/eziokwuche/webhook-relay/blob/main/sql/schema.sql): `sql/schema.sql`
- [Webhook Event Model](https://github.com/eziokwuche/webhook-relay/blob/main/internal/models/event.go): `internal/models/event.go`

### Runtime

- [Server Bootstrap](https://github.com/eziokwuche/webhook-relay/blob/main/cmd/server/main.go): `cmd/server/main.go`

### Other components

- **Webhook Sender**
- **Webhook Target**

## Connections

- Webhook Sender → HTTP Routes: sends requests (evidence: `README.md`)
- Server Bootstrap → Event Repository: creates (evidence: `cmd/server/main.go`)
- Server Bootstrap → Relay Worker: starts (evidence: `cmd/server/main.go`)
- Server Bootstrap → HTTP Routes: serves (evidence: `cmd/server/main.go`)
- HTTP Routes → API Handlers: routes requests (evidence: `internal/api/routes.go`)
- API Handlers → Event Repository: reads and writes (evidence: `internal/api/handlers.go`)
- Event Repository → PostgreSQL Events: queries and updates (evidence: `internal/db/repository.go`)
- Event Repository → Webhook Event Model: maps rows (evidence: `internal/db/repository.go`)
- Relay Worker → Event Repository: polls and updates (evidence: `internal/worker/relay.go`)
- Relay Worker → Webhook Target: POSTs payload (evidence: `README.md`)
