# kanguyen2802/hotel-booking-demand architecture

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

- Interactive diagram: https://gitdiagram.com/kanguyen2802/hotel-booking-demand
- Repository: https://github.com/kanguyen2802/hotel-booking-demand

## Overview

#### 1. Purpose and entry points
This is an analytics and decision-support repository for hotel booking demand, focused on improving proxy RevPAR while controlling cancellations, overbooking/walk risk, and channel conflict across City and Resort properties. It produces a recommend-only pricing and booking-risk playbook, not an operational booking engine.

Primary entry points:
- Project workflow and decisions: `README.md`
- Static executive dashboard: `dashboard-html/index.html`
- Power BI report project: `dashboard-powerbi/Power BI/Hotel Booking Demand v2.pbip`
- Reproducible analytical workflow: `notebooks/01_data_cleaning.ipynb`
- Final playbook and implementation material: `reports/28_finalize_dynamic_pricing_playbook.md`, `reports/34_implementation_guide.md`

#### 2. Data foundation and serving boundary
The curated analytical source is `data/hotel_bookings_v5.csv`; it represents cleaned booking-level data and feeds notebooks, SQL import, and star-schema construction. Raw Kaggle data is intentionally external/local-only for full reproduction.

A Python transformation builds dashboard-oriented dimensional and fact CSVs:
- `scripts/build_star_schema_v5.py`
- `data/star schema/hotel_bookings_normalized.csv`
- `data/star schema/revpar_monthly.csv`

The key semantic boundary is that occupancy and RevPAR are proxies derived from booking/cancellation records; there is no true room-inventory or accounting P&L source.

#### 3. Analytical and modeling pipeline
The notebook sequence is the main research/control flow: cleaning → EDA/statistical testing → cancellation prediction → demand/ADR/RevPAR forecasting → elasticity and pricing optimization → simulation/back-testing.

Representative stages:
- Data cleaning and derived KPIs: `notebooks/01_data_cleaning.ipynb`
- Cancellation and ADR EDA: `notebooks/02_eda_stage1_cancellation.ipynb`, `notebooks/03_eda_stage2_adr.ipynb`
- Demand and revenue forecasting: `notebooks/18_demand_forecasting_dynamic_pricing.ipynb`
- City/Resort price elasticity and optimization: `notebooks/22_dynamic_pricing_elasticity_city_resort.ipynb`, `notebooks/23_dynamic_pricing_optimization_city_resort.ipynb`
- Scenario validation: `notebooks/27_validate_simulation.ipynb`

The architecture deliberately separates City and Resort analysis; a shared policy or pooled model is treated as a decision risk.

#### 4. Cancellation-risk decision layer
Cancellation prediction supports booking tiers and controlled buffer policies rather than autonomous customer actions. The model evolution is retained in notebooks and portable parameter/policy artifacts:
- `models/Cancellation Predict Model v2/09_cancellation_model_v2_2.ipynb`
- `models/Cancellation Predict Model v2/artifacts/threshold_policy_v2_2.json`
- `models/Cancellation Predict Model v2/artifacts/fp_reduction_policy_v2_1.json`

The intended flow is booking attributes → calibrated cancellation probability → Low/Medium/High risk tier → friction, CRM confirmation, or constrained refill/buffer recommendation. Leakage-prone post-booking fields are excluded from the modeling approach.

#### 5. SQL and BI semantic layer
SQL Server provides a separately executable star-schema path: import the curated CSV, create schema, populate facts/dimensions, then run business questions.
- `sql/01_create_star_schema.sql`
- `sql/02_populate_star_schema.sql`
- `sql/03_business_questions.sql`

Power BI is a versioned PBIP/TMDL implementation of the same decision views. Its semantic model defines facts, dimensions, relationships, and measures:
- `dashboard-powerbi/Power BI/Hotel Booking Demand v2.SemanticModel/definition/model.tmdl`
- `dashboard-powerbi/Power BI/Hotel Booking Demand v2.SemanticModel/definition/relationships.tmdl`
- `dashboard-powerbi/Power BI/Hotel Booking Demand v2.SemanticModel/definition/tables/Fact_Booking.tmdl`

This is a file-based BI project requiring Power BI Desktop and local CSV path refresh; it is not backed by a deployed API.

#### 6. Presentation and deployment surfaces
The HTML dashboard is a static vanilla-JS/Chart.js application. `index.html` establishes the page shell; application state/rendering, charts, and range interaction are separated:
- `dashboard-html/js/app.js`
- `dashboard-html/js/charts.js`
- `dashboard-html/js/rangeBrush.js`

`dashboard-html/_export_data.py` refreshes dashboard data from the star-schema CSV layer. Vercel deployment is configured in `dashboard-html/vercel.json`.

A separate static SCQA narrative report is deployed similarly:
- `reports/html/index.html`
- `reports/html/scqa_data_storytelling.html`
- `reports/html/vercel.json`

External infrastructure is limited to Vercel static hosting, SQL Server for optional T-SQL execution, Power BI Desktop for the PBIP report, and the original Kaggle dataset for raw-data reproduction.

Main entry points: [`data/star schema/hotel_bookings_normalized.csv`](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/data/star%20schema/hotel_bookings_normalized.csv) (Normalized bookings), [`reports/28_finalize_dynamic_pricing_playbook.md`](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/reports/28_finalize_dynamic_pricing_playbook.md) (Dynamic pricing playbook), [`data/hotel_bookings_v5.csv`](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/data/hotel_bookings_v5.csv) (Curated booking data), [`scripts/build_star_schema_v5.py`](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/scripts/build_star_schema_v5.py) (Star-schema builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data foundation"]
  node_curated_bookings[("Curated booking data<br/>CSV dataset")]
  node_star_builder["Star-schema builder<br/>Python transformation"]
  node_normalized_bookings[("Normalized bookings<br/>CSV dimension/fact source")]
  node_monthly_revpar[("Monthly proxy RevPAR<br/>CSV metric dataset<br/>[revpar_monthly.csv]")]
end

subgraph group_research["Analytical workflow"]
  node_cleaning_kpis["Cleaning and KPI derivation<br/>research notebook"]
  node_cancellation_adr_eda["Cancellation and ADR EDA<br/>research notebooks"]
  node_forecasting["Demand and revenue forecasting<br/>forecasting notebook"]
  node_city_resort_elasticity["City/Resort elasticity<br/>segmented pricing notebook"]
  node_pricing_optimization["Pricing optimization<br/>optimization notebook"]
  node_simulation_validation["Scenario validation<br/>simulation notebook"]
end

subgraph group_risk["Cancellation-risk policy"]
  node_cancellation_model["Cancellation model<br/>calibrated risk model"]
  node_threshold_policy["Risk-tier threshold policy<br/>policy artifact"]
  node_fp_policy["False-positive reduction policy<br/>policy artifact"]
  node_playbook["Dynamic pricing playbook<br/>recommendation artifact"]
  node_implementation_guide["Implementation guide<br/>delivery guidance"]
end

subgraph group_serving["BI and presentation"]
  node_sql_star_schema[("SQL Server star schema<br/>T-SQL schema and load")]
  node_sql_questions["SQL business questions<br/>T-SQL analysis"]
  node_powerbi_model["Power BI semantic model<br/>PBIP/TMDL model<br/>[model.tmdl]"]
  node_powerbi_report["Power BI report<br/>PBIP report project"]
  node_dashboard_export["Dashboard data export<br/>Python export<br/>[_export_data.py]"]
  node_html_dashboard["Executive dashboard<br/>static Chart.js app<br/>[index.html]"]
  node_scqa_report["SCQA narrative report<br/>static report"]
end

node_curated_bookings -->|"input"| node_star_builder
node_star_builder -->|"writes"| node_normalized_bookings
node_star_builder -->|"writes"| node_monthly_revpar
node_curated_bookings -->|"analyzed by"| node_cleaning_kpis
node_cleaning_kpis -->|"feeds"| node_cancellation_adr_eda
node_cancellation_adr_eda -->|"informs"| node_forecasting
node_forecasting -->|"demand inputs"| node_city_resort_elasticity
node_city_resort_elasticity -->|"elasticity inputs"| node_pricing_optimization
node_pricing_optimization -->|"validates scenarios"| node_simulation_validation
node_curated_bookings -->|"training data"| node_cancellation_model
node_cancellation_model -->|"calibrates tiers"| node_threshold_policy
node_cancellation_model -->|"controls false positives"| node_fp_policy
node_threshold_policy -->|"buffer and friction guidance"| node_playbook
node_fp_policy -->|"refines policy"| node_playbook
node_simulation_validation -->|"validated pricing guidance"| node_playbook
node_playbook -->|"operationalizes"| node_implementation_guide
node_normalized_bookings -->|"imports"| node_sql_star_schema
node_sql_star_schema -->|"queries"| node_sql_questions
node_normalized_bookings -->|"local CSV refresh"| node_powerbi_model
node_monthly_revpar -->|"local CSV refresh"| node_powerbi_model
node_powerbi_model -->|"renders"| node_powerbi_report
node_normalized_bookings -->|"exports from"| node_dashboard_export
node_monthly_revpar -->|"exports from"| node_dashboard_export
node_dashboard_export -->|"refreshes data"| node_html_dashboard

click node_curated_bookings "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/data/hotel_bookings_v5.csv"
click node_star_builder "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/scripts/build_star_schema_v5.py"
click node_normalized_bookings "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/data/star%20schema/hotel_bookings_normalized.csv"
click node_monthly_revpar "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/data/star%20schema/revpar_monthly.csv"
click node_cleaning_kpis "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/notebooks/01_data_cleaning.ipynb"
click node_cancellation_adr_eda "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/notebooks/02_eda_stage1_cancellation.ipynb"
click node_forecasting "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/notebooks/18_demand_forecasting_dynamic_pricing.ipynb"
click node_city_resort_elasticity "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/notebooks/22_dynamic_pricing_elasticity_city_resort.ipynb"
click node_pricing_optimization "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/notebooks/23_dynamic_pricing_optimization_city_resort.ipynb"
click node_simulation_validation "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/notebooks/27_validate_simulation.ipynb"
click node_cancellation_model "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/models/Cancellation%20Predict%20Model%20v2/09_cancellation_model_v2_2.ipynb"
click node_threshold_policy "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/models/Cancellation%20Predict%20Model%20v2/artifacts/threshold_policy_v2_2.json"
click node_fp_policy "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/models/Cancellation%20Predict%20Model%20v2/artifacts/fp_reduction_policy_v2_1.json"
click node_playbook "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/reports/28_finalize_dynamic_pricing_playbook.md"
click node_sql_star_schema "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/sql/02_populate_star_schema.sql"
click node_sql_questions "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/sql/03_business_questions.sql"
click node_powerbi_model "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/dashboard-powerbi/Power%20BI/Hotel%20Booking%20Demand%20v2.SemanticModel/definition/model.tmdl"
click node_powerbi_report "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/dashboard-powerbi/Power%20BI/Hotel%20Booking%20Demand%20v2.pbip"
click node_dashboard_export "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/dashboard-html/_export_data.py"
click node_html_dashboard "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/dashboard-html/index.html"
click node_scqa_report "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/reports/html/scqa_data_storytelling.html"
click node_implementation_guide "https://github.com/kanguyen2802/hotel-booking-demand/blob/main/reports/34_implementation_guide.md"

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_curated_bookings,node_star_builder,node_normalized_bookings,node_monthly_revpar toneBlue
class node_cleaning_kpis,node_cancellation_adr_eda,node_forecasting,node_city_resort_elasticity,node_pricing_optimization,node_simulation_validation toneAmber
class node_cancellation_model,node_threshold_policy,node_fp_policy,node_playbook,node_implementation_guide toneMint
class node_sql_star_schema,node_sql_questions,node_powerbi_model,node_powerbi_report,node_dashboard_export,node_html_dashboard,node_scqa_report toneRose
```

## Components

### Data foundation

- [Curated booking data](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/data/hotel_bookings_v5.csv): CSV dataset · Cleaned booking-level analytical source; occupancy and RevPAR remain proxies. · `data/hotel_bookings_v5.csv`
- [Star-schema builder](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/scripts/build_star_schema_v5.py): Python transformation · `scripts/build_star_schema_v5.py`
- [Normalized bookings](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/data/star%20schema/hotel_bookings_normalized.csv): CSV dimension/fact source · `data/star schema/hotel_bookings_normalized.csv`
- [Monthly proxy RevPAR](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/data/star%20schema/revpar_monthly.csv): CSV metric dataset · `data/star schema/revpar_monthly.csv`

### Analytical workflow

- [Cleaning and KPI derivation](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/notebooks/01_data_cleaning.ipynb): research notebook · `notebooks/01_data_cleaning.ipynb`
- [Cancellation and ADR EDA](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/notebooks/02_eda_stage1_cancellation.ipynb): research notebooks · `notebooks/02_eda_stage1_cancellation.ipynb`
- [Demand and revenue forecasting](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/notebooks/18_demand_forecasting_dynamic_pricing.ipynb): forecasting notebook · `notebooks/18_demand_forecasting_dynamic_pricing.ipynb`
- [City/Resort elasticity](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/notebooks/22_dynamic_pricing_elasticity_city_resort.ipynb): segmented pricing notebook · Property types are modeled separately to avoid pooled-policy risk. · `notebooks/22_dynamic_pricing_elasticity_city_resort.ipynb`
- [Pricing optimization](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/notebooks/23_dynamic_pricing_optimization_city_resort.ipynb): optimization notebook · `notebooks/23_dynamic_pricing_optimization_city_resort.ipynb`
- [Scenario validation](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/notebooks/27_validate_simulation.ipynb): simulation notebook · `notebooks/27_validate_simulation.ipynb`

### Cancellation-risk policy

- [Cancellation model](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/models/Cancellation%20Predict%20Model%20v2/09_cancellation_model_v2_2.ipynb): calibrated risk model · Uses booking attributes while excluding leakage-prone post-booking fields. · `models/Cancellation Predict Model v2/09_cancellation_model_v2_2.ipynb`
- [Risk-tier threshold policy](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/models/Cancellation%20Predict%20Model%20v2/artifacts/threshold_policy_v2_2.json): policy artifact · Maps cancellation probability to Low, Medium, and High tiers. · `models/Cancellation Predict Model v2/artifacts/threshold_policy_v2_2.json`
- [False-positive reduction policy](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/models/Cancellation%20Predict%20Model%20v2/artifacts/fp_reduction_policy_v2_1.json): policy artifact · `models/Cancellation Predict Model v2/artifacts/fp_reduction_policy_v2_1.json`
- [Dynamic pricing playbook](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/reports/28_finalize_dynamic_pricing_playbook.md): recommendation artifact · Recommend-only guidance for pricing, buffers, and booking risk. · `reports/28_finalize_dynamic_pricing_playbook.md`
- [Implementation guide](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/reports/34_implementation_guide.md): delivery guidance · `reports/34_implementation_guide.md`

### BI and presentation

- [SQL Server star schema](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/sql/02_populate_star_schema.sql): T-SQL schema and load · Separately executable import and fact/dimension population path. · `sql/02_populate_star_schema.sql`
- [SQL business questions](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/sql/03_business_questions.sql): T-SQL analysis · `sql/03_business_questions.sql`
- [Power BI semantic model](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/dashboard-powerbi/Power%20BI/Hotel%20Booking%20Demand%20v2.SemanticModel/definition/model.tmdl): PBIP/TMDL model · Local CSV-refresh semantic layer with facts, dimensions, relationships, and measures. · `dashboard-powerbi/Power BI/Hotel Booking Demand v2.SemanticModel/definition/model.tmdl`
- [Power BI report](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/dashboard-powerbi/Power%20BI/Hotel%20Booking%20Demand%20v2.pbip): PBIP report project · Opened locally in Power BI Desktop; not served by an API. · `dashboard-powerbi/Power BI/Hotel Booking Demand v2.pbip`
- [Dashboard data export](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/dashboard-html/_export_data.py): Python export · `dashboard-html/_export_data.py`
- [Executive dashboard](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/dashboard-html/index.html): static Chart.js app · Static dashboard with separate application state, charts, and range interaction. · `dashboard-html/index.html`
- [SCQA narrative report](https://github.com/kanguyen2802/hotel-booking-demand/blob/main/reports/html/scqa_data_storytelling.html): static report · `reports/html/scqa_data_storytelling.html`

## Connections

- Curated booking data → Star-schema builder: input
- Star-schema builder → Normalized bookings: writes
- Star-schema builder → Monthly proxy RevPAR: writes
- Curated booking data → Cleaning and KPI derivation: analyzed by
- Cleaning and KPI derivation → Cancellation and ADR EDA: feeds
- Cancellation and ADR EDA → Demand and revenue forecasting: informs
- Demand and revenue forecasting → City/Resort elasticity: demand inputs
- City/Resort elasticity → Pricing optimization: elasticity inputs
- Pricing optimization → Scenario validation: validates scenarios
- Curated booking data → Cancellation model: training data
- Cancellation model → Risk-tier threshold policy: calibrates tiers
- Cancellation model → False-positive reduction policy: controls false positives
- Risk-tier threshold policy → Dynamic pricing playbook: buffer and friction guidance
- False-positive reduction policy → Dynamic pricing playbook: refines policy
- Scenario validation → Dynamic pricing playbook: validated pricing guidance
- Dynamic pricing playbook → Implementation guide: operationalizes
- Normalized bookings → SQL Server star schema: imports
- SQL Server star schema → SQL business questions: queries
- Normalized bookings → Power BI semantic model: local CSV refresh
- Monthly proxy RevPAR → Power BI semantic model: local CSV refresh
- Power BI semantic model → Power BI report: renders
- Normalized bookings → Dashboard data export: exports from
- Monthly proxy RevPAR → Dashboard data export: exports from
- Dashboard data export → Executive dashboard: refreshes data
