# ryadevx/event-flow architecture

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

- Interactive diagram: https://gitdiagram.com/ryadevx/event-flow
- Repository: https://github.com/ryadevx/event-flow

## Overview

Even is a database-per-service ticketing backend: clients enter through the API gateway, which forwards requests to authentication, event-catalog, and ticket-purchase services. Purchases atomically reserve inventory, create tickets, and record outbox events; Kafka carries domain events to ticket synchronization and notification consumers. The README documents the outbox, idempotency, inbox retries, and DLQ capabilities. Some worker and consumer internals were not sampled, so those links rely on the README rather than inspected implementation.

Main entry points: [`apps/api-gateway/src/app.service.ts`](https://github.com/ryadevx/event-flow/blob/main/apps/api-gateway/src/app.service.ts) (HTTP forwarding), [`apps/auth/src/auth/auth.service.ts`](https://github.com/ryadevx/event-flow/blob/main/apps/auth/src/auth/auth.service.ts) (Authentication), [`apps/notifications/src/messaging/kafka.consumer.ts`](https://github.com/ryadevx/event-flow/blob/main/apps/notifications/src/messaging/kafka.consumer.ts) (Notification consumer), [`apps/api-gateway/src/app.controller.ts`](https://github.com/ryadevx/event-flow/blob/main/apps/api-gateway/src/app.controller.ts) (API gateway)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["API edge"]
  node_gateway["API gateway<br/>[app.controller.ts]"]
  node_proxy["HTTP forwarding<br/>[app.service.ts]"]
  node_roles["Role authorization<br/>[roles.guard.ts]"]
end

subgraph group_domain["Ticketing services"]
  node_auth["Authentication<br/>[auth.service.ts]"]
  node_auth_routes["Auth endpoints<br/>[auth.controller.ts]"]
  node_events["Event catalog<br/>[events.service.ts]"]
  node_event_routes["Event endpoints"]
  node_tickets["Ticket purchase<br/>[tickets.service.ts]"]
  node_ticket_routes["Ticket endpoints"]
end

subgraph group_messaging["Event delivery"]
  node_auth_outbox["Auth outbox publisher"]
  node_events_outbox["Events outbox publisher"]
  node_tickets_outbox["Tickets outbox publisher"]
  node_kafka["Kafka / Redpanda"]
  node_ticket_consumer["Ticket event consumer<br/>[kafka.consumer.ts]"]
  node_notification_consumer["Notification consumer<br/>[kafka.consumer.ts]"]
  node_notification_dispatch["Notification dispatch"]
  node_dlq["Purchase-event DLQ"]
end

subgraph group_state["Service data"]
  node_auth_db[("Auth database<br/>[schema.ts]")]
  node_events_db[("Events database<br/>[schema.ts]")]
  node_tickets_db[("Tickets database<br/>[schema.ts]")]
  node_notifications_db[("Notifications database<br/>[schema.ts]")]
end

subgraph group_shared["Shared runtime"]
  node_shared_topics["Shared topic constants<br/>[topics.ts]"]
  node_jwt_guard["JWT authentication guard<br/>[jwt-auth.guard.ts]"]
end

node_clients(("Web / mobile clients"))

node_clients -->|"sends HTTP"| node_gateway
node_gateway -->|"forwards requests"| node_proxy
node_proxy -->|"routes auth"| node_auth_routes
node_proxy -->|"routes events"| node_event_routes
node_proxy -->|"routes tickets"| node_ticket_routes
node_gateway -->|"applies guards"| node_roles
node_auth_routes -->|"calls"| node_auth
node_event_routes -->|"calls"| node_events
node_ticket_routes -->|"calls"| node_tickets
node_auth -->|"reads and writes"| node_auth_db
node_events -->|"reads and writes"| node_events_db
node_tickets -->|"reserves inventory"| node_tickets_db
node_auth -->|"uses topics"| node_shared_topics
node_events -->|"uses topics"| node_shared_topics
node_tickets -->|"uses topics"| node_shared_topics
node_auth -.->|"issues JWTs"| node_jwt_guard
node_auth_outbox -->|"publishes events"| node_kafka
node_events_outbox -->|"publishes events"| node_kafka
node_tickets_outbox -->|"publishes events"| node_kafka
node_kafka -->|"delivers event changes"| node_ticket_consumer
node_ticket_consumer -->|"syncs event data"| node_tickets_db
node_kafka -->|"delivers purchases"| node_notification_consumer
node_notification_consumer -->|"deduplicates and tracks retries"| node_notifications_db
node_notification_consumer -->|"dispatches alerts"| node_notification_dispatch
node_notification_consumer -->|"routes after retries"| node_dlq

click node_gateway "https://github.com/ryadevx/event-flow/blob/main/apps/api-gateway/src/app.controller.ts"
click node_proxy "https://github.com/ryadevx/event-flow/blob/main/apps/api-gateway/src/app.service.ts"
click node_roles "https://github.com/ryadevx/event-flow/blob/main/apps/api-gateway/src/auth/roles.guard.ts"
click node_auth "https://github.com/ryadevx/event-flow/blob/main/apps/auth/src/auth/auth.service.ts"
click node_auth_routes "https://github.com/ryadevx/event-flow/blob/main/apps/auth/src/auth/auth.controller.ts"
click node_events "https://github.com/ryadevx/event-flow/blob/main/apps/events/src/events/events.service.ts"
click node_event_routes "https://github.com/ryadevx/event-flow/blob/main/apps/events/src/events/events.controller.ts"
click node_tickets "https://github.com/ryadevx/event-flow/blob/main/apps/tickets/src/tickets/tickets.service.ts"
click node_ticket_routes "https://github.com/ryadevx/event-flow/blob/main/apps/tickets/src/tickets/tickets.controller.ts"
click node_auth_db "https://github.com/ryadevx/event-flow/blob/main/apps/auth/src/database/schema.ts"
click node_events_db "https://github.com/ryadevx/event-flow/blob/main/apps/events/src/database/schema.ts"
click node_tickets_db "https://github.com/ryadevx/event-flow/blob/main/apps/tickets/src/database/schema.ts"
click node_notifications_db "https://github.com/ryadevx/event-flow/blob/main/apps/notifications/src/database/schema.ts"
click node_auth_outbox "https://github.com/ryadevx/event-flow/blob/main/apps/auth/src/messaging/outbox.publisher.ts"
click node_events_outbox "https://github.com/ryadevx/event-flow/blob/main/apps/events/src/messaging/outbox.publisher.ts"
click node_tickets_outbox "https://github.com/ryadevx/event-flow/blob/main/apps/tickets/src/messaging/outbox.publisher.ts"
click node_ticket_consumer "https://github.com/ryadevx/event-flow/blob/main/apps/tickets/src/messaging/kafka.consumer.ts"
click node_notification_consumer "https://github.com/ryadevx/event-flow/blob/main/apps/notifications/src/messaging/kafka.consumer.ts"
click node_notification_dispatch "https://github.com/ryadevx/event-flow/blob/main/apps/notifications/src/notifications.service.ts"
click node_shared_topics "https://github.com/ryadevx/event-flow/blob/main/libs/shared/src/messaging/topics.ts"
click node_jwt_guard "https://github.com/ryadevx/event-flow/blob/main/libs/shared/src/auth/jwt-auth.guard.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_gateway,node_proxy,node_roles,node_clients toneBlue
class node_auth,node_auth_routes,node_events,node_event_routes,node_tickets,node_ticket_routes toneAmber
class node_auth_outbox,node_events_outbox,node_tickets_outbox,node_kafka,node_ticket_consumer,node_notification_consumer,node_notification_dispatch,node_dlq toneMint
class node_auth_db,node_events_db,node_tickets_db,node_notifications_db toneRose
class node_shared_topics,node_jwt_guard toneIndigo
```

## Components

### API edge

- [API gateway](https://github.com/ryadevx/event-flow/blob/main/apps/api-gateway/src/app.controller.ts): `apps/api-gateway/src/app.controller.ts`
- [HTTP forwarding](https://github.com/ryadevx/event-flow/blob/main/apps/api-gateway/src/app.service.ts): `apps/api-gateway/src/app.service.ts`
- [Role authorization](https://github.com/ryadevx/event-flow/blob/main/apps/api-gateway/src/auth/roles.guard.ts): `apps/api-gateway/src/auth/roles.guard.ts`

### Ticketing services

- [Authentication](https://github.com/ryadevx/event-flow/blob/main/apps/auth/src/auth/auth.service.ts): `apps/auth/src/auth/auth.service.ts`
- [Auth endpoints](https://github.com/ryadevx/event-flow/blob/main/apps/auth/src/auth/auth.controller.ts): `apps/auth/src/auth/auth.controller.ts`
- [Event catalog](https://github.com/ryadevx/event-flow/blob/main/apps/events/src/events/events.service.ts): `apps/events/src/events/events.service.ts`
- [Event endpoints](https://github.com/ryadevx/event-flow/blob/main/apps/events/src/events/events.controller.ts): `apps/events/src/events/events.controller.ts`
- [Ticket purchase](https://github.com/ryadevx/event-flow/blob/main/apps/tickets/src/tickets/tickets.service.ts): `apps/tickets/src/tickets/tickets.service.ts`
- [Ticket endpoints](https://github.com/ryadevx/event-flow/blob/main/apps/tickets/src/tickets/tickets.controller.ts): `apps/tickets/src/tickets/tickets.controller.ts`

### Event delivery

- [Auth outbox publisher](https://github.com/ryadevx/event-flow/blob/main/apps/auth/src/messaging/outbox.publisher.ts): `apps/auth/src/messaging/outbox.publisher.ts`
- [Events outbox publisher](https://github.com/ryadevx/event-flow/blob/main/apps/events/src/messaging/outbox.publisher.ts): `apps/events/src/messaging/outbox.publisher.ts`
- [Tickets outbox publisher](https://github.com/ryadevx/event-flow/blob/main/apps/tickets/src/messaging/outbox.publisher.ts): `apps/tickets/src/messaging/outbox.publisher.ts`
- **Kafka / Redpanda**
- [Ticket event consumer](https://github.com/ryadevx/event-flow/blob/main/apps/tickets/src/messaging/kafka.consumer.ts): `apps/tickets/src/messaging/kafka.consumer.ts`
- [Notification consumer](https://github.com/ryadevx/event-flow/blob/main/apps/notifications/src/messaging/kafka.consumer.ts): `apps/notifications/src/messaging/kafka.consumer.ts`
- [Notification dispatch](https://github.com/ryadevx/event-flow/blob/main/apps/notifications/src/notifications.service.ts): `apps/notifications/src/notifications.service.ts`
- **Purchase-event DLQ**

### Service data

- [Auth database](https://github.com/ryadevx/event-flow/blob/main/apps/auth/src/database/schema.ts): `apps/auth/src/database/schema.ts`
- [Events database](https://github.com/ryadevx/event-flow/blob/main/apps/events/src/database/schema.ts): `apps/events/src/database/schema.ts`
- [Tickets database](https://github.com/ryadevx/event-flow/blob/main/apps/tickets/src/database/schema.ts): `apps/tickets/src/database/schema.ts`
- [Notifications database](https://github.com/ryadevx/event-flow/blob/main/apps/notifications/src/database/schema.ts): `apps/notifications/src/database/schema.ts`

### Shared runtime

- [Shared topic constants](https://github.com/ryadevx/event-flow/blob/main/libs/shared/src/messaging/topics.ts): `libs/shared/src/messaging/topics.ts`
- [JWT authentication guard](https://github.com/ryadevx/event-flow/blob/main/libs/shared/src/auth/jwt-auth.guard.ts): `libs/shared/src/auth/jwt-auth.guard.ts`

### Other components

- **Web / mobile clients**

## Connections

- Web / mobile clients → API gateway: sends HTTP
- API gateway → HTTP forwarding: forwards requests (evidence: `apps/api-gateway/src/app.controller.ts`)
- HTTP forwarding → Auth endpoints: routes auth
- HTTP forwarding → Event endpoints: routes events
- HTTP forwarding → Ticket endpoints: routes tickets
- API gateway → Role authorization: applies guards (evidence: `apps/api-gateway/src/app.controller.ts`)
- Auth endpoints → Authentication: calls (evidence: `apps/auth/src/auth/auth.controller.ts`)
- Event endpoints → Event catalog: calls (evidence: `apps/events/src/events/events.controller.ts`)
- Ticket endpoints → Ticket purchase: calls (evidence: `apps/tickets/src/tickets/tickets.controller.ts`)
- Authentication → Auth database: reads and writes (evidence: `apps/auth/src/auth/auth.service.ts`)
- Event catalog → Events database: reads and writes (evidence: `apps/events/src/events/events.service.ts`)
- Ticket purchase → Tickets database: reserves inventory (evidence: `apps/tickets/src/tickets/tickets.service.ts`)
- Authentication → Shared topic constants: uses topics (evidence: `apps/auth/src/auth/auth.service.ts`)
- Event catalog → Shared topic constants: uses topics (evidence: `apps/events/src/events/events.service.ts`)
- Ticket purchase → Shared topic constants: uses topics (evidence: `apps/tickets/src/tickets/tickets.service.ts`)
- Authentication → JWT authentication guard: issues JWTs
- Auth outbox publisher → Kafka / Redpanda: publishes events
- Events outbox publisher → Kafka / Redpanda: publishes events
- Tickets outbox publisher → Kafka / Redpanda: publishes events
- Kafka / Redpanda → Ticket event consumer: delivers event changes
- Ticket event consumer → Tickets database: syncs event data
- Kafka / Redpanda → Notification consumer: delivers purchases
- Notification consumer → Notifications database: deduplicates and tracks retries
- Notification consumer → Notification dispatch: dispatches alerts
- Notification consumer → Purchase-event DLQ: routes after retries
