# rezarg-dev/redeliver architecture

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

- Interactive diagram: https://gitdiagram.com/rezarg-dev/redeliver
- Repository: https://github.com/rezarg-dev/redeliver

## Overview

redeliver is a self-hosted webhook relay. Senders submit signed webhooks; ingest verifies and deduplicates them, stores each event with destination deliveries, and returns promptly. A background worker sends deliveries, records attempts, and retries failures; administrators can manage sources and destinations, inspect or replay events and deliveries, and monitor health and metrics. The graph follows the documented workflow and sampled wiring; unsampled route and store internals are represented only where the README or source index supports them.

Main entry points: [`src/app.js`](https://github.com/rezarg-dev/redeliver/blob/main/src/app.js) (HTTP application), [`src/routes/ingest.js`](https://github.com/rezarg-dev/redeliver/blob/main/src/routes/ingest.js) (Webhook ingest), [`src/server.js`](https://github.com/rezarg-dev/redeliver/blob/main/src/server.js) (Server bootstrap), [`src/worker.js`](https://github.com/rezarg-dev/redeliver/blob/main/src/worker.js) (Delivery worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime setup"]
  node_server["Server bootstrap<br/>[server.js]"]
  node_config["Runtime config<br/>[config.js]"]
  node_app["HTTP application<br/>[app.js]"]
  node_db[("SQLite database<br/>[db.js]")]
  node_store["Store factory<br/>[index.js]"]
end

subgraph group_ingest["Webhook intake"]
  node_ingest_route["Webhook ingest<br/>[ingest.js]"]
  node_signature["Signature verification<br/>[signature.js]"]
  node_event_store["Event records<br/>[events.js]"]
  node_source_store["Source records<br/>[sources.js]"]
  node_destination_store["Destination records<br/>[destinations.js]"]
end

subgraph group_delivery["Delivery processing"]
  node_delivery_store["Delivery queue and history<br/>[deliveries.js]"]
  node_worker["Delivery worker<br/>[worker.js]"]
  node_backoff["Retry scheduling<br/>[backoff.js]"]
end

subgraph group_admin["Administration and observability"]
  node_source_routes["Source management<br/>[sources.js]"]
  node_destination_routes["Destination management<br/>[destinations.js]"]
  node_event_routes["Event inspection and replay<br/>[events.js]"]
  node_delivery_routes["Delivery inspection and retry<br/>[deliveries.js]"]
  node_pagination["Page utilities<br/>[pagination.js]"]
  node_metrics["Prometheus metrics<br/>[metrics.js]"]
  node_metrics_route["Metrics endpoint<br/>[metrics.js]"]
  node_health_route["Health endpoint<br/>[health.js]"]
end

node_sender(("Webhook sender"))
node_destination(("Webhook destinations"))

node_server -->|"loads config"| node_config
node_server -->|"opens database"| node_db
node_server -->|"creates store"| node_store
node_server -->|"creates metrics"| node_metrics
node_server -->|"builds app"| node_app
node_server -->|"starts worker"| node_worker
node_store -->|"uses database"| node_db
node_app -->|"registers route"| node_ingest_route
node_app -->|"registers route"| node_source_routes
node_app -->|"registers route"| node_destination_routes
node_app -->|"registers route"| node_event_routes
node_app -->|"registers route"| node_delivery_routes
node_app -->|"registers route"| node_metrics_route
node_app -->|"registers route"| node_health_route
node_sender -->|"submits webhook"| node_ingest_route
node_ingest_route -->|"verifies signature"| node_signature
node_ingest_route -->|"looks up source"| node_source_store
node_ingest_route -->|"stores event"| node_event_store
node_ingest_route -->|"lists enabled destinations"| node_destination_store
node_ingest_route -->|"enqueues deliveries"| node_delivery_store
node_ingest_route -->|"writes atomically"| node_db
node_worker -->|"claims and updates"| node_delivery_store
node_worker -->|"calculates retry delay"| node_backoff
node_worker -->|"sends webhook"| node_destination
node_event_routes -->|"replays event"| node_delivery_routes
node_delivery_routes -->|"paginates results"| node_pagination
node_metrics_route -->|"exposes metrics"| node_metrics
node_health_route -->|"checks health"| node_store

click node_server "https://github.com/rezarg-dev/redeliver/blob/main/src/server.js"
click node_config "https://github.com/rezarg-dev/redeliver/blob/main/src/config.js"
click node_app "https://github.com/rezarg-dev/redeliver/blob/main/src/app.js"
click node_db "https://github.com/rezarg-dev/redeliver/blob/main/src/db.js"
click node_store "https://github.com/rezarg-dev/redeliver/blob/main/src/store/index.js"
click node_ingest_route "https://github.com/rezarg-dev/redeliver/blob/main/src/routes/ingest.js"
click node_signature "https://github.com/rezarg-dev/redeliver/blob/main/src/signature.js"
click node_event_store "https://github.com/rezarg-dev/redeliver/blob/main/src/store/events.js"
click node_source_store "https://github.com/rezarg-dev/redeliver/blob/main/src/store/sources.js"
click node_destination_store "https://github.com/rezarg-dev/redeliver/blob/main/src/store/destinations.js"
click node_delivery_store "https://github.com/rezarg-dev/redeliver/blob/main/src/store/deliveries.js"
click node_worker "https://github.com/rezarg-dev/redeliver/blob/main/src/worker.js"
click node_backoff "https://github.com/rezarg-dev/redeliver/blob/main/src/backoff.js"
click node_source_routes "https://github.com/rezarg-dev/redeliver/blob/main/src/routes/sources.js"
click node_destination_routes "https://github.com/rezarg-dev/redeliver/blob/main/src/routes/destinations.js"
click node_event_routes "https://github.com/rezarg-dev/redeliver/blob/main/src/routes/events.js"
click node_delivery_routes "https://github.com/rezarg-dev/redeliver/blob/main/src/routes/deliveries.js"
click node_pagination "https://github.com/rezarg-dev/redeliver/blob/main/src/pagination.js"
click node_metrics "https://github.com/rezarg-dev/redeliver/blob/main/src/metrics.js"
click node_metrics_route "https://github.com/rezarg-dev/redeliver/blob/main/src/routes/metrics.js"
click node_health_route "https://github.com/rezarg-dev/redeliver/blob/main/src/routes/health.js"

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_server,node_config,node_app,node_db,node_store toneBlue
class node_ingest_route,node_signature,node_event_store,node_source_store,node_destination_store toneAmber
class node_delivery_store,node_worker,node_backoff,node_sender,node_destination toneMint
class node_source_routes,node_destination_routes,node_event_routes,node_delivery_routes,node_pagination,node_metrics,node_metrics_route,node_health_route toneRose
```

## Components

### Runtime setup

- [Server bootstrap](https://github.com/rezarg-dev/redeliver/blob/main/src/server.js): `src/server.js`
- [Runtime config](https://github.com/rezarg-dev/redeliver/blob/main/src/config.js): `src/config.js`
- [HTTP application](https://github.com/rezarg-dev/redeliver/blob/main/src/app.js): `src/app.js`
- [SQLite database](https://github.com/rezarg-dev/redeliver/blob/main/src/db.js): `src/db.js`
- [Store factory](https://github.com/rezarg-dev/redeliver/blob/main/src/store/index.js): `src/store/index.js`

### Webhook intake

- [Webhook ingest](https://github.com/rezarg-dev/redeliver/blob/main/src/routes/ingest.js): `src/routes/ingest.js`
- [Signature verification](https://github.com/rezarg-dev/redeliver/blob/main/src/signature.js): `src/signature.js`
- [Event records](https://github.com/rezarg-dev/redeliver/blob/main/src/store/events.js): `src/store/events.js`
- [Source records](https://github.com/rezarg-dev/redeliver/blob/main/src/store/sources.js): `src/store/sources.js`
- [Destination records](https://github.com/rezarg-dev/redeliver/blob/main/src/store/destinations.js): `src/store/destinations.js`

### Delivery processing

- [Delivery queue and history](https://github.com/rezarg-dev/redeliver/blob/main/src/store/deliveries.js): `src/store/deliveries.js`
- [Delivery worker](https://github.com/rezarg-dev/redeliver/blob/main/src/worker.js): `src/worker.js`
- [Retry scheduling](https://github.com/rezarg-dev/redeliver/blob/main/src/backoff.js): `src/backoff.js`

### Administration and observability

- [Source management](https://github.com/rezarg-dev/redeliver/blob/main/src/routes/sources.js): `src/routes/sources.js`
- [Destination management](https://github.com/rezarg-dev/redeliver/blob/main/src/routes/destinations.js): `src/routes/destinations.js`
- [Event inspection and replay](https://github.com/rezarg-dev/redeliver/blob/main/src/routes/events.js): `src/routes/events.js`
- [Delivery inspection and retry](https://github.com/rezarg-dev/redeliver/blob/main/src/routes/deliveries.js): `src/routes/deliveries.js`
- [Page utilities](https://github.com/rezarg-dev/redeliver/blob/main/src/pagination.js): `src/pagination.js`
- [Prometheus metrics](https://github.com/rezarg-dev/redeliver/blob/main/src/metrics.js): `src/metrics.js`
- [Metrics endpoint](https://github.com/rezarg-dev/redeliver/blob/main/src/routes/metrics.js): `src/routes/metrics.js`
- [Health endpoint](https://github.com/rezarg-dev/redeliver/blob/main/src/routes/health.js): `src/routes/health.js`

### Other components

- **Webhook sender**
- **Webhook destinations**

## Connections

- Server bootstrap → Runtime config: loads config (evidence: `src/server.js`)
- Server bootstrap → SQLite database: opens database (evidence: `src/server.js`)
- Server bootstrap → Store factory: creates store (evidence: `src/server.js`)
- Server bootstrap → Prometheus metrics: creates metrics (evidence: `src/server.js`)
- Server bootstrap → HTTP application: builds app (evidence: `src/server.js`)
- Server bootstrap → Delivery worker: starts worker (evidence: `src/server.js`)
- Store factory → SQLite database: uses database (evidence: `src/store/index.js`)
- HTTP application → Webhook ingest: registers route (evidence: `src/app.js`)
- HTTP application → Source management: registers route (evidence: `src/app.js`)
- HTTP application → Destination management: registers route (evidence: `src/app.js`)
- HTTP application → Event inspection and replay: registers route (evidence: `src/app.js`)
- HTTP application → Delivery inspection and retry: registers route (evidence: `src/app.js`)
- HTTP application → Metrics endpoint: registers route (evidence: `src/app.js`)
- HTTP application → Health endpoint: registers route (evidence: `src/app.js`)
- Webhook sender → Webhook ingest: submits webhook (evidence: `README.md`)
- Webhook ingest → Signature verification: verifies signature (evidence: `src/routes/ingest.js`)
- Webhook ingest → Source records: looks up source (evidence: `src/routes/ingest.js`)
- Webhook ingest → Event records: stores event (evidence: `README.md`)
- Webhook ingest → Destination records: lists enabled destinations (evidence: `src/routes/ingest.js`)
- Webhook ingest → Delivery queue and history: enqueues deliveries (evidence: `src/routes/ingest.js`)
- Webhook ingest → SQLite database: writes atomically (evidence: `src/routes/ingest.js`)
- Delivery worker → Delivery queue and history: claims and updates (evidence: `src/worker.js`)
- Delivery worker → Retry scheduling: calculates retry delay (evidence: `src/worker.js`)
- Delivery worker → Webhook destinations: sends webhook (evidence: `README.md`)
- Event inspection and replay → Delivery inspection and retry: replays event (evidence: `README.md`)
- Delivery inspection and retry → Page utilities: paginates results (evidence: `src/routes/deliveries.js`)
- Metrics endpoint → Prometheus metrics: exposes metrics (evidence: `README.md`)
- Health endpoint → Store factory: checks health (evidence: `README.md`)
