# mmahmoud95/wild-oasis architecture

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

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

## Overview

##### Main System Components

A. Client Layer
- Next.js Frontend (App Router)
- Authentication UI Components
- Reservation Management Components
- Cabin Browsing Components

B. Server Layer (Next.js API Routes)
- Authentication Handler
- Server Actions
- API Routes

C. External Services
- Supabase (Database & Authentication)
- Next Auth Integration

##### Component Organization

Structure the components as follows:

**Frontend Components Layer**
- Layout Components
- Header
- Navigation
- Footer
- SideNavigation
- Feature Components
- Cabin Management
- CabinList
- CabinCard
- Cabin Detail
- Reservation System
- ReservationForm
- ReservationList
- ReservationCard
- Auth Components
- SignInButton
- SignOutButton
- UpdateProfileForm

##### Data Flow Representation

- User authentication flow through NextAuth.js
- Reservation creation/management flow
- Cabin browsing and booking flow
- Data persistence flow to Supabase

##### Specific Implementation Details

a. App Router Structure
- Route hierarchy (/cabins, /account, /login)
- Dynamic routes ([cabinId])
- Server components vs client components

b. Authentication Flow
- NextAuth.js integration
- Supabase authentication
- Protected routes and middleware

c. Data Management
- Server actions for data mutations
- API routes for data fetching
- Supabase database interactions

##### Key Architectural Patterns

Emphasize:
- The App Router architecture of Next.js 13+
- Server Components usage
- Client-side interactivity boundaries
- Data fetching patterns

##### External Services Layer (Supabase)

→ Synchronous operations
⇢ Asynchronous operations
⇄ Two-way data flow

Remember to:
- Keep components grouped by feature
- Clear boundaries between client/server
- Protected vs public routes
- Loading and error states

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Client Layer"
        UI[User Interface]
        
        subgraph "Layout Components"
            Header["Header"]:::component
            Nav["Navigation"]:::component
            Footer["Footer"]:::component
            SideNav["Side Navigation"]:::component
        end
        
        subgraph "Feature Components"
            subgraph "Cabin Management"
                CabinList["Cabin List"]:::component
                CabinCard["Cabin Card"]:::component
                CabinDetail["Cabin Detail"]:::component
            end
            
            subgraph "Reservation System"
                ReservForm["Reservation Form"]:::component
                ReservList["Reservation List"]:::component
                ReservCard["Reservation Card"]:::component
                ReservContext["Reservation Context"]:::component
                ReservManage["Reservation Management"]:::component
            end
            
            subgraph "Auth Components"
                SignIn["Sign In Button"]:::component
                SignOut["Sign Out Button"]:::component
                UpdateProfile["Update Profile Form"]:::component
            end
        end
    end
    
    subgraph "Server Layer"
        ServerActions["Server Actions"]:::server
        AuthService["Authentication Service"]:::server
        DataService["Data Service"]:::server
        AuthHandler["Auth Handler"]:::server
        MainLayout["Main Layout"]:::server
        Middleware["Protected Routes Middleware"]:::server
        AccountMgmt["Account Management"]:::server
        CabinBrowse["Cabin Browsing"]:::server
    end
    
    subgraph "External Services"
        Supabase["Supabase DB & Auth"]:::external
        NextAuth["NextAuth.js"]:::external
    end
    
    %% Relationships
    UI --> Header
    UI --> Nav
    UI --> Footer
    UI --> SideNav
    
    UI --> CabinList
    CabinList --> CabinCard
    CabinCard --> CabinDetail
    
    UI --> ReservForm
    UI --> ReservList
    ReservList --> ReservCard
    ReservForm --> ReservContext
    ReservContext --> ReservManage
    
    UI --> SignIn
    UI --> SignOut
    UI --> UpdateProfile
    
    SignIn --> AuthHandler
    SignOut --> AuthHandler
    AuthHandler --> NextAuth
    NextAuth --> Supabase
    
    ServerActions --> DataService
    DataService --> Supabase
    AuthService --> Supabase
    
    %% Click Events
    click Header "https://github.com/mmahmoud95/wild-oasis/blob/main/app/_components/Header.js"
    click Nav "https://github.com/mmahmoud95/wild-oasis/blob/main/app/_components/Navigation.js"
    click Footer "https://github.com/mmahmoud95/wild-oasis/blob/main/app/_components/Footer.js"
    click SideNav "https://github.com/mmahmoud95/wild-oasis/blob/main/app/_components/SideNavigation.js"
    click CabinList "https://github.com/mmahmoud95/wild-oasis/blob/main/app/_components/CabinList.js"
    click CabinCard "https://github.com/mmahmoud95/wild-oasis/blob/main/app/_components/CabinCard.js"
    click CabinDetail "https://github.com/mmahmoud95/wild-oasis/blob/main/app/cabins/[cabinId]/page.js"
    click ReservForm "https://github.com/mmahmoud95/wild-oasis/blob/main/app/_components/ReservationForm.js"
    click ReservList "https://github.com/mmahmoud95/wild-oasis/blob/main/app/_components/ReservationList.js"
    click ReservCard "https://github.com/mmahmoud95/wild-oasis/blob/main/app/_components/ReservationCard.js"
    click ReservContext "https://github.com/mmahmoud95/wild-oasis/blob/main/app/_components/ReservationContext.js"
    click ReservManage "https://github.com/mmahmoud95/wild-oasis/blob/main/app/account/reservations/page.js"
    click SignIn "https://github.com/mmahmoud95/wild-oasis/blob/main/app/_components/SignInButton.js"
    click SignOut "https://github.com/mmahmoud95/wild-oasis/blob/main/app/_components/SignOutButton.js"
    click UpdateProfile "https://github.com/mmahmoud95/wild-oasis/blob/main/app/_components/UpdateProfileForm.js"
    click AuthHandler "https://github.com/mmahmoud95/wild-oasis/blob/main/app/api/auth/[...nextauth]/route.js"
    click ServerActions "https://github.com/mmahmoud95/wild-oasis/blob/main/app/_lib/actions.js"
    click AuthService "https://github.com/mmahmoud95/wild-oasis/blob/main/app/_lib/auth.js"
    click DataService "https://github.com/mmahmoud95/wild-oasis/blob/main/app/_lib/data-service.js"
    click Supabase "https://github.com/mmahmoud95/wild-oasis/blob/main/app/_lib/supabase.js"
    click MainLayout "https://github.com/mmahmoud95/wild-oasis/blob/main/app/layout.js"
    click Middleware "https://github.com/mmahmoud95/wild-oasis/blob/main/middleware.js"
    click AccountMgmt "https://github.com/mmahmoud95/wild-oasis/blob/main/app/account/page.js"
    click CabinBrowse "https://github.com/mmahmoud95/wild-oasis/blob/main/app/cabins/page.js"
    
    %% Styles
    classDef component fill:#2196F3,stroke:#1565C0,color:white
    classDef server fill:#4CAF50,stroke:#2E7D32,color:white
    classDef external fill:#9C27B0,stroke:#6A1B9A,color:white
    
    %% Legend
    subgraph Legend
        L1["Frontend Component"]:::component
        L2["Server Component"]:::server
        L3["External Service"]:::external
    end
```
