# lhhuy02012005/cgv architecture

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

- Interactive diagram: https://gitdiagram.com/lhhuy02012005/cgv
- Repository: https://github.com/lhhuy02012005/cgv

## Overview

CineMatrix is a microservices movie-ticket booking platform. The main user journey is identity authentication, browsing movies and showtimes, temporarily holding seats, creating a booking, paying, and receiving a confirmed ticket; staff also manage check-in, refunds, and booking statistics. Catalog additionally covers cinemas, rooms, seats, articles, and events; identity includes membership tiers, while marketing, media, and notification services provide supporting capabilities. The README documents Kafka/outbox, Redis locking, and realtime updates. Several supporting service implementations and their wiring are not sampled, so those links are shown only where the tree or documentation supports them.

Main entry points: [`bookingservice/src/main/java/com/cgv/bookingservice/service/BookingService.java`](https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/service/BookingService.java) (Booking Service), [`identityservice/src/main/java/com/cgv/identityservice/controller/AuthenticationController.java`](https://github.com/lhhuy02012005/cgv/blob/main/identityservice/src/main/java/com/cgv/identityservice/controller/AuthenticationController.java) (Identity API), [`bookingservice/src/main/java/com/cgv/bookingservice/consumer/PaymentEventConsumer.java`](https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/consumer/PaymentEventConsumer.java) (Payment Event Consumer), [`bookingservice/src/main/java/com/cgv/bookingservice/controller/BookingController.java`](https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/controller/BookingController.java) (Booking API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and Membership"]
  node_identity_api["Identity API"]
  node_identity_auth["Authentication"]
  node_user_api["User API"]
  node_tier_service["Membership Tiers"]
end

subgraph group_catalog["Catalog and Scheduling"]
  node_catalog_api["Catalog APIs"]
  node_showtime_api["Showtime API"]
  node_showtime_service["Showtime Queries"]
  node_catalog_data[("Catalog Storage")]
  node_catalog_realtime["Catalog Realtime"]
  node_catalog_realtime_api["Catalog Stream API"]
end

subgraph group_booking["Booking and Tickets"]
  node_booking_api["Booking API"]
  node_booking_service["Booking Service"]
  node_seat_api["Seat Lock API"]
  node_seat_lock["Seat Lock Service"]
  node_booking_store[("Booking Storage")]
  node_booking_realtime["Booking Realtime"]
  node_booking_consumer["Payment Event Consumer"]
  node_booking_realtime_api["Booking Stream API"]
  node_catalog_client["Catalog gRPC Client"]
end

subgraph group_commerce["Commerce Integrations"]
  node_payment["Payment Service"]
  node_marketing["Promotion Service"]
  node_media["Media Service<br/>[MediaService.java]"]
  node_notification["Email Service<br/>[BrevoService.java]"]
end

subgraph group_shared["Shared Contracts"]
  node_shared_events["Shared Event Contracts"]
end

node_customer(("Customer"))
node_staff(("Cinema Staff"))
node_brevo["Brevo"]
node_kafka["Kafka"]

node_customer -->|"authenticates"| node_identity_api
node_identity_api -->|"delegates"| node_identity_auth
node_customer -->|"browses"| node_catalog_api
node_customer -->|"finds showtimes"| node_showtime_api
node_showtime_api -->|"queries"| node_showtime_service
node_showtime_service -->|"reads"| node_catalog_data
node_customer -->|"holds seats"| node_seat_api
node_seat_api -->|"delegates"| node_seat_lock
node_customer -->|"books seats"| node_booking_api
node_booking_api -->|"delegates"| node_booking_service
node_booking_service -->|"reads/writes"| node_booking_store
node_booking_service -->|"requests catalog data"| node_catalog_client
node_booking_service -.->|"starts payment"| node_payment
node_customer -->|"pays"| node_payment
node_payment -.->|"publishes events"| node_kafka
node_kafka -->|"dispatches events"| node_booking_consumer
node_booking_consumer -->|"uses event contract"| node_shared_events
node_booking_consumer -->|"confirms booking"| node_booking_service
node_booking_service -->|"broadcasts updates"| node_booking_realtime
node_booking_realtime_api -->|"subscribes"| node_booking_realtime
node_customer -->|"watches booking"| node_booking_realtime_api
node_staff -->|"manages tickets"| node_booking_api
node_catalog_realtime_api -->|"subscribes"| node_catalog_realtime
node_customer -->|"watches catalog"| node_catalog_realtime_api
node_marketing -.->|"promotion support"| node_booking_service
node_media -.->|"provides upload URL"| node_customer
node_notification -->|"sends email"| node_brevo
node_identity_auth -.->|"sends OTP"| node_notification
node_identity_api -.->|"supports account flows"| node_user_api
node_tier_service -.->|"membership management"| node_user_api

click node_identity_api "https://github.com/lhhuy02012005/cgv/blob/main/identityservice/src/main/java/com/cgv/identityservice/controller/AuthenticationController.java"
click node_identity_auth "https://github.com/lhhuy02012005/cgv/blob/main/identityservice/src/main/java/com/cgv/identityservice/service/AuthenticationService.java"
click node_user_api "https://github.com/lhhuy02012005/cgv/blob/main/identityservice/src/main/java/com/cgv/identityservice/controller/UserController.java"
click node_tier_service "https://github.com/lhhuy02012005/cgv/blob/main/identityservice/src/main/java/com/cgv/identityservice/service/MemberShipTierService.java"
click node_catalog_api "https://github.com/lhhuy02012005/cgv/blob/main/catalogservice/src/main/java/com/cgv/catalogservice/controller/MovieController.java"
click node_showtime_api "https://github.com/lhhuy02012005/cgv/blob/main/catalogservice/src/main/java/com/cgv/catalogservice/controller/ShowtimeController.java"
click node_showtime_service "https://github.com/lhhuy02012005/cgv/blob/main/catalogservice/src/main/java/com/cgv/catalogservice/service/ShowtimeService.java"
click node_catalog_data "https://github.com/lhhuy02012005/cgv/blob/main/catalogservice/src/main/java/com/cgv/catalogservice/repository/ShowtimeRepository.java"
click node_catalog_realtime "https://github.com/lhhuy02012005/cgv/blob/main/catalogservice/src/main/java/com/cgv/catalogservice/service/CatalogRealtimeService.java"
click node_booking_api "https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/controller/BookingController.java"
click node_booking_service "https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/service/BookingService.java"
click node_seat_api "https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/controller/SeatLockController.java"
click node_seat_lock "https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/service/SeatLockService.java"
click node_booking_store "https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/repository/BookingRepository.java"
click node_booking_realtime "https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/service/BookingRealtimeService.java"
click node_payment "https://github.com/lhhuy02012005/cgv/blob/main/paymentservice/src/main/java/com/cgv/paymentservice/service/PaymentService.java"
click node_marketing "https://github.com/lhhuy02012005/cgv/blob/main/marketingservice/src/main/java/com/cgv/marketingservice/service/PromotionService.java"
click node_media "https://github.com/lhhuy02012005/cgv/blob/main/mediaservice/src/main/java/com/cgv/mediaservice/service/MediaService.java"
click node_notification "https://github.com/lhhuy02012005/cgv/blob/main/notificationservice/src/main/java/com/cgv/notificationservice/service/impl/BrevoService.java"
click node_booking_consumer "https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/consumer/PaymentEventConsumer.java"
click node_shared_events "https://github.com/lhhuy02012005/cgv/blob/main/commondto/src/main/java/com/cgv/commondto/event/PaymentCompletedEvent.java"
click node_catalog_realtime_api "https://github.com/lhhuy02012005/cgv/blob/main/catalogservice/src/main/java/com/cgv/catalogservice/controller/CatalogRealtimeController.java"
click node_booking_realtime_api "https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/controller/BookingRealtimeController.java"
click node_catalog_client "https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/grpc/CatalogGrpcClient.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_identity_api,node_identity_auth,node_user_api,node_tier_service toneBlue
class node_catalog_api,node_showtime_api,node_showtime_service,node_catalog_data,node_catalog_realtime,node_catalog_realtime_api toneAmber
class node_booking_api,node_booking_service,node_seat_api,node_seat_lock,node_booking_store,node_booking_realtime,node_booking_consumer,node_booking_realtime_api,node_catalog_client toneMint
class node_payment,node_marketing,node_media,node_notification toneRose
class node_shared_events,node_customer,node_staff,node_brevo,node_kafka toneIndigo
```

## Components

### Identity and Membership

- [Identity API](https://github.com/lhhuy02012005/cgv/blob/main/identityservice/src/main/java/com/cgv/identityservice/controller/AuthenticationController.java): `identityservice/src/main/java/com/cgv/identityservice/controller/AuthenticationController.java`
- [Authentication](https://github.com/lhhuy02012005/cgv/blob/main/identityservice/src/main/java/com/cgv/identityservice/service/AuthenticationService.java): `identityservice/src/main/java/com/cgv/identityservice/service/AuthenticationService.java`
- [User API](https://github.com/lhhuy02012005/cgv/blob/main/identityservice/src/main/java/com/cgv/identityservice/controller/UserController.java): `identityservice/src/main/java/com/cgv/identityservice/controller/UserController.java`
- [Membership Tiers](https://github.com/lhhuy02012005/cgv/blob/main/identityservice/src/main/java/com/cgv/identityservice/service/MemberShipTierService.java): `identityservice/src/main/java/com/cgv/identityservice/service/MemberShipTierService.java`

### Catalog and Scheduling

- [Catalog APIs](https://github.com/lhhuy02012005/cgv/blob/main/catalogservice/src/main/java/com/cgv/catalogservice/controller/MovieController.java): `catalogservice/src/main/java/com/cgv/catalogservice/controller/MovieController.java`
- [Showtime API](https://github.com/lhhuy02012005/cgv/blob/main/catalogservice/src/main/java/com/cgv/catalogservice/controller/ShowtimeController.java): `catalogservice/src/main/java/com/cgv/catalogservice/controller/ShowtimeController.java`
- [Showtime Queries](https://github.com/lhhuy02012005/cgv/blob/main/catalogservice/src/main/java/com/cgv/catalogservice/service/ShowtimeService.java): `catalogservice/src/main/java/com/cgv/catalogservice/service/ShowtimeService.java`
- [Catalog Storage](https://github.com/lhhuy02012005/cgv/blob/main/catalogservice/src/main/java/com/cgv/catalogservice/repository/ShowtimeRepository.java): `catalogservice/src/main/java/com/cgv/catalogservice/repository/ShowtimeRepository.java`
- [Catalog Realtime](https://github.com/lhhuy02012005/cgv/blob/main/catalogservice/src/main/java/com/cgv/catalogservice/service/CatalogRealtimeService.java): `catalogservice/src/main/java/com/cgv/catalogservice/service/CatalogRealtimeService.java`
- [Catalog Stream API](https://github.com/lhhuy02012005/cgv/blob/main/catalogservice/src/main/java/com/cgv/catalogservice/controller/CatalogRealtimeController.java): `catalogservice/src/main/java/com/cgv/catalogservice/controller/CatalogRealtimeController.java`

### Booking and Tickets

- [Booking API](https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/controller/BookingController.java): `bookingservice/src/main/java/com/cgv/bookingservice/controller/BookingController.java`
- [Booking Service](https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/service/BookingService.java): `bookingservice/src/main/java/com/cgv/bookingservice/service/BookingService.java`
- [Seat Lock API](https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/controller/SeatLockController.java): `bookingservice/src/main/java/com/cgv/bookingservice/controller/SeatLockController.java`
- [Seat Lock Service](https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/service/SeatLockService.java): `bookingservice/src/main/java/com/cgv/bookingservice/service/SeatLockService.java`
- [Booking Storage](https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/repository/BookingRepository.java): `bookingservice/src/main/java/com/cgv/bookingservice/repository/BookingRepository.java`
- [Booking Realtime](https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/service/BookingRealtimeService.java): `bookingservice/src/main/java/com/cgv/bookingservice/service/BookingRealtimeService.java`
- [Payment Event Consumer](https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/consumer/PaymentEventConsumer.java): `bookingservice/src/main/java/com/cgv/bookingservice/consumer/PaymentEventConsumer.java`
- [Booking Stream API](https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/controller/BookingRealtimeController.java): `bookingservice/src/main/java/com/cgv/bookingservice/controller/BookingRealtimeController.java`
- [Catalog gRPC Client](https://github.com/lhhuy02012005/cgv/blob/main/bookingservice/src/main/java/com/cgv/bookingservice/grpc/CatalogGrpcClient.java): `bookingservice/src/main/java/com/cgv/bookingservice/grpc/CatalogGrpcClient.java`

### Commerce Integrations

- [Payment Service](https://github.com/lhhuy02012005/cgv/blob/main/paymentservice/src/main/java/com/cgv/paymentservice/service/PaymentService.java): `paymentservice/src/main/java/com/cgv/paymentservice/service/PaymentService.java`
- [Promotion Service](https://github.com/lhhuy02012005/cgv/blob/main/marketingservice/src/main/java/com/cgv/marketingservice/service/PromotionService.java): `marketingservice/src/main/java/com/cgv/marketingservice/service/PromotionService.java`
- [Media Service](https://github.com/lhhuy02012005/cgv/blob/main/mediaservice/src/main/java/com/cgv/mediaservice/service/MediaService.java): `mediaservice/src/main/java/com/cgv/mediaservice/service/MediaService.java`
- [Email Service](https://github.com/lhhuy02012005/cgv/blob/main/notificationservice/src/main/java/com/cgv/notificationservice/service/impl/BrevoService.java): `notificationservice/src/main/java/com/cgv/notificationservice/service/impl/BrevoService.java`

### Shared Contracts

- [Shared Event Contracts](https://github.com/lhhuy02012005/cgv/blob/main/commondto/src/main/java/com/cgv/commondto/event/PaymentCompletedEvent.java): `commondto/src/main/java/com/cgv/commondto/event/PaymentCompletedEvent.java`

### Other components

- **Customer**
- **Cinema Staff**
- **Brevo**
- **Kafka**

## Connections

- Customer → Identity API: authenticates
- Identity API → Authentication: delegates
- Customer → Catalog APIs: browses
- Customer → Showtime API: finds showtimes
- Showtime API → Showtime Queries: queries
- Showtime Queries → Catalog Storage: reads
- Customer → Seat Lock API: holds seats
- Seat Lock API → Seat Lock Service: delegates
- Customer → Booking API: books seats
- Booking API → Booking Service: delegates
- Booking Service → Booking Storage: reads/writes
- Booking Service → Catalog gRPC Client: requests catalog data
- Booking Service → Payment Service: starts payment
- Customer → Payment Service: pays
- Payment Service → Kafka: publishes events
- Kafka → Payment Event Consumer: dispatches events
- Payment Event Consumer → Shared Event Contracts: uses event contract
- Payment Event Consumer → Booking Service: confirms booking
- Booking Service → Booking Realtime: broadcasts updates
- Booking Stream API → Booking Realtime: subscribes
- Customer → Booking Stream API: watches booking
- Cinema Staff → Booking API: manages tickets
- Catalog Stream API → Catalog Realtime: subscribes
- Customer → Catalog Stream API: watches catalog
- Promotion Service → Booking Service: promotion support
- Media Service → Customer: provides upload URL
- Email Service → Brevo: sends email
- Authentication → Email Service: sends OTP
- Identity API → User API: supports account flows
- Membership Tiers → User API: membership management
