# nikola-golijanin/webhooks architecture

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

- Interactive diagram: https://gitdiagram.com/nikola-golijanin/webhooks
- Repository: https://github.com/nikola-golijanin/webhooks

## Overview

This repository implements an event-driven webhook service: clients register subscriptions or publish events through the API; the processing worker finds matching subscriptions, fans out delivery messages, sends HTTP POSTs to subscriber URLs, and records outcomes. The example Orders API also triggers an order-created event, and a test listener can receive and inspect deliveries. The README documents OpenTelemetry instrumentation across both services. Worker and dispatcher details are represented at their exact tree paths; their source was not sampled, so links follow the README’s described message flow.

Main entry points: [`Webhooks.Processing/Services/WebhookDispatchedConsumer.cs`](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Processing/Services/WebhookDispatchedConsumer.cs) (Match Subscriptions), [`Webhooks.Processing/Services/WebhookTriggeredConsumer.cs`](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Processing/Services/WebhookTriggeredConsumer.cs) (Send Delivery), [`Webhooks.API/Services/WebhookDispatcher.cs`](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.API/Services/WebhookDispatcher.cs) (Event Dispatcher), [`Webhooks.Processing/Data/WebhooksDbContext.cs`](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Processing/Data/WebhooksDbContext.cs) (Worker Data Context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and Orders"]
  node_api["REST API<br/>[Program.cs]"]
  node_webhooks["Webhook Endpoints"]
  node_orders["Orders API"]
  node_orderrepo["Order Repository"]
  node_dispatcher["Event Dispatcher"]
  node_apidata["API Data Context"]
end

subgraph group_processing["Webhook Processing"]
  node_worker["Processing Worker<br/>[Program.cs]"]
  node_dispatched["Match Subscriptions"]
  node_processingdata["Worker Data Context"]
  node_delivery["Send Delivery"]
  node_payload["Delivery Payload<br/>[WebhookPayload.cs]"]
end

subgraph group_messaging["Message Contracts"]
  node_contracts["Message Contracts"]
  node_triggeredcontract["Delivery Contract"]
end

subgraph group_observability["Observability"]
  node_apiotel["API Telemetry<br/>[Program.cs]"]
  node_workerotel["Worker Telemetry<br/>[Program.cs]"]
end

node_client(("API Client"))
node_database[("PostgreSQL")]
node_subscriber(("Subscriber URL"))
node_listener["Test Listener<br/>[Program.cs]"]
node_listenerstore[("Received Webhooks<br/>[WebhookStore.cs]")]
node_rabbitmq["RabbitMQ"]
node_otlp(("OTLP Backend"))

node_client -->|"manages and publishes"| node_webhooks
node_client -->|"creates orders"| node_orders
node_webhooks -->|"reads and writes"| node_apidata
node_apidata -->|"persists subscriptions"| node_database
node_webhooks -->|"dispatches event"| node_dispatcher
node_orders -->|"stores order"| node_orderrepo
node_orders -->|"dispatches event"| node_dispatcher
node_dispatcher -->|"creates message"| node_contracts
node_dispatcher -->|"publishes"| node_rabbitmq
node_rabbitmq -->|"delivers message"| node_dispatched
node_dispatched -->|"queries matches"| node_processingdata
node_processingdata -->|"reads subscriptions"| node_database
node_dispatched -->|"creates per match"| node_triggeredcontract
node_dispatched -->|"publishes"| node_rabbitmq
node_rabbitmq -->|"delivers message"| node_delivery
node_delivery -->|"builds payload"| node_payload
node_delivery -->|"posts payload"| node_subscriber
node_subscriber -.->|"example receiver"| node_listener
node_listener -->|"stores received"| node_listenerstore
node_delivery -->|"records attempt"| node_processingdata
node_processingdata -->|"writes attempt"| node_database
node_apiotel -->|"exports telemetry"| node_otlp
node_workerotel -->|"exports telemetry"| node_otlp

click node_api "https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.API/Program.cs"
click node_webhooks "https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.API/Controllers/WebhooksController.cs"
click node_orders "https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.API/Controllers/OrdersController.cs"
click node_orderrepo "https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.API/Repositories/InMemoryOrderRepository.cs"
click node_dispatcher "https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.API/Services/WebhookDispatcher.cs"
click node_apidata "https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.API/Data/WebhooksDbContext.cs"
click node_worker "https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Processing/Program.cs"
click node_dispatched "https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Processing/Services/WebhookDispatchedConsumer.cs"
click node_processingdata "https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Processing/Data/WebhooksDbContext.cs"
click node_delivery "https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Processing/Services/WebhookTriggeredConsumer.cs"
click node_payload "https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Processing/Services/WebhookPayload.cs"
click node_listener "https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.TestListener/Program.cs"
click node_listenerstore "https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.TestListener/WebhookStore.cs"
click node_contracts "https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Contracts/WebhookDispatched.cs"
click node_triggeredcontract "https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Contracts/WebhookTriggered.cs"
click node_apiotel "https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.API/Program.cs"
click node_workerotel "https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Processing/Program.cs"

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_api,node_webhooks,node_orders,node_orderrepo,node_dispatcher,node_apidata,node_client toneBlue
class node_worker,node_dispatched,node_processingdata,node_delivery,node_payload,node_database,node_listenerstore toneAmber
class node_contracts,node_triggeredcontract toneMint
class node_apiotel,node_workerotel toneRose
class node_subscriber,node_rabbitmq,node_otlp toneIndigo
class node_listener toneTeal
```

## Components

### API and Orders

- [REST API](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.API/Program.cs): `Webhooks.API/Program.cs`
- [Webhook Endpoints](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.API/Controllers/WebhooksController.cs): `Webhooks.API/Controllers/WebhooksController.cs`
- [Orders API](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.API/Controllers/OrdersController.cs): `Webhooks.API/Controllers/OrdersController.cs`
- [Order Repository](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.API/Repositories/InMemoryOrderRepository.cs): `Webhooks.API/Repositories/InMemoryOrderRepository.cs`
- [Event Dispatcher](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.API/Services/WebhookDispatcher.cs): `Webhooks.API/Services/WebhookDispatcher.cs`
- [API Data Context](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.API/Data/WebhooksDbContext.cs): `Webhooks.API/Data/WebhooksDbContext.cs`

### Webhook Processing

- [Processing Worker](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Processing/Program.cs): `Webhooks.Processing/Program.cs`
- [Match Subscriptions](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Processing/Services/WebhookDispatchedConsumer.cs): `Webhooks.Processing/Services/WebhookDispatchedConsumer.cs`
- [Worker Data Context](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Processing/Data/WebhooksDbContext.cs): `Webhooks.Processing/Data/WebhooksDbContext.cs`
- [Send Delivery](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Processing/Services/WebhookTriggeredConsumer.cs): `Webhooks.Processing/Services/WebhookTriggeredConsumer.cs`
- [Delivery Payload](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Processing/Services/WebhookPayload.cs): `Webhooks.Processing/Services/WebhookPayload.cs`

### Message Contracts

- [Message Contracts](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Contracts/WebhookDispatched.cs): `Webhooks.Contracts/WebhookDispatched.cs`
- [Delivery Contract](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Contracts/WebhookTriggered.cs): `Webhooks.Contracts/WebhookTriggered.cs`

### Observability

- [API Telemetry](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.API/Program.cs): `Webhooks.API/Program.cs`
- [Worker Telemetry](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.Processing/Program.cs): `Webhooks.Processing/Program.cs`

### Other components

- **API Client**
- **PostgreSQL**
- **Subscriber URL**
- [Test Listener](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.TestListener/Program.cs): `Webhooks.TestListener/Program.cs`
- [Received Webhooks](https://github.com/nikola-golijanin/webhooks/blob/main/Webhooks.TestListener/WebhookStore.cs): `Webhooks.TestListener/WebhookStore.cs`
- **RabbitMQ**
- **OTLP Backend**

## Connections

- API Client → Webhook Endpoints: manages and publishes
- API Client → Orders API: creates orders
- Webhook Endpoints → API Data Context: reads and writes
- API Data Context → PostgreSQL: persists subscriptions
- Webhook Endpoints → Event Dispatcher: dispatches event
- Orders API → Order Repository: stores order
- Orders API → Event Dispatcher: dispatches event
- Event Dispatcher → Message Contracts: creates message
- Event Dispatcher → RabbitMQ: publishes
- RabbitMQ → Match Subscriptions: delivers message
- Match Subscriptions → Worker Data Context: queries matches
- Worker Data Context → PostgreSQL: reads subscriptions
- Match Subscriptions → Delivery Contract: creates per match
- Match Subscriptions → RabbitMQ: publishes
- RabbitMQ → Send Delivery: delivers message
- Send Delivery → Delivery Payload: builds payload
- Send Delivery → Subscriber URL: posts payload
- Subscriber URL → Test Listener: example receiver
- Test Listener → Received Webhooks: stores received
- Send Delivery → Worker Data Context: records attempt
- Worker Data Context → PostgreSQL: writes attempt
- API Telemetry → OTLP Backend: exports telemetry
- Worker Telemetry → OTLP Backend: exports telemetry
