# lalitlohani07/webhook-reconcilation-engine architecture

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

- Interactive diagram: https://gitdiagram.com/lalitlohani07/webhook-reconcilation-engine
- Repository: https://github.com/lalitlohani07/webhook-reconcilation-engine

## Overview

This Spring Boot backend accepts webhooks, persists them with a transactional outbox, and processes queued work asynchronously with idempotency and database-backed retries. Operators can inspect and replay dead-lettered events; a separate reconciliation workflow compares terminal local events with an external source of truth and records audit results. The README documents Redis rate limiting and role-protected endpoints, but source excerpts were not provided, so internal call ownership and some subsystem links cannot be verified; documented relationships are cited to the README.

Main entry points: [`webhook-reconciliation-engine/src/main/java/com/example/webhookengine/service/WebhookIngestionService.java`](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/service/WebhookIngestionService.java) (Ingestion Service), [`webhook-reconciliation-engine/src/main/java/com/example/webhookengine/service/WebhookProcessingService.java`](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/service/WebhookProcessingService.java) (Webhook Processor), [`webhook-reconciliation-engine/src/main/java/com/example/webhookengine/reconciliation/service/ReconciliationServiceImpl.java`](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/reconciliation/service/ReconciliationServiceImpl.java) (Reconciliation Service), [`webhook-reconciliation-engine/src/main/resources/db/migration/V1__create_webhook_domain_tables.sql`](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/resources/db/migration/V1__create_webhook_domain_tables.sql) (PostgreSQL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Ingestion and Processing"]
  node_api["Webhook API"]
  node_ingest["Ingestion Service"]
  node_processing["Webhook Processor"]
end

subgraph group_reliability["Delivery Reliability"]
  node_outbox["Outbox Publisher"]
  node_broker["RabbitMQ"]
  node_consumer["Processing Consumer"]
  node_retry["Retry Scheduler"]
  node_deadletter["Dead-Letter Service"]
  node_deadletter_api["Dead-Letter API"]
  node_replay["Replay Audit<br/>[WebhookReplay.java]"]
end

subgraph group_reconciliation["Reconciliation"]
  node_recon_api["Reconciliation API"]
  node_recon_service["Reconciliation Service"]
  node_source_client["Source-of-Truth Client"]
end

subgraph group_platform["Access and Infrastructure"]
  node_rate["Redis Rate Limiter"]
  node_database[("PostgreSQL")]
  node_security["HTTP Basic RBAC"]
end

node_client(("Webhook Client"))
node_external_source(("External Source"))

node_client -->|"submits webhook"| node_api
node_api -->|"accepts events"| node_ingest
node_ingest -->|"rate checks"| node_rate
node_ingest -->|"persists event"| node_database
node_ingest -->|"writes outbox"| node_outbox
node_outbox -->|"publishes messages"| node_broker
node_broker -->|"delivers work"| node_consumer
node_consumer -->|"dispatches work"| node_processing
node_processing -->|"locks and updates"| node_database
node_processing -->|"schedules retries"| node_retry
node_processing -->|"exhausts retries"| node_deadletter
node_deadletter_api -->|"inspects and replays"| node_deadletter
node_deadletter -->|"audits replay"| node_replay
node_recon_api -->|"starts comparison"| node_recon_service
node_recon_service -->|"reads terminal events"| node_database
node_recon_service -->|"requests comparison"| node_source_client
node_source_client -->|"fetches records"| node_external_source
node_recon_service -->|"persists audit"| node_database
node_security -->|"protects endpoints"| node_api
node_security -->|"authorizes roles"| node_deadletter_api

click node_api "https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/controller/WebhookController.java"
click node_ingest "https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/service/WebhookIngestionService.java"
click node_rate "https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/ratelimit/service/RedisRateLimiterService.java"
click node_database "https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/resources/db/migration/V1__create_webhook_domain_tables.sql"
click node_outbox "https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/messaging/OutboxPublisher.java"
click node_broker "https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/config/RabbitMqConfig.java"
click node_consumer "https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/messaging/WebhookProcessingConsumer.java"
click node_processing "https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/service/WebhookProcessingService.java"
click node_retry "https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/service/WebhookRetryScheduler.java"
click node_deadletter "https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/service/DeadLetterService.java"
click node_deadletter_api "https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/controller/DeadLetterController.java"
click node_replay "https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/domain/WebhookReplay.java"
click node_recon_api "https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/controller/ReconciliationController.java"
click node_recon_service "https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/reconciliation/service/ReconciliationServiceImpl.java"
click node_source_client "https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/reconciliation/provider/SourceOfTruthClient.java"
click node_security "https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/security/config/SecurityConfig.java"

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_ingest,node_processing,node_client toneBlue
class node_outbox,node_broker,node_consumer,node_retry,node_deadletter,node_deadletter_api,node_replay toneAmber
class node_recon_api,node_recon_service,node_source_client toneMint
class node_rate,node_database,node_security toneRose
class node_external_source toneIndigo
```

## Components

### Ingestion and Processing

- [Webhook API](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/controller/WebhookController.java): `webhook-reconciliation-engine/src/main/java/com/example/webhookengine/controller/WebhookController.java`
- [Ingestion Service](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/service/WebhookIngestionService.java): `webhook-reconciliation-engine/src/main/java/com/example/webhookengine/service/WebhookIngestionService.java`
- [Webhook Processor](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/service/WebhookProcessingService.java): `webhook-reconciliation-engine/src/main/java/com/example/webhookengine/service/WebhookProcessingService.java`

### Delivery Reliability

- [Outbox Publisher](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/messaging/OutboxPublisher.java): `webhook-reconciliation-engine/src/main/java/com/example/webhookengine/messaging/OutboxPublisher.java`
- [RabbitMQ](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/config/RabbitMqConfig.java): `webhook-reconciliation-engine/src/main/java/com/example/webhookengine/config/RabbitMqConfig.java`
- [Processing Consumer](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/messaging/WebhookProcessingConsumer.java): `webhook-reconciliation-engine/src/main/java/com/example/webhookengine/messaging/WebhookProcessingConsumer.java`
- [Retry Scheduler](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/service/WebhookRetryScheduler.java): `webhook-reconciliation-engine/src/main/java/com/example/webhookengine/service/WebhookRetryScheduler.java`
- [Dead-Letter Service](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/service/DeadLetterService.java): `webhook-reconciliation-engine/src/main/java/com/example/webhookengine/service/DeadLetterService.java`
- [Dead-Letter API](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/controller/DeadLetterController.java): `webhook-reconciliation-engine/src/main/java/com/example/webhookengine/controller/DeadLetterController.java`
- [Replay Audit](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/domain/WebhookReplay.java): `webhook-reconciliation-engine/src/main/java/com/example/webhookengine/domain/WebhookReplay.java`

### Reconciliation

- [Reconciliation API](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/controller/ReconciliationController.java): `webhook-reconciliation-engine/src/main/java/com/example/webhookengine/controller/ReconciliationController.java`
- [Reconciliation Service](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/reconciliation/service/ReconciliationServiceImpl.java): `webhook-reconciliation-engine/src/main/java/com/example/webhookengine/reconciliation/service/ReconciliationServiceImpl.java`
- [Source-of-Truth Client](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/reconciliation/provider/SourceOfTruthClient.java): `webhook-reconciliation-engine/src/main/java/com/example/webhookengine/reconciliation/provider/SourceOfTruthClient.java`

### Access and Infrastructure

- [Redis Rate Limiter](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/ratelimit/service/RedisRateLimiterService.java): `webhook-reconciliation-engine/src/main/java/com/example/webhookengine/ratelimit/service/RedisRateLimiterService.java`
- [PostgreSQL](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/resources/db/migration/V1__create_webhook_domain_tables.sql): `webhook-reconciliation-engine/src/main/resources/db/migration/V1__create_webhook_domain_tables.sql`
- [HTTP Basic RBAC](https://github.com/lalitlohani07/webhook-reconcilation-engine/blob/main/webhook-reconciliation-engine/src/main/java/com/example/webhookengine/security/config/SecurityConfig.java): `webhook-reconciliation-engine/src/main/java/com/example/webhookengine/security/config/SecurityConfig.java`

### Other components

- **Webhook Client**
- **External Source**

## Connections

- Webhook Client → Webhook API: submits webhook
- Webhook API → Ingestion Service: accepts events
- Ingestion Service → Redis Rate Limiter: rate checks
- Ingestion Service → PostgreSQL: persists event
- Ingestion Service → Outbox Publisher: writes outbox
- Outbox Publisher → RabbitMQ: publishes messages
- RabbitMQ → Processing Consumer: delivers work
- Processing Consumer → Webhook Processor: dispatches work
- Webhook Processor → PostgreSQL: locks and updates
- Webhook Processor → Retry Scheduler: schedules retries
- Webhook Processor → Dead-Letter Service: exhausts retries
- Dead-Letter API → Dead-Letter Service: inspects and replays
- Dead-Letter Service → Replay Audit: audits replay
- Reconciliation API → Reconciliation Service: starts comparison
- Reconciliation Service → PostgreSQL: reads terminal events
- Reconciliation Service → Source-of-Truth Client: requests comparison
- Source-of-Truth Client → External Source: fetches records
- Reconciliation Service → PostgreSQL: persists audit
- HTTP Basic RBAC → Webhook API: protects endpoints
- HTTP Basic RBAC → Dead-Letter API: authorizes roles
