# benardelia/stayhub-web architecture

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

- Interactive diagram: https://gitdiagram.com/benardelia/stayhub-web
- Repository: https://github.com/benardelia/stayhub-web

## Overview

Estantly is a React front end for hotel discovery, booking and account management, with separate hotel and platform administration. Guest flow runs from search and property details through authenticated checkout, then payment and booking status; administrators manage properties and operational records. The README documents token refresh, idempotent booking and M-Pesa/Pesapal payment behavior. Edges reflect the route table, excerpted imports/calls, or README; unsampled screens are grouped by their exact source directories, and unverified API interactions are not expanded.

Main entry points: [`src/App.jsx`](https://github.com/benardelia/stayhub-web/blob/main/src/App.jsx) (Route table), [`src/pages/site`](https://github.com/benardelia/stayhub-web/tree/main/src/pages/site) (Browse stays), [`src/pages/admin`](https://github.com/benardelia/stayhub-web/tree/main/src/pages/admin) (Property operations), [`src/api/client.js`](https://github.com/benardelia/stayhub-web/blob/main/src/api/client.js) (HTTP client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["App and access"]
  node_router["Route table<br/>[App.jsx]"]
  node_auth["Auth context<br/>[AuthProvider.jsx]"]
  node_guards["Route guards<br/>[guards.jsx]"]
end

subgraph group_guest["Guest booking"]
  node_guest_site["Browse stays"]
  node_favourites["Saved stays<br/>[useFavourites.js]"]
  node_checkout["Checkout<br/>[Checkout.jsx]"]
  node_payment_panel["Payment panel<br/>[PayPanel.jsx]"]
  node_account["Bookings and account"]
end

subgraph group_hotel["Hotel back office"]
  node_hotel_admin_pages["Property operations"]
  node_hotel_context["Hotel context<br/>[HotelContext.js]"]
  node_image_upload["Image uploads<br/>[ImageUploader.jsx]"]
end

subgraph group_platform["Platform operations"]
  node_platform_pages["Platform controls"]
end

subgraph group_shared["API and shared runtime"]
  node_catalog_api["Stay catalog API<br/>[catalog.js]"]
  node_guest_api["Guest API<br/>[guest.js]"]
  node_hotel_api["Hotel admin API<br/>[admin.js]"]
  node_platform_api["Platform API<br/>[platform.js]"]
  node_http_client["HTTP client<br/>[client.js]"]
  node_session["Stored session<br/>[session.js]"]
  node_query["Query cache<br/>[query.js]"]
  node_ui["Shared UI"]
end

node_guest_actor(("Guest"))
node_hotel_operator(("Hotel operator"))
node_platform_admin(("Platform admin"))
node_payment_provider["Payment services"]

node_guest_actor -->|"opens app"| node_router
node_hotel_operator -->|"opens app"| node_router
node_platform_admin -->|"opens app"| node_router
node_router -->|"routes to"| node_guest_site
node_router -->|"routes to"| node_checkout
node_router -->|"routes to"| node_account
node_router -->|"routes to"| node_hotel_admin_pages
node_router -->|"routes to"| node_platform_pages
node_router -->|"protects routes"| node_guards
node_auth -->|"uses session"| node_session
node_auth -->|"loads user data"| node_guest_api
node_guest_site -->|"fetches stays"| node_catalog_api
node_guest_site -->|"uses saved stays"| node_favourites
node_checkout -.->|"creates booking"| node_guest_api
node_checkout -.->|"opens booking"| node_account
node_account -->|"renders payment"| node_payment_panel
node_payment_panel -->|"checks payment"| node_guest_api
node_payment_panel -.->|"starts payment"| node_payment_provider
node_hotel_admin_pages -->|"manages property"| node_hotel_api
node_hotel_admin_pages -->|"uses hotel context"| node_hotel_context
node_hotel_admin_pages -->|"uses uploader"| node_image_upload
node_image_upload -->|"uploads images"| node_hotel_api
node_platform_pages -->|"calls API"| node_platform_api
node_hotel_api -->|"sends requests"| node_http_client
node_guest_api -->|"sends requests"| node_http_client
node_catalog_api -->|"sends requests"| node_http_client
node_platform_api -.->|"sends requests"| node_http_client
node_http_client -->|"reads and refreshes"| node_session
node_guest_site -->|"caches search"| node_query
node_hotel_admin_pages -->|"caches reviews"| node_query
node_platform_pages -->|"caches lists"| node_query
node_guest_site -->|"renders components"| node_ui
node_payment_panel -->|"renders components"| node_ui

click node_router "https://github.com/benardelia/stayhub-web/blob/main/src/App.jsx"
click node_auth "https://github.com/benardelia/stayhub-web/blob/main/src/auth/AuthProvider.jsx"
click node_guards "https://github.com/benardelia/stayhub-web/blob/main/src/auth/guards.jsx"
click node_guest_site "https://github.com/benardelia/stayhub-web/tree/main/src/pages/site"
click node_catalog_api "https://github.com/benardelia/stayhub-web/blob/main/src/api/catalog.js"
click node_favourites "https://github.com/benardelia/stayhub-web/blob/main/src/hooks/useFavourites.js"
click node_checkout "https://github.com/benardelia/stayhub-web/blob/main/src/pages/site/Checkout.jsx"
click node_guest_api "https://github.com/benardelia/stayhub-web/blob/main/src/api/guest.js"
click node_payment_panel "https://github.com/benardelia/stayhub-web/blob/main/src/components/site/PayPanel.jsx"
click node_account "https://github.com/benardelia/stayhub-web/tree/main/src/pages/account"
click node_hotel_admin_pages "https://github.com/benardelia/stayhub-web/tree/main/src/pages/admin"
click node_hotel_api "https://github.com/benardelia/stayhub-web/blob/main/src/api/admin.js"
click node_hotel_context "https://github.com/benardelia/stayhub-web/blob/main/src/components/admin/HotelContext.js"
click node_image_upload "https://github.com/benardelia/stayhub-web/blob/main/src/components/admin/ImageUploader.jsx"
click node_platform_pages "https://github.com/benardelia/stayhub-web/tree/main/src/pages/platform"
click node_platform_api "https://github.com/benardelia/stayhub-web/blob/main/src/api/platform.js"
click node_http_client "https://github.com/benardelia/stayhub-web/blob/main/src/api/client.js"
click node_session "https://github.com/benardelia/stayhub-web/blob/main/src/api/session.js"
click node_query "https://github.com/benardelia/stayhub-web/blob/main/src/lib/query.js"
click node_ui "https://github.com/benardelia/stayhub-web/tree/main/src/components/ui"

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_router,node_auth,node_guards toneBlue
class node_guest_site,node_favourites,node_checkout,node_payment_panel,node_account toneAmber
class node_hotel_admin_pages,node_hotel_context,node_image_upload toneMint
class node_platform_pages toneRose
class node_catalog_api,node_guest_api,node_hotel_api,node_platform_api,node_http_client,node_session,node_query,node_ui,node_guest_actor,node_hotel_operator,node_platform_admin,node_payment_provider toneIndigo
```

## Components

### App and access

- [Route table](https://github.com/benardelia/stayhub-web/blob/main/src/App.jsx): `src/App.jsx`
- [Auth context](https://github.com/benardelia/stayhub-web/blob/main/src/auth/AuthProvider.jsx): `src/auth/AuthProvider.jsx`
- [Route guards](https://github.com/benardelia/stayhub-web/blob/main/src/auth/guards.jsx): `src/auth/guards.jsx`

### Guest booking

- [Browse stays](https://github.com/benardelia/stayhub-web/tree/main/src/pages/site): `src/pages/site`
- [Saved stays](https://github.com/benardelia/stayhub-web/blob/main/src/hooks/useFavourites.js): `src/hooks/useFavourites.js`
- [Checkout](https://github.com/benardelia/stayhub-web/blob/main/src/pages/site/Checkout.jsx): `src/pages/site/Checkout.jsx`
- [Payment panel](https://github.com/benardelia/stayhub-web/blob/main/src/components/site/PayPanel.jsx): `src/components/site/PayPanel.jsx`
- [Bookings and account](https://github.com/benardelia/stayhub-web/tree/main/src/pages/account): `src/pages/account`

### Hotel back office

- [Property operations](https://github.com/benardelia/stayhub-web/tree/main/src/pages/admin): `src/pages/admin`
- [Hotel context](https://github.com/benardelia/stayhub-web/blob/main/src/components/admin/HotelContext.js): `src/components/admin/HotelContext.js`
- [Image uploads](https://github.com/benardelia/stayhub-web/blob/main/src/components/admin/ImageUploader.jsx): `src/components/admin/ImageUploader.jsx`

### Platform operations

- [Platform controls](https://github.com/benardelia/stayhub-web/tree/main/src/pages/platform): `src/pages/platform`

### API and shared runtime

- [Stay catalog API](https://github.com/benardelia/stayhub-web/blob/main/src/api/catalog.js): `src/api/catalog.js`
- [Guest API](https://github.com/benardelia/stayhub-web/blob/main/src/api/guest.js): `src/api/guest.js`
- [Hotel admin API](https://github.com/benardelia/stayhub-web/blob/main/src/api/admin.js): `src/api/admin.js`
- [Platform API](https://github.com/benardelia/stayhub-web/blob/main/src/api/platform.js): `src/api/platform.js`
- [HTTP client](https://github.com/benardelia/stayhub-web/blob/main/src/api/client.js): `src/api/client.js`
- [Stored session](https://github.com/benardelia/stayhub-web/blob/main/src/api/session.js): `src/api/session.js`
- [Query cache](https://github.com/benardelia/stayhub-web/blob/main/src/lib/query.js): `src/lib/query.js`
- [Shared UI](https://github.com/benardelia/stayhub-web/tree/main/src/components/ui): `src/components/ui`

### Other components

- **Guest**
- **Hotel operator**
- **Platform admin**
- **Payment services**

## Connections

- Guest → Route table: opens app (evidence: `src/App.jsx`)
- Hotel operator → Route table: opens app (evidence: `src/App.jsx`)
- Platform admin → Route table: opens app (evidence: `src/App.jsx`)
- Route table → Browse stays: routes to (evidence: `src/App.jsx`)
- Route table → Checkout: routes to (evidence: `src/App.jsx`)
- Route table → Bookings and account: routes to (evidence: `src/App.jsx`)
- Route table → Property operations: routes to (evidence: `src/App.jsx`)
- Route table → Platform controls: routes to (evidence: `src/App.jsx`)
- Route table → Route guards: protects routes (evidence: `src/App.jsx`)
- Auth context → Stored session: uses session (evidence: `src/auth/AuthProvider.jsx`)
- Auth context → Guest API: loads user data (evidence: `src/auth/AuthProvider.jsx`)
- Browse stays → Stay catalog API: fetches stays (evidence: `src/pages/site/HotelDetail.jsx`)
- Browse stays → Saved stays: uses saved stays (evidence: `src/pages/site/HotelDetail.jsx`)
- Checkout → Guest API: creates booking (evidence: `README.md`)
- Checkout → Bookings and account: opens booking (evidence: `README.md`)
- Bookings and account → Payment panel: renders payment (evidence: `src/pages/account/BookingDetail.jsx`)
- Payment panel → Guest API: checks payment (evidence: `src/components/site/PayPanel.jsx`)
- Payment panel → Payment services: starts payment (evidence: `README.md`)
- Property operations → Hotel admin API: manages property (evidence: `src/pages/admin/Reviews.jsx`)
- Property operations → Hotel context: uses hotel context (evidence: `src/pages/admin/Reviews.jsx`)
- Property operations → Image uploads: uses uploader (evidence: `src/pages/admin/Rooms.jsx`)
- Image uploads → Hotel admin API: uploads images (evidence: `src/components/admin/ImageUploader.jsx`)
- Platform controls → Platform API: calls API (evidence: `src/pages/platform/Hotels.jsx`)
- Hotel admin API → HTTP client: sends requests (evidence: `src/api/admin.js`)
- Guest API → HTTP client: sends requests (evidence: `src/api/guest.js`)
- Stay catalog API → HTTP client: sends requests (evidence: `src/api/catalog.js`)
- Platform API → HTTP client: sends requests
- HTTP client → Stored session: reads and refreshes (evidence: `src/api/client.js`)
- Browse stays → Query cache: caches search (evidence: `src/pages/site/Search.jsx`)
- Property operations → Query cache: caches reviews (evidence: `src/pages/admin/Reviews.jsx`)
- Platform controls → Query cache: caches lists (evidence: `src/pages/platform/Hotels.jsx`)
- Browse stays → Shared UI: renders components (evidence: `src/pages/site/Search.jsx`)
- Payment panel → Shared UI: renders components (evidence: `src/components/site/PayPanel.jsx`)
