How reddyakshay19/hclhack_usecase3 works
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: Program.cs HTTP composition · app.routes.ts App shell & routes · AppDbContext.cs EF Core context · booking.service.ts Booking, room & payment APIs
Components 20
Angular SPA
- Bootstrap
frontend/src/main.ts - App shell & routes
frontend/src/app/app.routes.ts - Shared UI · Navbar, loader, and alerts support route pages.
frontend/src/app/shared/components - Auth client boundary · Adds credentials and restricts customer/admin navigation.
frontend/src/app/core/services/auth.service.ts - Search, booking & payment
frontend/src/app/pages/search/search.component.ts - Booking, room & payment APIs · Orchestrates customer API calls; payment is a demo stub.
frontend/src/app/core/services/booking.service.ts - API environment
frontend/src/environments/environment.ts
ASP.NET Core API
- HTTP composition
HotelBookingAPI/Program.cs - Exception handling
HotelBookingAPI/Middleware/ExceptionMiddleware.cs - Booking & payment endpoints
HotelBookingAPI/Controllers/BookingsController.cs - Room endpoints
HotelBookingAPI/Controllers/RoomsController.cs - Admin reporting endpoints
HotelBookingAPI/Controllers/AdminController.cs - DTO boundary · Prevents persistence entities from being exposed directly.
HotelBookingAPI/DTOs/BookingDTOs.cs - Service contracts
- Room & booking services
HotelBookingAPI/Services/BookingService.cs - Report service
HotelBookingAPI/Services/ReportService.cs - Email service · Concrete provider is not established.
HotelBookingAPI/Services/EmailService.cs
Persistence
- EF Core context
HotelBookingAPI/Data/AppDbContext.cs - Booking & occupancy model · DailyRoomBooking drives date-based availability and conflict handling.
HotelBookingAPI/Models/DailyRoomBooking.cs - Schema migrations
Connections 23
- 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