# tavish108/hotel_booking architecture

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

- Interactive diagram: https://gitdiagram.com/tavish108/hotel_booking
- Repository: https://github.com/tavish108/hotel_booking

## Overview

#### Purpose and Entry Points
This is a Ruby object-oriented hotel booking system for managing hotels, rooms, guests, bookings, reviews, and payments. The likely executable entry points are `main.rb` and `hotel_booking_system.rb`; persistent hotel data is supplied through `hotels.json`.

#### Application Orchestration
`hotel_booking_system.rb` appears to be the top-level domain/application coordinator, while `main.rb` likely starts the program and drives its interaction flow. These files form the boundary between user-facing execution and domain services:
- `main.rb`
- `hotel_booking_system.rb`

#### Booking Workflow
Booking is represented as a first-class domain entity and coordinated through a dedicated service. `BookingService.rb` is the likely transaction/workflow layer: it should validate room availability, connect a guest and room/hotel, create a `Booking`, and trigger payment handling.
- `BookingService.rb`
- `Booking.rb`
- `payment.rb`

#### Hotel and Room Inventory
Hotel inventory is modeled separately from reservation activity. `Hotel.rb` likely owns hotel metadata and its available rooms, while `Room.rb` defines individual bookable units and their availability/rate state. This separation allows booking logic to operate on room inventory without embedding it in guest records.
- `Hotel.rb`
- `Room.rb`
- `hotels.json`

#### Guest and Booking Records
Guests are modeled independently and linked to bookings rather than embedded in hotel inventory. `Guest.rb` likely holds guest identity/contact information; `Booking.rb` captures the reservation relationship among guest, hotel or room, dates, and booking status.
- `Guest.rb`
- `Booking.rb`
- `BookingService.rb`

#### Reviews and Payments
Reviews and payments are distinct post- or alongside-booking concerns. `Review.rb` provides a feedback record associated with hotel stays, while `payment.rb` encapsulates payment-related state or processing. These should remain downstream of successful booking creation rather than being part of room inventory management.
- `Review.rb`
- `payment.rb`
- `Booking.rb`

#### Persistence and Runtime Boundaries
The runtime is Ruby, using local JSON storage rather than an external database or web service. `hotels.json` is the material persistence boundary indicated by the repository; loading and saving are expected to occur from the application coordinator or hotel-management flow. No external infrastructure, API integration, or deployment runtime is evidenced by the supplied repository tree.
- `hotels.json`
- `hotel_booking_system.rb`
- `main.rb`

Main entry points: [`BookingService.rb`](https://github.com/tavish108/hotel_booking/blob/main/BookingService.rb) (Booking service), [`Booking.rb`](https://github.com/tavish108/hotel_booking/blob/main/Booking.rb) (Booking), [`hotel_booking_system.rb`](https://github.com/tavish108/hotel_booking/blob/main/hotel_booking_system.rb) (Booking system), [`Hotel.rb`](https://github.com/tavish108/hotel_booking/blob/main/Hotel.rb) (Hotel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_main(("Program entry<br/>Ruby entry point<br/>[main.rb]"))
  node_system["Booking system<br/>application coordinator"]
  node_hotel_data[("Hotel data<br/>JSON storage<br/>[hotels.json]")]
end

subgraph group_booking["Booking workflow"]
  node_booking_service["Booking service<br/>workflow service<br/>[BookingService.rb]"]
  node_booking["Booking<br/>reservation entity<br/>[Booking.rb]"]
  node_payment["Payment<br/>[payment.rb]"]
end

subgraph group_inventory["Hotel inventory"]
  node_hotel["Hotel<br/>inventory aggregate<br/>[Hotel.rb]"]
  node_room["Room<br/>bookable unit<br/>[Room.rb]"]
end

subgraph group_records["Guest records"]
  node_guest["Guest<br/>[Guest.rb]"]
  node_review["Review<br/>feedback record<br/>[Review.rb]"]
end

node_main -->|"starts"| node_system
node_system -->|"loads and saves"| node_hotel_data
node_system -->|"coordinates bookings"| node_booking_service
node_system -->|"manages inventory"| node_hotel
node_hotel_data -->|"supplies hotel data"| node_hotel
node_hotel -->|"contains"| node_room
node_booking_service -->|"checks availability"| node_room
node_booking_service -->|"uses guest"| node_guest
node_booking_service -->|"creates"| node_booking
node_booking_service -->|"triggers"| node_payment
node_booking -->|"belongs to"| node_guest
node_booking -->|"reserves"| node_room
node_booking -->|"has payment"| node_payment
node_review -.->|"follows stay"| node_booking
node_review -->|"rates"| node_hotel

click node_main "https://github.com/tavish108/hotel_booking/blob/main/main.rb"
click node_system "https://github.com/tavish108/hotel_booking/blob/main/hotel_booking_system.rb"
click node_hotel_data "https://github.com/tavish108/hotel_booking/blob/main/hotels.json"
click node_booking_service "https://github.com/tavish108/hotel_booking/blob/main/BookingService.rb"
click node_booking "https://github.com/tavish108/hotel_booking/blob/main/Booking.rb"
click node_payment "https://github.com/tavish108/hotel_booking/blob/main/payment.rb"
click node_hotel "https://github.com/tavish108/hotel_booking/blob/main/Hotel.rb"
click node_room "https://github.com/tavish108/hotel_booking/blob/main/Room.rb"
click node_guest "https://github.com/tavish108/hotel_booking/blob/main/Guest.rb"
click node_review "https://github.com/tavish108/hotel_booking/blob/main/Review.rb"

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_main,node_system,node_hotel_data toneBlue
class node_booking_service,node_booking,node_payment toneAmber
class node_hotel,node_room toneMint
class node_guest,node_review toneRose
```

## Components

### Runtime

- [Program entry](https://github.com/tavish108/hotel_booking/blob/main/main.rb): Ruby entry point · `main.rb`
- [Booking system](https://github.com/tavish108/hotel_booking/blob/main/hotel_booking_system.rb): application coordinator · Coordinates runtime flow and local hotel data. · `hotel_booking_system.rb`
- [Hotel data](https://github.com/tavish108/hotel_booking/blob/main/hotels.json): JSON storage · Local persistence boundary for hotel inventory. · `hotels.json`

### Booking workflow

- [Booking service](https://github.com/tavish108/hotel_booking/blob/main/BookingService.rb): workflow service · Validates availability and creates reservations. · `BookingService.rb`
- [Booking](https://github.com/tavish108/hotel_booking/blob/main/Booking.rb): reservation entity · `Booking.rb`
- [Payment](https://github.com/tavish108/hotel_booking/blob/main/payment.rb): payment entity · `payment.rb`

### Hotel inventory

- [Hotel](https://github.com/tavish108/hotel_booking/blob/main/Hotel.rb): inventory aggregate · `Hotel.rb`
- [Room](https://github.com/tavish108/hotel_booking/blob/main/Room.rb): bookable unit · Tracks availability and rate state. · `Room.rb`

### Guest records

- [Guest](https://github.com/tavish108/hotel_booking/blob/main/Guest.rb): guest entity · `Guest.rb`
- [Review](https://github.com/tavish108/hotel_booking/blob/main/Review.rb): feedback record · `Review.rb`

## Connections

- Program entry → Booking system: starts
- Booking system → Hotel data: loads and saves
- Booking system → Booking service: coordinates bookings
- Booking system → Hotel: manages inventory
- Hotel data → Hotel: supplies hotel data
- Hotel → Room: contains
- Booking service → Room: checks availability
- Booking service → Guest: uses guest
- Booking service → Booking: creates
- Booking service → Payment: triggers
- Booking → Guest: belongs to
- Booking → Room: reserves
- Booking → Payment: has payment
- Review → Booking: follows stay
- Review → Hotel: rates
