# toshmatovdeveloper/bookingservice architecture

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

- Interactive diagram: https://gitdiagram.com/toshmatovdeveloper/bookingservice
- Repository: https://github.com/toshmatovdeveloper/bookingservice

## Overview

This repository implements a hotel-booking platform with booking and inventory APIs, account authentication, and event-driven email notifications. The main user workflow enters through the booking controllers, dispatches booking requests through MediatR, and returns booking results; hotel and room lookup handlers also use a distributed cache and the booking database. Authentication has separate HTTP and gRPC entry points backed by its own database. Notification consumers handle account and booking events. Several handlers and service registrations are not sampled, so their internal calls and event producers are not inferred.

Main entry points: [`BookingService/src/BookingService.Presenters/Controllers/BookingController.cs`](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Presenters/Controllers/BookingController.cs) (Booking endpoints), [`BookingService/src/BookingService.Presenters/Controllers/HotelController.cs`](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Presenters/Controllers/HotelController.cs) (Hotel endpoints), [`BookingService/src/BookingService.Application/Features/Queries/Booking/GetBookingByIdQuery.cs`](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Application/Features/Queries/Booking/GetBookingByIdQuery.cs) (Booking lookup), [`BookingService/src/BookingService.Application/Features/Queries/Hotel/GetHotelByIdQuery.cs`](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Application/Features/Queries/Hotel/GetHotelByIdQuery.cs) (Hotel lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_booking["Booking API"]
  node_booking_api["Booking endpoints"]
  node_hotel_api["Hotel endpoints<br/>[HotelController.cs]"]
  node_booking_requests["Booking handlers<br/>[Booking]"]
  node_booking_queries["Booking lookup"]
  node_hotel_requests["Hotel handlers<br/>[Hotel]"]
  node_hotel_lookup["Hotel lookup"]
  node_room_api["Room endpoints<br/>[RoomController.cs]"]
  node_room_lookup["Room lookup"]
  node_booking_db[("Booking database")]
  node_cache[("Distributed cache")]
end

subgraph group_auth["Authentication"]
  node_auth_api["Account endpoints<br/>[UserController.cs]"]
  node_auth_requests["Account handlers<br/>[Features]"]
  node_token_provider["Token provider<br/>[TokenProvider.cs]"]
  node_auth_grpc["Auth gRPC service"]
  node_auth_db[("Auth database<br/>[AuthDbContext.cs]")]
end

subgraph group_notify["Notifications"]
  node_notification_consumers["Event consumers<br/>[Consumers]"]
  node_mail_command["Send mail<br/>[SendMailCommand.cs]"]
  node_notification_db[("Notification database")]
end

subgraph group_shared["Shared contracts"]
  node_event_contracts["Integration events<br/>[Events]"]
  node_grpc_client["Auth gRPC client<br/>[AuthGrpcClient.cs]"]
end

node_user(("API user"))
node_smtp["SMTP server"]
node_broker["Message broker"]

node_user -->|"sends requests"| node_booking_api
node_user -->|"sends requests"| node_hotel_api
node_user -->|"sends requests"| node_room_api
node_booking_api -->|"dispatches commands"| node_booking_requests
node_booking_api -->|"dispatches queries"| node_booking_queries
node_hotel_api -->|"dispatches commands"| node_hotel_requests
node_hotel_api -->|"dispatches queries"| node_hotel_lookup
node_room_api -->|"dispatches queries"| node_room_lookup
node_booking_queries -->|"reads and writes"| node_cache
node_booking_queries -->|"reads"| node_booking_db
node_hotel_lookup -->|"reads and writes"| node_cache
node_hotel_lookup -->|"reads"| node_booking_db
node_room_lookup -->|"reads and writes"| node_cache
node_room_lookup -->|"reads"| node_booking_db
node_user -->|"sends requests"| node_auth_api
node_auth_api -->|"dispatches commands"| node_auth_requests
node_auth_grpc -->|"reads users"| node_auth_db
node_grpc_client -->|"calls"| node_auth_grpc
node_broker -->|"delivers events"| node_notification_consumers
node_notification_consumers -->|"dispatches mail"| node_mail_command
node_notification_consumers -->|"persists mail"| node_notification_db
node_mail_command -->|"sends mail"| node_smtp

click node_booking_api "https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Presenters/Controllers/BookingController.cs"
click node_hotel_api "https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Presenters/Controllers/HotelController.cs"
click node_booking_requests "https://github.com/toshmatovdeveloper/bookingservice/tree/main/BookingService/src/BookingService.Application/Features/Commands/Booking"
click node_booking_queries "https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Application/Features/Queries/Booking/GetBookingByIdQuery.cs"
click node_hotel_requests "https://github.com/toshmatovdeveloper/bookingservice/tree/main/BookingService/src/BookingService.Application/Features/Commands/Hotel"
click node_hotel_lookup "https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Application/Features/Queries/Hotel/GetHotelByIdQuery.cs"
click node_room_api "https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Presenters/Controllers/RoomController.cs"
click node_room_lookup "https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Application/Features/Queries/Room/GetRoomByIdQuery.cs"
click node_booking_db "https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Infrastructure/ApplicationDbContext.cs"
click node_auth_api "https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/auth/BookingService.Auth/Presenters/Controllers/UserController.cs"
click node_auth_requests "https://github.com/toshmatovdeveloper/bookingservice/tree/main/BookingService/src/auth/BookingService.Auth/Application/Features"
click node_token_provider "https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/auth/BookingService.Auth/Application/Features/Tokens/TokenProvider.cs"
click node_auth_grpc "https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/auth/BookingService.Auth/Grpc/Services/AuthenticationService.cs"
click node_auth_db "https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/auth/BookingService.Auth/Infrastructure/AuthDbContext.cs"
click node_notification_consumers "https://github.com/toshmatovdeveloper/bookingservice/tree/main/BookingService/src/BookingService.Notification/Infrastructure/Consumers"
click node_mail_command "https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Notification/Application/Features/SendMailCommand.cs"
click node_notification_db "https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Notification/Infrastructure/NotificationDbContext.cs"
click node_event_contracts "https://github.com/toshmatovdeveloper/bookingservice/tree/main/BookingService/src/BookingService.Contracts/Events"
click node_grpc_client "https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Grpc.Contracts/Clients/AuthGrpcClient.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_booking_api,node_hotel_api,node_booking_requests,node_booking_queries,node_hotel_requests,node_hotel_lookup,node_room_api,node_room_lookup,node_booking_db,node_cache,node_user toneBlue
class node_auth_api,node_auth_requests,node_token_provider,node_auth_grpc,node_auth_db toneAmber
class node_notification_consumers,node_mail_command,node_notification_db,node_smtp toneMint
class node_event_contracts,node_grpc_client toneRose
class node_broker toneIndigo
```

## Components

### Booking API

- [Booking endpoints](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Presenters/Controllers/BookingController.cs): `BookingService/src/BookingService.Presenters/Controllers/BookingController.cs`
- [Hotel endpoints](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Presenters/Controllers/HotelController.cs): `BookingService/src/BookingService.Presenters/Controllers/HotelController.cs`
- [Booking handlers](https://github.com/toshmatovdeveloper/bookingservice/tree/main/BookingService/src/BookingService.Application/Features/Commands/Booking): `BookingService/src/BookingService.Application/Features/Commands/Booking`
- [Booking lookup](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Application/Features/Queries/Booking/GetBookingByIdQuery.cs): `BookingService/src/BookingService.Application/Features/Queries/Booking/GetBookingByIdQuery.cs`
- [Hotel handlers](https://github.com/toshmatovdeveloper/bookingservice/tree/main/BookingService/src/BookingService.Application/Features/Commands/Hotel): `BookingService/src/BookingService.Application/Features/Commands/Hotel`
- [Hotel lookup](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Application/Features/Queries/Hotel/GetHotelByIdQuery.cs): `BookingService/src/BookingService.Application/Features/Queries/Hotel/GetHotelByIdQuery.cs`
- [Room endpoints](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Presenters/Controllers/RoomController.cs): `BookingService/src/BookingService.Presenters/Controllers/RoomController.cs`
- [Room lookup](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Application/Features/Queries/Room/GetRoomByIdQuery.cs): `BookingService/src/BookingService.Application/Features/Queries/Room/GetRoomByIdQuery.cs`
- [Booking database](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Infrastructure/ApplicationDbContext.cs): `BookingService/src/BookingService.Infrastructure/ApplicationDbContext.cs`
- **Distributed cache**

### Authentication

- [Account endpoints](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/auth/BookingService.Auth/Presenters/Controllers/UserController.cs): `BookingService/src/auth/BookingService.Auth/Presenters/Controllers/UserController.cs`
- [Account handlers](https://github.com/toshmatovdeveloper/bookingservice/tree/main/BookingService/src/auth/BookingService.Auth/Application/Features): `BookingService/src/auth/BookingService.Auth/Application/Features`
- [Token provider](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/auth/BookingService.Auth/Application/Features/Tokens/TokenProvider.cs): `BookingService/src/auth/BookingService.Auth/Application/Features/Tokens/TokenProvider.cs`
- [Auth gRPC service](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/auth/BookingService.Auth/Grpc/Services/AuthenticationService.cs): `BookingService/src/auth/BookingService.Auth/Grpc/Services/AuthenticationService.cs`
- [Auth database](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/auth/BookingService.Auth/Infrastructure/AuthDbContext.cs): `BookingService/src/auth/BookingService.Auth/Infrastructure/AuthDbContext.cs`

### Notifications

- [Event consumers](https://github.com/toshmatovdeveloper/bookingservice/tree/main/BookingService/src/BookingService.Notification/Infrastructure/Consumers): `BookingService/src/BookingService.Notification/Infrastructure/Consumers`
- [Send mail](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Notification/Application/Features/SendMailCommand.cs): `BookingService/src/BookingService.Notification/Application/Features/SendMailCommand.cs`
- [Notification database](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Notification/Infrastructure/NotificationDbContext.cs): `BookingService/src/BookingService.Notification/Infrastructure/NotificationDbContext.cs`

### Shared contracts

- [Integration events](https://github.com/toshmatovdeveloper/bookingservice/tree/main/BookingService/src/BookingService.Contracts/Events): `BookingService/src/BookingService.Contracts/Events`
- [Auth gRPC client](https://github.com/toshmatovdeveloper/bookingservice/blob/main/BookingService/src/BookingService.Grpc.Contracts/Clients/AuthGrpcClient.cs): `BookingService/src/BookingService.Grpc.Contracts/Clients/AuthGrpcClient.cs`

### Other components

- **API user**
- **SMTP server**
- **Message broker**

## Connections

- API user → Booking endpoints: sends requests
- API user → Hotel endpoints: sends requests
- API user → Room endpoints: sends requests
- Booking endpoints → Booking handlers: dispatches commands
- Booking endpoints → Booking lookup: dispatches queries
- Hotel endpoints → Hotel handlers: dispatches commands
- Hotel endpoints → Hotel lookup: dispatches queries
- Room endpoints → Room lookup: dispatches queries
- Booking lookup → Distributed cache: reads and writes
- Booking lookup → Booking database: reads
- Hotel lookup → Distributed cache: reads and writes
- Hotel lookup → Booking database: reads
- Room lookup → Distributed cache: reads and writes
- Room lookup → Booking database: reads
- API user → Account endpoints: sends requests
- Account endpoints → Account handlers: dispatches commands
- Auth gRPC service → Auth database: reads users
- Auth gRPC client → Auth gRPC service: calls
- Message broker → Event consumers: delivers events
- Event consumers → Send mail: dispatches mail
- Event consumers → Notification database: persists mail
- Send mail → SMTP server: sends mail
