# reddyakshay19/hclhack_usecase3 architecture

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

- Interactive diagram: https://gitdiagram.com/reddyakshay19/hclhack_usecase3
- Repository: https://github.com/reddyakshay19/hclhack_usecase3

## Overview

#### 1. System Purpose and Entry Points
This repository implements a hotel booking system with an Angular single-page frontend and an ASP.NET Core backend API. Customers search rooms, create and view bookings, and proceed through a payment flow; administrators manage rooms/bookings and access reporting.

Backend startup and HTTP composition begin at `HotelBookingAPI/Program.cs`. Frontend bootstrap and route setup begin at `frontend/src/main.ts` and `frontend/src/app/app.routes.ts`.

#### 2. Angular Application Shell and Navigation
The Angular frontend is organized as route-level pages backed by reusable core services and shared UI. The root component/configuration establishes application-wide providers and shell behavior in:
- `frontend/src/app/app.component.ts`
- `frontend/src/app/app.config.ts`
- `frontend/src/app/app.routes.ts`

Routes divide public/customer experiences (home, search, booking, payment, account bookings) from admin experiences. Shared navbar, loader, and alert components provide cross-page interface behavior under `frontend/src/app/shared/components`.

#### 3. Client Authentication and Access Boundary
Authentication state and API request credentials are centralized in:
- `frontend/src/app/core/services/auth.service.ts`
- `frontend/src/app/core/interceptors/auth.interceptor.ts`
- `frontend/src/app/core/guards/auth.guard.ts`

The interceptor attaches stored credentials to outgoing HTTP calls, while guards restrict authenticated and administrator routes. Admin-specific authorization is isolated in `frontend/src/app/core/guards/admin.guard.ts`; this is primarily a client navigation boundary and must be enforced again by the API.

#### 4. Booking and Payment Flow
Customer flow moves from search and room selection through booking creation, confirmation/detail, then payment:
- `frontend/src/app/pages/search/search.component.ts`
- `frontend/src/app/pages/booking-form/booking-form.component.ts`
- `frontend/src/app/pages/payment/payment.component.ts`

Frontend orchestration is performed through `frontend/src/app/core/services/booking.service.ts`, `frontend/src/app/core/services/room.service.ts`, and `frontend/src/app/core/services/payment.service.ts`. The README identifies payment as a demo stub, so it should not be treated as an external payment-provider integration.

On the API side, HTTP requests enter `HotelBookingAPI/Controllers/BookingsController.cs` and `HotelBookingAPI/Controllers/PaymentsController.cs`, then delegate to service interfaces/implementations.

#### 5. Backend Application and Domain Services
The ASP.NET Core API uses a controller → service interface → service implementation structure. Core business operations are represented by:
- `HotelBookingAPI/Controllers/RoomsController.cs`
- `HotelBookingAPI/Services/RoomService.cs`
- `HotelBookingAPI/Services/BookingService.cs`

Service contracts in `HotelBookingAPI/Interfaces/` separate controllers from business logic. DTOs form the API input/output boundary, including `HotelBookingAPI/DTOs/BookingDTOs.cs`, `HotelBookingAPI/DTOs/RoomDTOs.cs`, and `HotelBookingAPI/DTOs/SearchDTOs.cs`, preventing direct exposure of persistence entities.

#### 6. Persistence, Availability, and Reporting
Entity Framework Core persistence is centered on `HotelBookingAPI/Data/AppDbContext.cs`, with schema history in `HotelBookingAPI/Migrations/`. The core model captures rooms, customers, bookings, payments, and per-day room occupancy:
- `HotelBookingAPI/Models/Room.cs`
- `HotelBookingAPI/Models/Booking.cs`
- `HotelBookingAPI/Models/DailyRoomBooking.cs`

`DailyRoomBooking` is architecturally significant for date-based availability/conflict handling. Reporting is a separate service/API capability via `HotelBookingAPI/Services/ReportService.cs` and `HotelBookingAPI/Controllers/AdminController.cs`.

#### 7. Operational Boundaries
The principal runtime boundary is browser Angular SPA to ASP.NET Core HTTP API; environment-specific frontend API configuration resides in `frontend/src/environments/environment.ts`. API exception handling is centralized through `HotelBookingAPI/Middleware/ExceptionMiddleware.cs`.

The backend includes an email abstraction and implementation at `HotelBookingAPI/Interfaces/IEmailService.cs` and `HotelBookingAPI/Services/EmailService.cs`; the file tree does not establish the concrete external email provider. Database provider and deployment infrastructure are likewise not determinable from the supplied files, though EF migrations confirm a relational persistence lifecycle.

Main entry points: [`HotelBookingAPI/Program.cs`](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Program.cs) (HTTP composition), [`frontend/src/app/app.routes.ts`](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/frontend/src/app/app.routes.ts) (App shell & routes), [`HotelBookingAPI/Data/AppDbContext.cs`](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Data/AppDbContext.cs) (EF Core context), [`frontend/src/app/core/services/booking.service.ts`](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/frontend/src/app/core/services/booking.service.ts) (Booking, room & payment APIs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Angular SPA"]
  node_frontend_bootstrap(("Bootstrap<br/>Angular entry<br/>[main.ts]"))
  node_frontend_shell["App shell &amp; routes<br/>Angular shell<br/>[app.routes.ts]"]
  node_shared_ui["Shared UI<br/>Angular components"]
  node_auth_client["Auth client boundary<br/>service, interceptor &amp; guards<br/>[auth.service.ts]"]
  node_customer_pages["Search, booking &amp; payment<br/>customer pages"]
  node_booking_client["Booking, room &amp; payment APIs<br/>Angular services<br/>[booking.service.ts]"]
  node_api_environment["API environment<br/>runtime config<br/>[environment.ts]"]
end

subgraph group_api["ASP.NET Core API"]
  node_api_startup(("HTTP composition<br/>ASP.NET startup<br/>[Program.cs]"))
  node_exception_middleware["Exception handling<br/>API middleware"]
  node_booking_payment_controllers["Booking &amp; payment endpoints<br/>API controllers"]
  node_room_controller["Room endpoints<br/>API controller<br/>[RoomsController.cs]"]
  node_admin_reporting["Admin reporting endpoints<br/>API controller<br/>[AdminController.cs]"]
  node_dto_boundary["DTO boundary<br/>API contracts<br/>[BookingDTOs.cs]"]
  node_service_contracts["Service contracts<br/>interfaces"]
  node_domain_services["Room &amp; booking services<br/>business services<br/>[BookingService.cs]"]
  node_report_service["Report service<br/>business service<br/>[ReportService.cs]"]
  node_email_service["Email service<br/>notification abstraction<br/>[EmailService.cs]"]
end

subgraph group_data["Persistence"]
  node_db_context[("EF Core context<br/>data access<br/>[AppDbContext.cs]")]
  node_booking_model[("Booking &amp; occupancy model<br/>EF entities")]
  node_migrations["Schema migrations<br/>EF schema history"]
end

node_frontend_bootstrap -->|"starts"| node_frontend_shell
node_frontend_shell -->|"uses"| node_shared_ui
node_frontend_shell -->|"applies route guards"| node_auth_client
node_frontend_shell -->|"routes to"| node_customer_pages
node_customer_pages -->|"orchestrates through"| node_booking_client
node_booking_client -->|"reads API target"| node_api_environment
node_booking_client -->|"HTTP requests"| node_api_startup
node_auth_client -->|"credentialed requests"| node_api_startup
node_api_startup -->|"composes"| node_exception_middleware
node_api_startup -->|"routes to"| node_booking_payment_controllers
node_api_startup -->|"routes to"| node_room_controller
node_api_startup -->|"routes to"| node_admin_reporting
node_booking_payment_controllers -->|"accepts/returns"| node_dto_boundary
node_room_controller -->|"accepts/returns"| node_dto_boundary
node_booking_payment_controllers -->|"delegates via"| node_service_contracts
node_room_controller -->|"delegates via"| node_service_contracts
node_admin_reporting -->|"delegates to"| node_report_service
node_service_contracts -->|"implemented by"| node_domain_services
node_domain_services -->|"persists through"| node_db_context
node_domain_services -.->|"notifies through"| node_email_service
node_report_service -->|"queries"| node_db_context
node_db_context -->|"maps"| node_booking_model
node_migrations -->|"evolves schema"| node_db_context

click node_frontend_bootstrap "https://github.com/reddyakshay19/hclhack_usecase3/blob/master/frontend/src/main.ts"
click node_frontend_shell "https://github.com/reddyakshay19/hclhack_usecase3/blob/master/frontend/src/app/app.routes.ts"
click node_shared_ui "https://github.com/reddyakshay19/hclhack_usecase3/tree/master/frontend/src/app/shared/components"
click node_auth_client "https://github.com/reddyakshay19/hclhack_usecase3/blob/master/frontend/src/app/core/services/auth.service.ts"
click node_customer_pages "https://github.com/reddyakshay19/hclhack_usecase3/blob/master/frontend/src/app/pages/search/search.component.ts"
click node_booking_client "https://github.com/reddyakshay19/hclhack_usecase3/blob/master/frontend/src/app/core/services/booking.service.ts"
click node_api_environment "https://github.com/reddyakshay19/hclhack_usecase3/blob/master/frontend/src/environments/environment.ts"
click node_api_startup "https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Program.cs"
click node_exception_middleware "https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Middleware/ExceptionMiddleware.cs"
click node_booking_payment_controllers "https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Controllers/BookingsController.cs"
click node_room_controller "https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Controllers/RoomsController.cs"
click node_admin_reporting "https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Controllers/AdminController.cs"
click node_dto_boundary "https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/DTOs/BookingDTOs.cs"
click node_domain_services "https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Services/BookingService.cs"
click node_report_service "https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Services/ReportService.cs"
click node_email_service "https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Services/EmailService.cs"
click node_db_context "https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Data/AppDbContext.cs"
click node_booking_model "https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Models/DailyRoomBooking.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_frontend_bootstrap,node_frontend_shell,node_shared_ui,node_auth_client,node_customer_pages,node_booking_client,node_api_environment toneBlue
class node_api_startup,node_exception_middleware,node_booking_payment_controllers,node_room_controller,node_admin_reporting,node_dto_boundary,node_service_contracts,node_domain_services,node_report_service,node_email_service toneAmber
class node_db_context,node_booking_model,node_migrations toneMint
```

## Components

### Angular SPA

- [Bootstrap](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/frontend/src/main.ts): Angular entry · `frontend/src/main.ts`
- [App shell & routes](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/frontend/src/app/app.routes.ts): Angular shell · `frontend/src/app/app.routes.ts`
- [Shared UI](https://github.com/reddyakshay19/hclhack_usecase3/tree/master/frontend/src/app/shared/components): Angular components · Navbar, loader, and alerts support route pages. · `frontend/src/app/shared/components`
- [Auth client boundary](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/frontend/src/app/core/services/auth.service.ts): service, interceptor & guards · Adds credentials and restricts customer/admin navigation. · `frontend/src/app/core/services/auth.service.ts`
- [Search, booking & payment](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/frontend/src/app/pages/search/search.component.ts): customer pages · `frontend/src/app/pages/search/search.component.ts`
- [Booking, room & payment APIs](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/frontend/src/app/core/services/booking.service.ts): Angular services · Orchestrates customer API calls; payment is a demo stub. · `frontend/src/app/core/services/booking.service.ts`
- [API environment](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/frontend/src/environments/environment.ts): runtime config · `frontend/src/environments/environment.ts`

### ASP.NET Core API

- [HTTP composition](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Program.cs): ASP.NET startup · `HotelBookingAPI/Program.cs`
- [Exception handling](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Middleware/ExceptionMiddleware.cs): API middleware · `HotelBookingAPI/Middleware/ExceptionMiddleware.cs`
- [Booking & payment endpoints](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Controllers/BookingsController.cs): API controllers · `HotelBookingAPI/Controllers/BookingsController.cs`
- [Room endpoints](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Controllers/RoomsController.cs): API controller · `HotelBookingAPI/Controllers/RoomsController.cs`
- [Admin reporting endpoints](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Controllers/AdminController.cs): API controller · `HotelBookingAPI/Controllers/AdminController.cs`
- [DTO boundary](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/DTOs/BookingDTOs.cs): API contracts · Prevents persistence entities from being exposed directly. · `HotelBookingAPI/DTOs/BookingDTOs.cs`
- **Service contracts**: interfaces
- [Room & booking services](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Services/BookingService.cs): business services · `HotelBookingAPI/Services/BookingService.cs`
- [Report service](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Services/ReportService.cs): business service · `HotelBookingAPI/Services/ReportService.cs`
- [Email service](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Services/EmailService.cs): notification abstraction · Concrete provider is not established. · `HotelBookingAPI/Services/EmailService.cs`

### Persistence

- [EF Core context](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Data/AppDbContext.cs): data access · `HotelBookingAPI/Data/AppDbContext.cs`
- [Booking & occupancy model](https://github.com/reddyakshay19/hclhack_usecase3/blob/master/HotelBookingAPI/Models/DailyRoomBooking.cs): EF entities · DailyRoomBooking drives date-based availability and conflict handling. · `HotelBookingAPI/Models/DailyRoomBooking.cs`
- **Schema migrations**: EF schema history

## Connections

- Bootstrap → App shell & routes: starts
- App shell & routes → Shared UI: uses
- App shell & routes → Auth client boundary: applies route guards
- App shell & routes → Search, booking & payment: routes to
- Search, booking & payment → Booking, room & payment APIs: orchestrates through
- Booking, room & payment APIs → API environment: reads API target
- Booking, room & payment APIs → HTTP composition: HTTP requests
- Auth client boundary → HTTP composition: credentialed requests
- HTTP composition → Exception handling: composes
- HTTP composition → Booking & payment endpoints: routes to
- HTTP composition → Room endpoints: routes to
- HTTP composition → Admin reporting endpoints: routes to
- Booking & payment endpoints → DTO boundary: accepts/returns
- Room endpoints → DTO boundary: accepts/returns
- Booking & payment endpoints → Service contracts: delegates via
- Room endpoints → Service contracts: delegates via
- Admin reporting endpoints → Report service: delegates to
- Service contracts → Room & booking services: implemented by
- Room & booking services → EF Core context: persists through
- Room & booking services → Email service: notifies through
- Report service → EF Core context: queries
- EF Core context → Booking & occupancy model: maps
- Schema migrations → EF Core context: evolves schema
