# aritiaya50217/high-concurrency-ticket-booking-system architecture

> Architecture diagram of the GitHub repository aritiaya50217/high-concurrency-ticket-booking-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aritiaya50217/high-concurrency-ticket-booking-system
- Repository: https://github.com/aritiaya50217/high-concurrency-ticket-booking-system

## Overview

This repository implements a ticket-booking platform with separate booking, event/seat, and user services. A customer submits a booking through the booking HTTP API; booking logic coordinates seat availability and user identity, persists booking state and an outbox event, and publishes it for the event service to reserve the seat. Expiration similarly cancels bookings and emits events so seats can be released. The user service provides HTTP account flows and a gRPC identity API. The README documents the Inbox/Outbox and concurrency guarantees; some detailed wiring is inferred from that documentation because those sources were not sampled.

Main entry points: [`booking-service/internal/application/usecase/booking_usecase.go`](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/application/usecase/booking_usecase.go) (Booking Workflow), [`event-service/internal/application/usecase/event_usecase.go`](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/application/usecase/event_usecase.go) (Event Workflow), [`event-service/internal/interface/handler/event_handler.go`](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/interface/handler/event_handler.go) (Event HTTP API), [`event-service/internal/worker/booking_created_consumer.go`](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/worker/booking_created_consumer.go) (Booking Event Consumer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_booking["Booking Service"]
  node_booking_http["Booking HTTP API<br/>[booking_handler.go]"]
  node_booking_logic["Booking Workflow<br/>[booking_usecase.go]"]
  node_booking_state["Booking State<br/>[booking.go]"]
  node_booking_repo["Booking Repository"]
  node_booking_db[("Booking Database<br/>[postgres.go]")]
  node_expiration["Expiration Worker"]
  node_outbox_worker["Outbox Worker<br/>[outbox_worker.go]"]
  node_outbox_repo["Outbox Repository"]
  node_booking_consumer["Booking Consumer"]
  node_seat_client["Seat Service Client"]
  node_user_client["User gRPC Client"]
end

subgraph group_event["Event And Seats"]
  node_event_http["Event HTTP API<br/>[event_handler.go]"]
  node_event_logic["Event Workflow<br/>[event_usecase.go]"]
  node_seat_logic["Seat Workflow<br/>[seat_usecase.go]"]
  node_event_repo["Event Repository"]
  node_event_db[("Event Database<br/>[postgres.go]")]
  node_event_consumer["Booking Event Consumer"]
  node_inbox_repo["Inbox Repository"]
  node_event_producer["Seat Event Producer"]
end

subgraph group_identity["User Identity"]
  node_user_http["User HTTP API<br/>[user_handler.go]"]
  node_user_logic["User Workflow<br/>[user_usecase.go]"]
  node_user_grpc["User gRPC Server<br/>[user_server.go]"]
  node_user_repo["User Repository"]
  node_user_db[("User Database<br/>[postgres.go]")]
end

subgraph group_messaging["Event Transport"]
  node_kafka["Kafka"]
end

node_customer(("Customer"))

node_customer -->|"submits booking"| node_booking_http
node_booking_http -->|"calls"| node_booking_logic
node_booking_logic -->|"creates or updates"| node_booking_state
node_booking_logic -->|"persists"| node_booking_repo
node_booking_repo -->|"reads and writes"| node_booking_db
node_booking_logic -->|"checks seat"| node_seat_client
node_seat_client -.->|"calls seat API"| node_event_http
node_booking_logic -->|"validates user"| node_user_client
node_user_client -.->|"calls"| node_user_grpc
node_expiration -->|"finds and updates"| node_booking_repo
node_expiration -->|"records cancellation"| node_outbox_repo
node_outbox_repo -->|"writes outbox"| node_booking_db
node_outbox_worker -->|"polls pending"| node_outbox_repo
node_outbox_worker -->|"publishes booking events"| node_kafka
node_kafka -->|"delivers booking events"| node_event_consumer
node_event_consumer -->|"checks processed"| node_inbox_repo
node_event_consumer -->|"dispatches event"| node_event_logic
node_event_logic -->|"loads and updates seats"| node_event_repo
node_event_repo -->|"locks and persists"| node_event_db
node_event_logic -->|"emits seat events"| node_event_producer
node_event_producer -->|"publishes"| node_kafka
node_event_http -->|"calls event workflow"| node_event_logic
node_event_http -->|"calls seat workflow"| node_seat_logic
node_seat_logic -->|"reserves or releases"| node_event_repo
node_customer -->|"registers or logs in"| node_user_http
node_user_http -->|"calls"| node_user_logic
node_user_logic -->|"reads and writes users"| node_user_repo
node_user_repo -->|"reads and writes"| node_user_db
node_user_grpc -->|"delegates requests"| node_user_logic

click node_booking_http "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/interface/handler/booking_handler.go"
click node_booking_logic "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/application/usecase/booking_usecase.go"
click node_booking_state "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/domain/aggregate/booking.go"
click node_booking_repo "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/infrastructure/repository/booking_repository_impl.go"
click node_booking_db "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/infrastructure/database/postgres.go"
click node_expiration "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/worker/booking_expiration_worker.go"
click node_outbox_worker "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/worker/outbox_worker.go"
click node_outbox_repo "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/infrastructure/repository/outbox_repository_impl.go"
click node_booking_consumer "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/worker/booking_consumer.go"
click node_seat_client "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/infrastructure/external/eventservice/seat_service_client.go"
click node_user_client "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/infrastructure/grpc/user_service_client.go"
click node_event_http "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/interface/handler/event_handler.go"
click node_event_logic "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/application/usecase/event_usecase.go"
click node_seat_logic "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/application/usecase/seat_usecase.go"
click node_event_repo "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/infrastructure/repository/event_repository_impl.go"
click node_event_db "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/infrastructure/database/postgres.go"
click node_event_consumer "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/worker/booking_created_consumer.go"
click node_inbox_repo "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/infrastructure/repository/inbox_repository_impl.go"
click node_event_producer "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/infrastructure/repository/event_producer_repository_impl.go"
click node_user_http "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/user-service/internal/interface/handler/user_handler.go"
click node_user_logic "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/user-service/internal/application/usecase/user_usecase.go"
click node_user_grpc "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/user-service/internal/grpc/user_server.go"
click node_user_repo "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/user-service/internal/infrastructure/repository/user_repository_impl.go"
click node_user_db "https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/user-service/internal/infrastructure/database/postgres.go"

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_booking_http,node_booking_logic,node_booking_state,node_booking_repo,node_booking_db,node_expiration,node_outbox_worker,node_outbox_repo,node_booking_consumer,node_seat_client,node_user_client toneBlue
class node_event_http,node_event_logic,node_seat_logic,node_event_repo,node_event_db,node_event_consumer,node_inbox_repo,node_event_producer toneAmber
class node_user_http,node_user_logic,node_user_grpc,node_user_repo,node_user_db toneMint
class node_kafka toneRose
class node_customer toneIndigo
```

## Components

### Booking Service

- [Booking HTTP API](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/interface/handler/booking_handler.go): `booking-service/internal/interface/handler/booking_handler.go`
- [Booking Workflow](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/application/usecase/booking_usecase.go): `booking-service/internal/application/usecase/booking_usecase.go`
- [Booking State](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/domain/aggregate/booking.go): `booking-service/internal/domain/aggregate/booking.go`
- [Booking Repository](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/infrastructure/repository/booking_repository_impl.go): `booking-service/internal/infrastructure/repository/booking_repository_impl.go`
- [Booking Database](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/infrastructure/database/postgres.go): `booking-service/internal/infrastructure/database/postgres.go`
- [Expiration Worker](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/worker/booking_expiration_worker.go): `booking-service/internal/worker/booking_expiration_worker.go`
- [Outbox Worker](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/worker/outbox_worker.go): `booking-service/internal/worker/outbox_worker.go`
- [Outbox Repository](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/infrastructure/repository/outbox_repository_impl.go): `booking-service/internal/infrastructure/repository/outbox_repository_impl.go`
- [Booking Consumer](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/worker/booking_consumer.go): `booking-service/internal/worker/booking_consumer.go`
- [Seat Service Client](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/infrastructure/external/eventservice/seat_service_client.go): `booking-service/internal/infrastructure/external/eventservice/seat_service_client.go`
- [User gRPC Client](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/booking-service/internal/infrastructure/grpc/user_service_client.go): `booking-service/internal/infrastructure/grpc/user_service_client.go`

### Event And Seats

- [Event HTTP API](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/interface/handler/event_handler.go): `event-service/internal/interface/handler/event_handler.go`
- [Event Workflow](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/application/usecase/event_usecase.go): `event-service/internal/application/usecase/event_usecase.go`
- [Seat Workflow](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/application/usecase/seat_usecase.go): `event-service/internal/application/usecase/seat_usecase.go`
- [Event Repository](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/infrastructure/repository/event_repository_impl.go): `event-service/internal/infrastructure/repository/event_repository_impl.go`
- [Event Database](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/infrastructure/database/postgres.go): `event-service/internal/infrastructure/database/postgres.go`
- [Booking Event Consumer](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/worker/booking_created_consumer.go): `event-service/internal/worker/booking_created_consumer.go`
- [Inbox Repository](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/infrastructure/repository/inbox_repository_impl.go): `event-service/internal/infrastructure/repository/inbox_repository_impl.go`
- [Seat Event Producer](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/event-service/internal/infrastructure/repository/event_producer_repository_impl.go): `event-service/internal/infrastructure/repository/event_producer_repository_impl.go`

### User Identity

- [User HTTP API](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/user-service/internal/interface/handler/user_handler.go): `user-service/internal/interface/handler/user_handler.go`
- [User Workflow](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/user-service/internal/application/usecase/user_usecase.go): `user-service/internal/application/usecase/user_usecase.go`
- [User gRPC Server](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/user-service/internal/grpc/user_server.go): `user-service/internal/grpc/user_server.go`
- [User Repository](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/user-service/internal/infrastructure/repository/user_repository_impl.go): `user-service/internal/infrastructure/repository/user_repository_impl.go`
- [User Database](https://github.com/aritiaya50217/high-concurrency-ticket-booking-system/blob/main/user-service/internal/infrastructure/database/postgres.go): `user-service/internal/infrastructure/database/postgres.go`

### Event Transport

- **Kafka**

### Other components

- **Customer**

## Connections

- Customer → Booking HTTP API: submits booking
- Booking HTTP API → Booking Workflow: calls
- Booking Workflow → Booking State: creates or updates
- Booking Workflow → Booking Repository: persists
- Booking Repository → Booking Database: reads and writes
- Booking Workflow → Seat Service Client: checks seat
- Seat Service Client → Event HTTP API: calls seat API
- Booking Workflow → User gRPC Client: validates user
- User gRPC Client → User gRPC Server: calls
- Expiration Worker → Booking Repository: finds and updates
- Expiration Worker → Outbox Repository: records cancellation
- Outbox Repository → Booking Database: writes outbox
- Outbox Worker → Outbox Repository: polls pending
- Outbox Worker → Kafka: publishes booking events
- Kafka → Booking Event Consumer: delivers booking events
- Booking Event Consumer → Inbox Repository: checks processed
- Booking Event Consumer → Event Workflow: dispatches event
- Event Workflow → Event Repository: loads and updates seats
- Event Repository → Event Database: locks and persists
- Event Workflow → Seat Event Producer: emits seat events
- Seat Event Producer → Kafka: publishes
- Event HTTP API → Event Workflow: calls event workflow
- Event HTTP API → Seat Workflow: calls seat workflow
- Seat Workflow → Event Repository: reserves or releases
- Customer → User HTTP API: registers or logs in
- User HTTP API → User Workflow: calls
- User Workflow → User Repository: reads and writes users
- User Repository → User Database: reads and writes
- User gRPC Server → User Workflow: delegates requests
