# abidev2003/the-wild-oasis architecture

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

- Interactive diagram: https://gitdiagram.com/abidev2003/the-wild-oasis
- Repository: https://github.com/abidev2003/the-wild-oasis

## Overview

1. **Overall shape**
   This is a single-page React application for hotel operations (“The Wild Oasis”), with the browser as the primary runtime and Supabase as the backend platform. The codebase is organized as a feature-driven front end rather than a traditional layered server/client split.

2. **Top-level frontend architecture**
   `src/main.jsx` bootstraps the app, `src/App.jsx` wires the route tree, and `src/ui/AppLayout.jsx` provides the authenticated shell. The app uses route-level pages under `src/pages` for major screens such as Dashboard, Bookings, Cabins, Check-In, Restaurant, Settings, Account, Login, and password reset flows.

3. **Feature modules as the main business boundary**
   Most business logic lives under `src/features/*`, with one folder per domain:
   - `authentication` for login/signup/OAuth/password reset/user profile
   - `bookings` for booking CRUD and booking detail views
   - `cabins` for cabin CRUD and table operations
   - `check-in-out` for arrival/departure processing
   - `dashboard` for operational metrics and charts
   - `restaurant` for orders tied to bookings
   - `invoice` for invoice generation and email delivery
   - `settings` for app/hotel configuration  
   Each feature bundles its UI components and custom hooks together, which keeps domain logic close to the screens that use it.

4. **Data access layer**
   `src/services/*` is the boundary to Supabase and external integrations. Separate API modules exist for auth, bookings, cabins, restaurant, settings, and email. The feature hooks generally call these service modules rather than accessing Supabase directly, which keeps components mostly presentational.

5. **Backend platform and persistence**
   Supabase is the external system of record for authentication, database tables, and likely storage. The `supabase/migrations` folder shows schema evolution and triggers, including employee table creation and cleanup-related triggers. This means the app depends on Supabase not just for CRUD, but also for server-side behavior enforced by database triggers.

6. **Serverless/edge function boundary**
   There are Supabase Edge Functions under `supabase/functions` for `auto-cancel`, `send-email`, and `send-invoice`. These extend the backend beyond simple database access and are important architectural nodes:
   - `auto-cancel` suggests scheduled/automated booking cancellation logic
   - `send-email` handles outbound email delivery
   - `send-invoice` likely generates or dispatches invoice-related messages  
   The invoice feature in `src/features/invoice` ties into these backend functions.

7. **Authentication and route protection**
   Authentication is a first-class subsystem. The app includes login, signup, OAuth callback handling, forgot/reset password pages, user update forms, and logout. `src/ui/ProtectedRoute.jsx` indicates route gating for authenticated areas, while `src/features/authentication/useUser.js` and related hooks centralize session/user state.

8. **Core operational workflows**
   The main hotel workflows are:
   - **Bookings**: list, view, create, edit, delete
   - **Cabins**: manage cabin inventory and properties
   - **Check-in/out**: confirm arrivals, handle departures, view today’s activity
   - **Restaurant**: create restaurant orders linked to bookings
   - **Dashboard**: summarize recent bookings, stays, duration, and sales  
   These workflows are implemented as feature hooks plus tables/forms/modals in `src/ui`.

9. **Shared UI and interaction primitives**
   `src/ui` contains the reusable design system and shell components: buttons, inputs, tables, modals, forms, filters, pagination, headers, sidebar, navigation, dark mode toggle, spinners, and confirmation dialogs. This is the main presentation layer used across all features.

10. **State and cross-cutting concerns**
   Cross-cutting client state is handled with small utilities and context:
   - `src/context/DarkModeContext.jsx` for theme mode
   - `src/hooks/useLocalStorageState.js` for persisted client preferences
   - `src/hooks/useOutsideClick.js` and `useMoveBack.js` for UI behavior  
   This suggests most domain state is server-backed, while local state is limited to UI preferences and interactions.

11. **Media, uploads, and invoice output**
   `src/data/Uploader.jsx` and `src/ui/FileInput.jsx` indicate file upload support, probably tied to Supabase storage for cabin images or avatars. Invoice generation is split between a React invoice component (`InvoicePDF.jsx`) and email dispatch service/function, implying a workflow that produces a document and then sends it through backend email infrastructure.

12. **Deployment and project tooling**
   The app is built with Vite and appears to be deployed on Netlify (`netlify.toml`). The repository also contains feature-plan docs and Supabase local metadata, which signals an actively evolving production app with database/schema managed alongside the frontend code.

13. **What an architecture diagram should show**
   The central diagram should have:
   - a browser-based React SPA
   - a shared UI shell and feature modules
   - a service layer bridging to Supabase
   - Supabase Auth, Postgres, Storage, and Edge Functions as the backend boundary
   - specialized flows for authentication, bookings/cabins, check-in/out, restaurant orders, dashboard analytics, and invoices/emails  
   The main architectural idea is that domain behavior lives in feature hooks/components, while persistence and automation live in Supabase.

Main entry points: [`src/pages`](https://github.com/abidev2003/the-wild-oasis/tree/main/src/pages) (Route pages), [`supabase`](https://github.com/abidev2003/the-wild-oasis/tree/main/supabase) (Supabase), [`src/App.jsx`](https://github.com/abidev2003/the-wild-oasis/blob/main/src/App.jsx) (App router), [`src/services/apiBookings.js`](https://github.com/abidev2003/the-wild-oasis/blob/main/src/services/apiBookings.js) (Bookings API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React SPA"]
  node_main(("main<br/>bootstrap<br/>[main.jsx]"))
  node_app["App router<br/>routing<br/>[App.jsx]"]
  node_layout["App shell<br/>layout<br/>[AppLayout.jsx]"]
  node_protected["Protected route<br/>auth guard<br/>[ProtectedRoute.jsx]"]
  node_pages["Route pages<br/>screens"]
  node_sharedui["Shared UI<br/>design system"]
end

subgraph group_features["Domain features"]
  node_auth["Auth feature<br/>domain module"]
  node_bookings["Bookings feature<br/>domain module"]
  node_cabins["Cabins feature<br/>domain module"]
  node_checkin["Check-in flow<br/>workflow"]
  node_dashboard["Dashboard feature<br/>analytics"]
  node_restaurant["Restaurant feature<br/>workflow"]
  node_invoice["Invoice feature<br/>workflow"]
  node_settings["Settings feature<br/>configuration"]
end

subgraph group_services["API services"]
  node_apiauth["Auth API<br/>supabase client<br/>[apiAuth.js]"]
  node_apibookings["Bookings API<br/>supabase client<br/>[apiBookings.js]"]
  node_apicabins["Cabins API<br/>supabase client<br/>[apiCabins.js]"]
  node_apirestaurant["Restaurant API<br/>supabase client<br/>[apiRestaurant.js]"]
  node_apisettings["Settings API<br/>supabase client<br/>[apiSettings.js]"]
  node_emailsvc["Email service<br/>integration<br/>[emailService.js]"]
end

subgraph group_backend["Supabase backend"]
  node_supabase[("Supabase<br/>backend platform")]
  node_migrations["Migrations<br/>schema/sql"]
  node_edgefx["Edge functions<br/>serverless"]
  node_storage[("Storage<br/>object store")]
end

node_main -->|"bootstraps"| node_app
node_app -->|"renders shell"| node_layout
node_app -->|"guards routes"| node_protected
node_app -->|"routes"| node_pages
node_layout -->|"uses"| node_sharedui
node_pages -->|"uses"| node_auth
node_pages -->|"uses"| node_bookings
node_pages -->|"uses"| node_cabins
node_pages -->|"uses"| node_checkin
node_pages -->|"uses"| node_dashboard
node_pages -->|"uses"| node_restaurant
node_pages -->|"uses"| node_settings
node_bookings -->|"calls"| node_apibookings
node_cabins -->|"calls"| node_apicabins
node_checkin -->|"calls"| node_apibookings
node_dashboard -->|"reads"| node_apibookings
node_restaurant -->|"calls"| node_apirestaurant
node_settings -->|"calls"| node_apisettings
node_auth -->|"calls"| node_apiauth
node_invoice -->|"prepares"| node_emailsvc
node_apiauth -->|"auth"| node_supabase
node_apibookings -->|"data"| node_supabase
node_apicabins -->|"data"| node_supabase
node_apirestaurant -->|"data"| node_supabase
node_apisettings -->|"data"| node_supabase
node_emailsvc -->|"invokes"| node_edgefx
node_invoice -->|"invokes"| node_edgefx
node_supabase -->|"contains"| node_migrations
node_supabase -->|"hosts"| node_edgefx
node_supabase -->|"stores"| node_storage

click node_main "https://github.com/abidev2003/the-wild-oasis/blob/main/src/main.jsx"
click node_app "https://github.com/abidev2003/the-wild-oasis/blob/main/src/App.jsx"
click node_layout "https://github.com/abidev2003/the-wild-oasis/blob/main/src/ui/AppLayout.jsx"
click node_protected "https://github.com/abidev2003/the-wild-oasis/blob/main/src/ui/ProtectedRoute.jsx"
click node_pages "https://github.com/abidev2003/the-wild-oasis/tree/main/src/pages"
click node_sharedui "https://github.com/abidev2003/the-wild-oasis/tree/main/src/ui"
click node_auth "https://github.com/abidev2003/the-wild-oasis/tree/main/src/features/authentication"
click node_bookings "https://github.com/abidev2003/the-wild-oasis/tree/main/src/features/bookings"
click node_cabins "https://github.com/abidev2003/the-wild-oasis/tree/main/src/features/cabins"
click node_checkin "https://github.com/abidev2003/the-wild-oasis/tree/main/src/features/check-in-out"
click node_dashboard "https://github.com/abidev2003/the-wild-oasis/tree/main/src/features/dashboard"
click node_restaurant "https://github.com/abidev2003/the-wild-oasis/tree/main/src/features/restaurant"
click node_invoice "https://github.com/abidev2003/the-wild-oasis/tree/main/src/features/invoice"
click node_settings "https://github.com/abidev2003/the-wild-oasis/tree/main/src/features/settings"
click node_apiauth "https://github.com/abidev2003/the-wild-oasis/blob/main/src/services/apiAuth.js"
click node_apibookings "https://github.com/abidev2003/the-wild-oasis/blob/main/src/services/apiBookings.js"
click node_apicabins "https://github.com/abidev2003/the-wild-oasis/blob/main/src/services/apiCabins.js"
click node_apirestaurant "https://github.com/abidev2003/the-wild-oasis/blob/main/src/services/apiRestaurant.js"
click node_apisettings "https://github.com/abidev2003/the-wild-oasis/blob/main/src/services/apiSettings.js"
click node_emailsvc "https://github.com/abidev2003/the-wild-oasis/blob/main/src/services/emailService.js"
click node_supabase "https://github.com/abidev2003/the-wild-oasis/tree/main/supabase"
click node_migrations "https://github.com/abidev2003/the-wild-oasis/tree/main/supabase/migrations"
click node_edgefx "https://github.com/abidev2003/the-wild-oasis/tree/main/supabase/functions"
click node_storage "https://github.com/abidev2003/the-wild-oasis/tree/main/supabase"

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_app,node_layout,node_protected,node_pages,node_sharedui toneBlue
class node_auth,node_bookings,node_cabins,node_checkin,node_dashboard,node_restaurant,node_invoice,node_settings toneAmber
class node_apiauth,node_apibookings,node_apicabins,node_apirestaurant,node_apisettings,node_emailsvc toneMint
class node_supabase,node_migrations,node_edgefx,node_storage toneRose
```

## Components

### React SPA

Browser runtime, routing, shell, and shared UI

- [main](https://github.com/abidev2003/the-wild-oasis/blob/main/src/main.jsx): bootstrap · Vite entry point that mounts the app · `src/main.jsx`
- [App router](https://github.com/abidev2003/the-wild-oasis/blob/main/src/App.jsx): routing · Defines the route tree and top-level navigation · `src/App.jsx`
- [App shell](https://github.com/abidev2003/the-wild-oasis/blob/main/src/ui/AppLayout.jsx): layout · Authenticated application frame and chrome · `src/ui/AppLayout.jsx`
- [Protected route](https://github.com/abidev2003/the-wild-oasis/blob/main/src/ui/ProtectedRoute.jsx): auth guard · Blocks unauthenticated access to private screens · `src/ui/ProtectedRoute.jsx`
- [Route pages](https://github.com/abidev2003/the-wild-oasis/tree/main/src/pages): screens · Page-level screens for dashboard, bookings, cabins, check-in, restaurant, settings, account, and auth flows · `src/pages`
- [Shared UI](https://github.com/abidev2003/the-wild-oasis/tree/main/src/ui): design system · Reusable inputs, tables, modals, navigation, and shell components · `src/ui`

### Domain features

Feature-driven business modules and workflows

- [Auth feature](https://github.com/abidev2003/the-wild-oasis/tree/main/src/features/authentication): domain module · Login, signup, OAuth, password reset, profile update, and session state · `src/features/authentication`
- [Bookings feature](https://github.com/abidev2003/the-wild-oasis/tree/main/src/features/bookings): domain module · Booking CRUD, detail views, and booking table operations · `src/features/bookings`
- [Cabins feature](https://github.com/abidev2003/the-wild-oasis/tree/main/src/features/cabins): domain module · Cabin inventory CRUD and table operations · `src/features/cabins`
- [Check-in flow](https://github.com/abidev2003/the-wild-oasis/tree/main/src/features/check-in-out): workflow · Arrival and departure processing plus today activity · `src/features/check-in-out`
- [Dashboard feature](https://github.com/abidev2003/the-wild-oasis/tree/main/src/features/dashboard): analytics · Operational metrics, charts, and recent activity · `src/features/dashboard`
- [Restaurant feature](https://github.com/abidev2003/the-wild-oasis/tree/main/src/features/restaurant): workflow · Orders tied to bookings and restaurant activity · `src/features/restaurant`
- [Invoice feature](https://github.com/abidev2003/the-wild-oasis/tree/main/src/features/invoice): workflow · Invoice generation and outbound email dispatch · `src/features/invoice`
- [Settings feature](https://github.com/abidev2003/the-wild-oasis/tree/main/src/features/settings): configuration · Application and hotel settings management · `src/features/settings`

### API services

Client-side integration layer for Supabase and external actions

- [Auth API](https://github.com/abidev2003/the-wild-oasis/blob/main/src/services/apiAuth.js): supabase client · Authentication/session calls to Supabase · `src/services/apiAuth.js`
- [Bookings API](https://github.com/abidev2003/the-wild-oasis/blob/main/src/services/apiBookings.js): supabase client · Data access for bookings and stay records · `src/services/apiBookings.js`
- [Cabins API](https://github.com/abidev2003/the-wild-oasis/blob/main/src/services/apiCabins.js): supabase client · Data access for cabin inventory and images · `src/services/apiCabins.js`
- [Restaurant API](https://github.com/abidev2003/the-wild-oasis/blob/main/src/services/apiRestaurant.js): supabase client · Data access for restaurant bookings and orders · `src/services/apiRestaurant.js`
- [Settings API](https://github.com/abidev2003/the-wild-oasis/blob/main/src/services/apiSettings.js): supabase client · Data access for app and hotel settings · `src/services/apiSettings.js`
- [Email service](https://github.com/abidev2003/the-wild-oasis/blob/main/src/services/emailService.js): integration · Client-side helper for email/invoice delivery · `src/services/emailService.js`

### Supabase backend

Auth, database, storage, migrations, and edge functions

- [Supabase](https://github.com/abidev2003/the-wild-oasis/tree/main/supabase): backend platform · External system of record for auth, data, storage, and edge functions · `supabase`
- [Migrations](https://github.com/abidev2003/the-wild-oasis/tree/main/supabase/migrations): schema/sql · Database schema evolution, triggers, and cleanup logic · `supabase/migrations`
- [Edge functions](https://github.com/abidev2003/the-wild-oasis/tree/main/supabase/functions): serverless · Automated booking and email/invoice backend functions · `supabase/functions`
- [Storage](https://github.com/abidev2003/the-wild-oasis/tree/main/supabase): object store · File storage for uploads and media assets · `supabase`

## Connections

- main → App router: bootstraps · Entry point mounts the router tree
- App router → App shell: renders shell · Authenticated routes use the app layout
- App router → Protected route: guards routes · Private areas are wrapped by access control
- App router → Route pages: routes · Top-level page screens are attached to the router
- App shell → Shared UI: uses · Shell composes reusable UI primitives
- Route pages → Auth feature: uses · Auth-related screens delegate to the auth feature
- Route pages → Bookings feature: uses · Bookings pages are backed by booking workflows
- Route pages → Cabins feature: uses · Cabin screens rely on the cabins feature
- Route pages → Check-in flow: uses · Check-in pages use the arrival/departure flow
- Route pages → Dashboard feature: uses · Dashboard page aggregates metrics feature code
- Route pages → Restaurant feature: uses · Restaurant page uses booking-linked order workflows
- Route pages → Settings feature: uses · Settings page uses configuration feature code
- Bookings feature → Bookings API: calls · Booking hooks and actions go through the API layer
- Cabins feature → Cabins API: calls · Cabin CRUD is mediated by the cabins API
- Check-in flow → Bookings API: calls · Check-in and checkout rely on booking records
- Dashboard feature → Bookings API: reads · Analytics pulls booking and stay data
- Restaurant feature → Restaurant API: calls · Restaurant orders and booking lookups use the restaurant API
- Settings feature → Settings API: calls · Settings forms persist through the settings API
- Auth feature → Auth API: calls · Login, signup, session, and password flows use auth API
- Invoice feature → Email service: prepares · Invoice workflow prepares outbound email payloads
- Auth API → Supabase: auth · Authentication is backed by Supabase Auth
- Bookings API → Supabase: data · Booking data comes from Supabase
- Cabins API → Supabase: data · Cabin data and media metadata live in Supabase
- Restaurant API → Supabase: data · Restaurant data is stored in Supabase
- Settings API → Supabase: data · Settings are persisted in Supabase
- Email service → Edge functions: invokes · Email delivery is delegated to Supabase edge functions
- Invoice feature → Edge functions: invokes · Invoice generation ties into serverless invoice/email delivery
- Supabase → Migrations: contains · Schema and trigger changes are managed as migrations
- Supabase → Edge functions: hosts · Backend automation runs as edge functions
- Supabase → Storage: stores · Uploads and media assets are handled via storage
