# prajexec/hookforge architecture

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

- Interactive diagram: https://gitdiagram.com/prajexec/hookforge
- Repository: https://github.com/prajexec/hookforge

## Overview

HookForge is a webhook platform: users manage tenant-scoped projects and endpoints, ingest events, then inspect and control asynchronous signed deliveries. The map includes the dashboard, API domain routes, durable PostgreSQL state, worker dispatch and retry, security, and the mock receiver. README-described capabilities are retained where the tree supports them; source excerpts are partial, so some subsystem links are documented rather than verified in sampled implementation.

Main entry points: [`apps/api/src/app.ts`](https://github.com/prajexec/hookforge/blob/main/apps/api/src/app.ts) (Fastify API), [`apps/api/src/store.ts`](https://github.com/prajexec/hookforge/blob/main/apps/api/src/store.ts) (Domain persistence), [`apps/api/src/routes/endpoints.ts`](https://github.com/prajexec/hookforge/blob/main/apps/api/src/routes/endpoints.ts) (Endpoint lifecycle), [`apps/worker/src/delivery.ts`](https://github.com/prajexec/hookforge/blob/main/apps/worker/src/delivery.ts) (Delivery execution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Dashboard"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
  node_endpoint_ui["Endpoint controls<br/>[EndpointsPanel.tsx]"]
  node_sandbox_ui["Sandbox panel<br/>[SandboxPanel.tsx]"]
  node_web_api["API client<br/>[api.ts]"]
end

subgraph group_api["API and domain"]
  node_api_app["Fastify API<br/>[app.ts]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_projects["Project management<br/>[projects.ts]"]
  node_endpoints["Endpoint lifecycle<br/>[endpoints.ts]"]
  node_ingestion["Event ingestion<br/>[events.ts]"]
  node_delivery_ops["Delivery operations<br/>[deliveries.ts]"]
  node_alerts["Alert routing<br/>[alerts.ts]"]
  node_sandbox["Sandbox API<br/>[sandbox.ts]"]
end

subgraph group_security["Security"]
  node_crypto["Secret cryptography<br/>[crypto.ts]"]
  node_envelope["Envelope encryption<br/>[envelope.ts]"]
  node_url_policy["URL validation<br/>[url.ts]"]
end

subgraph group_delivery["Delivery worker"]
  node_worker_loop["Worker loop<br/>[worker.ts]"]
  node_delivery_logic["Delivery execution<br/>[delivery.ts]"]
  node_worker_store[("Leases and attempts<br/>[delivery-store.ts]")]
  node_network["Pinned networking<br/>[network.ts]"]
  node_http_client["HTTP client<br/>[http-client.ts]"]
  node_retry["Retry policy<br/>[retry.ts]"]
end

subgraph group_runtime["State and operations"]
  node_api_store[("Domain persistence<br/>[store.ts]")]
  node_rate_limit["Rate limiting<br/>[rate-limit.ts]"]
  node_observability["Metrics and telemetry<br/>[metrics.ts]"]
  node_receiver["Mock receiver<br/>[server.ts]"]
  node_receiver_store[("Captured requests<br/>[store.ts]")]
end

node_user(("Platform user"))
node_postgres[("PostgreSQL")]
node_redis[("Redis")]
node_vault["Vault Transit"]

node_user -->|"uses"| node_dashboard
node_dashboard -->|"requests"| node_web_api
node_endpoint_ui -->|"requests"| node_web_api
node_sandbox_ui -->|"requests"| node_web_api
node_web_api -->|"calls API"| node_api_app
node_api_app -->|"registers"| node_auth
node_api_app -->|"registers"| node_projects
node_api_app -->|"registers"| node_endpoints
node_api_app -->|"registers"| node_ingestion
node_api_app -->|"registers"| node_delivery_ops
node_api_app -->|"registers"| node_alerts
node_api_app -->|"registers"| node_sandbox
node_auth -->|"reads and writes"| node_api_store
node_auth -->|"hashes credentials"| node_crypto
node_auth -->|"enforces limits"| node_rate_limit
node_projects -.->|"manages projects"| node_api_store
node_endpoints -->|"manages endpoints"| node_api_store
node_endpoints -->|"creates secrets"| node_crypto
node_endpoints -->|"encrypts secrets"| node_envelope
node_endpoints -->|"validates URLs"| node_url_policy
node_ingestion -->|"persists events"| node_api_store
node_ingestion -.->|"enforces limits"| node_rate_limit
node_delivery_ops -->|"inspects and controls"| node_api_store
node_alerts -.->|"routes alerts"| node_api_store
node_sandbox -->|"manages sandbox"| node_api_store
node_sandbox -.->|"creates secrets"| node_crypto
node_api_store -->|"stores domain data"| node_postgres
node_rate_limit -.->|"stores quotas"| node_redis
node_endpoints -.->|"wraps data keys"| node_vault
node_worker_loop -->|"claims and records"| node_worker_store
node_worker_loop -->|"dispatches jobs"| node_delivery_logic
node_worker_loop -->|"schedules retries"| node_retry
node_delivery_logic -->|"resolves target"| node_network
node_delivery_logic -->|"sends request"| node_http_client
node_delivery_logic -->|"classifies failures"| node_retry
node_worker_store -->|"leases and records"| node_postgres
node_delivery_logic -->|"delivers webhook"| node_receiver
node_receiver -->|"captures requests"| node_receiver_store
node_receiver_store -.->|"shows captured requests"| node_user

click node_dashboard "https://github.com/prajexec/hookforge/blob/main/apps/web/src/Dashboard.tsx"
click node_endpoint_ui "https://github.com/prajexec/hookforge/blob/main/apps/web/src/EndpointsPanel.tsx"
click node_sandbox_ui "https://github.com/prajexec/hookforge/blob/main/apps/web/src/SandboxPanel.tsx"
click node_web_api "https://github.com/prajexec/hookforge/blob/main/apps/web/src/api.ts"
click node_api_app "https://github.com/prajexec/hookforge/blob/main/apps/api/src/app.ts"
click node_auth "https://github.com/prajexec/hookforge/blob/main/apps/api/src/routes/auth.ts"
click node_projects "https://github.com/prajexec/hookforge/blob/main/apps/api/src/routes/projects.ts"
click node_endpoints "https://github.com/prajexec/hookforge/blob/main/apps/api/src/routes/endpoints.ts"
click node_ingestion "https://github.com/prajexec/hookforge/blob/main/apps/api/src/routes/events.ts"
click node_delivery_ops "https://github.com/prajexec/hookforge/blob/main/apps/api/src/routes/deliveries.ts"
click node_alerts "https://github.com/prajexec/hookforge/blob/main/apps/api/src/routes/alerts.ts"
click node_sandbox "https://github.com/prajexec/hookforge/blob/main/apps/api/src/routes/sandbox.ts"
click node_crypto "https://github.com/prajexec/hookforge/blob/main/apps/api/src/security/crypto.ts"
click node_envelope "https://github.com/prajexec/hookforge/blob/main/apps/api/src/security/envelope.ts"
click node_url_policy "https://github.com/prajexec/hookforge/blob/main/apps/api/src/security/url.ts"
click node_api_store "https://github.com/prajexec/hookforge/blob/main/apps/api/src/store.ts"
click node_rate_limit "https://github.com/prajexec/hookforge/blob/main/apps/api/src/rate-limit.ts"
click node_observability "https://github.com/prajexec/hookforge/blob/main/apps/api/src/metrics.ts"
click node_worker_loop "https://github.com/prajexec/hookforge/blob/main/apps/worker/src/worker.ts"
click node_delivery_logic "https://github.com/prajexec/hookforge/blob/main/apps/worker/src/delivery.ts"
click node_worker_store "https://github.com/prajexec/hookforge/blob/main/apps/worker/src/delivery-store.ts"
click node_network "https://github.com/prajexec/hookforge/blob/main/apps/worker/src/network.ts"
click node_http_client "https://github.com/prajexec/hookforge/blob/main/apps/worker/src/http-client.ts"
click node_retry "https://github.com/prajexec/hookforge/blob/main/apps/worker/src/retry.ts"
click node_receiver "https://github.com/prajexec/hookforge/blob/main/apps/mock-receiver/src/server.ts"
click node_receiver_store "https://github.com/prajexec/hookforge/blob/main/apps/mock-receiver/src/store.ts"

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_dashboard,node_endpoint_ui,node_sandbox_ui,node_web_api,node_user toneBlue
class node_api_app,node_auth,node_projects,node_endpoints,node_ingestion,node_delivery_ops,node_alerts,node_sandbox,node_postgres,node_redis toneAmber
class node_crypto,node_envelope,node_url_policy toneMint
class node_worker_loop,node_delivery_logic,node_worker_store,node_network,node_http_client,node_retry toneRose
class node_api_store,node_rate_limit,node_observability,node_receiver,node_receiver_store,node_vault toneIndigo
```

## Components

### Dashboard

- [Dashboard](https://github.com/prajexec/hookforge/blob/main/apps/web/src/Dashboard.tsx): `apps/web/src/Dashboard.tsx`
- [Endpoint controls](https://github.com/prajexec/hookforge/blob/main/apps/web/src/EndpointsPanel.tsx): `apps/web/src/EndpointsPanel.tsx`
- [Sandbox panel](https://github.com/prajexec/hookforge/blob/main/apps/web/src/SandboxPanel.tsx): `apps/web/src/SandboxPanel.tsx`
- [API client](https://github.com/prajexec/hookforge/blob/main/apps/web/src/api.ts): `apps/web/src/api.ts`

### API and domain

- [Fastify API](https://github.com/prajexec/hookforge/blob/main/apps/api/src/app.ts): `apps/api/src/app.ts`
- [Authentication](https://github.com/prajexec/hookforge/blob/main/apps/api/src/routes/auth.ts): `apps/api/src/routes/auth.ts`
- [Project management](https://github.com/prajexec/hookforge/blob/main/apps/api/src/routes/projects.ts): `apps/api/src/routes/projects.ts`
- [Endpoint lifecycle](https://github.com/prajexec/hookforge/blob/main/apps/api/src/routes/endpoints.ts): `apps/api/src/routes/endpoints.ts`
- [Event ingestion](https://github.com/prajexec/hookforge/blob/main/apps/api/src/routes/events.ts): `apps/api/src/routes/events.ts`
- [Delivery operations](https://github.com/prajexec/hookforge/blob/main/apps/api/src/routes/deliveries.ts): `apps/api/src/routes/deliveries.ts`
- [Alert routing](https://github.com/prajexec/hookforge/blob/main/apps/api/src/routes/alerts.ts): `apps/api/src/routes/alerts.ts`
- [Sandbox API](https://github.com/prajexec/hookforge/blob/main/apps/api/src/routes/sandbox.ts): `apps/api/src/routes/sandbox.ts`

### Security

- [Secret cryptography](https://github.com/prajexec/hookforge/blob/main/apps/api/src/security/crypto.ts): `apps/api/src/security/crypto.ts`
- [Envelope encryption](https://github.com/prajexec/hookforge/blob/main/apps/api/src/security/envelope.ts): `apps/api/src/security/envelope.ts`
- [URL validation](https://github.com/prajexec/hookforge/blob/main/apps/api/src/security/url.ts): `apps/api/src/security/url.ts`

### Delivery worker

- [Worker loop](https://github.com/prajexec/hookforge/blob/main/apps/worker/src/worker.ts): `apps/worker/src/worker.ts`
- [Delivery execution](https://github.com/prajexec/hookforge/blob/main/apps/worker/src/delivery.ts): `apps/worker/src/delivery.ts`
- [Leases and attempts](https://github.com/prajexec/hookforge/blob/main/apps/worker/src/delivery-store.ts): `apps/worker/src/delivery-store.ts`
- [Pinned networking](https://github.com/prajexec/hookforge/blob/main/apps/worker/src/network.ts): `apps/worker/src/network.ts`
- [HTTP client](https://github.com/prajexec/hookforge/blob/main/apps/worker/src/http-client.ts): `apps/worker/src/http-client.ts`
- [Retry policy](https://github.com/prajexec/hookforge/blob/main/apps/worker/src/retry.ts): `apps/worker/src/retry.ts`

### State and operations

- [Domain persistence](https://github.com/prajexec/hookforge/blob/main/apps/api/src/store.ts): `apps/api/src/store.ts`
- [Rate limiting](https://github.com/prajexec/hookforge/blob/main/apps/api/src/rate-limit.ts): `apps/api/src/rate-limit.ts`
- [Metrics and telemetry](https://github.com/prajexec/hookforge/blob/main/apps/api/src/metrics.ts): `apps/api/src/metrics.ts`
- [Mock receiver](https://github.com/prajexec/hookforge/blob/main/apps/mock-receiver/src/server.ts): `apps/mock-receiver/src/server.ts`
- [Captured requests](https://github.com/prajexec/hookforge/blob/main/apps/mock-receiver/src/store.ts): `apps/mock-receiver/src/store.ts`

### Other components

- **Platform user**
- **PostgreSQL**
- **Redis**
- **Vault Transit**

## Connections

- Platform user → Dashboard: uses
- Dashboard → API client: requests (evidence: `apps/web/src/Dashboard.tsx`)
- Endpoint controls → API client: requests (evidence: `apps/web/src/EndpointsPanel.tsx`)
- Sandbox panel → API client: requests (evidence: `apps/web/src/SandboxPanel.tsx`)
- API client → Fastify API: calls API (evidence: `apps/web/src/api.ts`)
- Fastify API → Authentication: registers (evidence: `apps/api/src/app.ts`)
- Fastify API → Project management: registers (evidence: `apps/api/src/app.ts`)
- Fastify API → Endpoint lifecycle: registers (evidence: `apps/api/src/app.ts`)
- Fastify API → Event ingestion: registers (evidence: `apps/api/src/app.ts`)
- Fastify API → Delivery operations: registers (evidence: `apps/api/src/app.ts`)
- Fastify API → Alert routing: registers (evidence: `apps/api/src/app.ts`)
- Fastify API → Sandbox API: registers (evidence: `apps/api/src/app.ts`)
- Authentication → Domain persistence: reads and writes (evidence: `apps/api/src/routes/auth.ts`)
- Authentication → Secret cryptography: hashes credentials (evidence: `apps/api/src/routes/auth.ts`)
- Authentication → Rate limiting: enforces limits (evidence: `apps/api/src/routes/auth.ts`)
- Project management → Domain persistence: manages projects
- Endpoint lifecycle → Domain persistence: manages endpoints (evidence: `apps/api/src/routes/endpoints.ts`)
- Endpoint lifecycle → Secret cryptography: creates secrets (evidence: `apps/api/src/routes/endpoints.ts`)
- Endpoint lifecycle → Envelope encryption: encrypts secrets (evidence: `apps/api/src/routes/endpoints.ts`)
- Endpoint lifecycle → URL validation: validates URLs (evidence: `apps/api/src/routes/endpoints.ts`)
- Event ingestion → Domain persistence: persists events (evidence: `apps/api/src/routes/events.ts`)
- Event ingestion → Rate limiting: enforces limits (evidence: `apps/api/src/routes/events.ts`)
- Delivery operations → Domain persistence: inspects and controls (evidence: `apps/api/src/routes/deliveries.ts`)
- Alert routing → Domain persistence: routes alerts
- Sandbox API → Domain persistence: manages sandbox (evidence: `apps/api/src/routes/sandbox.ts`)
- Sandbox API → Secret cryptography: creates secrets (evidence: `apps/api/src/routes/sandbox.ts`)
- Domain persistence → PostgreSQL: stores domain data
- Rate limiting → Redis: stores quotas
- Endpoint lifecycle → Vault Transit: wraps data keys
- Worker loop → Leases and attempts: claims and records (evidence: `apps/worker/src/worker.ts`)
- Worker loop → Delivery execution: dispatches jobs (evidence: `apps/worker/src/worker.ts`)
- Worker loop → Retry policy: schedules retries (evidence: `apps/worker/src/worker.ts`)
- Delivery execution → Pinned networking: resolves target (evidence: `apps/worker/src/delivery.ts`)
- Delivery execution → HTTP client: sends request (evidence: `apps/worker/src/delivery.ts`)
- Delivery execution → Retry policy: classifies failures (evidence: `apps/worker/src/delivery.ts`)
- Leases and attempts → PostgreSQL: leases and records
- Delivery execution → Mock receiver: delivers webhook
- Mock receiver → Captured requests: captures requests (evidence: `apps/mock-receiver/src/server.ts`)
- Captured requests → Platform user: shows captured requests
