# magic9701/booking-nest architecture

> Architecture diagram of the GitHub repository magic9701/booking-nest, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/magic9701/booking-nest
- Repository: https://github.com/magic9701/booking-nest

## Overview

##### Project type and purpose
- This is a full-stack Next.js 13 application (TypeScript, app router) for a vacation-rental marketplace.
- Users browse properties, manage favorites, book stays, handle payments, view trips, and administrators manage rentals.

##### File structure
- Top level:
- app/… – Next.js pages (page.tsx) and serverless API routes (app/api/…)
- components/… – UI and feature components (booking, cards, forms, navbar, etc.)
- data/… – static lookup data (categories, amenities)
- hooks/, lib/, utils/… – custom hooks, utilities (date/calendar, DB access, schemas, supabase auth)
- prisma/schema.prisma – database schema via Prisma ORM
- config files – tsconfig.json, next.config.mjs, tailwind.config.ts, vercel.json

- Patterns:
- Component-driven UI (atomic & domain components)
- Layered directory: app (presentation & API), utils/lib (business logic), prisma (data layer)
- Serverless functions for geocode, payment, confirmation

##### README for additional insights
- Bootstrapped with create-next-app – no custom architecture doc
- Uses next/font and Tailwind CSS for styling
- Deploys on Vercel

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        NextJsPages["Next.js Pages\n(app/)"]:::frontend
        subgraph "Pages"
            direction TB
            Checkout["Checkout Page"]:::frontend
            Favorites["Favorites Page"]:::frontend
            ProfileView["View Profile Page"]:::frontend
            ProfileCreate["Create Profile Page"]:::frontend
            PropertyDetails["Property Details Page"]:::frontend
            subgraph "Rentals Management Pages"
                direction TB
                RentalCreate["Create Rental Page"]:::frontend
                RentalEdit["Edit Rental Page"]:::frontend
                AdminRentals["Admin Rentals Dashboard"]:::frontend
                OwnerDashboard["Owner Rentals Dashboard"]:::frontend
                ReservationView["Reservation View Page"]:::frontend
            end
            Trips["Trips Page"]:::frontend
        end
        subgraph "UI Components"
            direction TB
            AtomicUI["Atomic UI Components"]:::frontend
            BookingComp["Booking Components"]:::frontend
            CardComp["Card Components"]:::frontend
            FormComp["Form Components"]:::frontend
            HomeWidgets["Home Page Widgets"]:::frontend
            NavbarComp["Navbar Components"]:::frontend
            PropertyComp["Property Detail Components"]:::frontend
            RentalDashboardComp["Rental Dashboard Components"]:::frontend
            TripsComp["Trips Components"]:::frontend
            CommonComp["Common Reusable Components"]:::frontend
        end
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        direction TB
        NextJsServer["Next.js Server\n(SSR/SSG + API routes)"]:::backend
        subgraph "API Routes"
            direction TB
            ConfirmAPI["Confirmation Endpoint"]:::backend
            GeocodeAPI["Geocoding Endpoint"]:::backend
            PaymentAPI["Payment Endpoint"]:::backend
        end
        subgraph "Utilities / Lib"
            direction TB
            DBUtil["DB Access (utils/db.ts)"]:::backend
            AuthUtil["Supabase Auth (utils/supabase.ts)"]:::backend
            SchemasUtil["Validation Schemas (utils/schemas.ts)"]:::backend
            CalendarUtil["Date & Calendar Helpers (utils/calendar.ts)"]:::backend
            HelperUtil["Generic Helpers (utils/helper.ts)"]:::backend
            StoreUtil["Global State Store (utils/store.ts)"]:::backend
            TypesUtil["Shared Types (utils/types.ts)"]:::backend
            ActionUtil["Action Handlers (utils/action.ts)"]:::backend
            SharedLib["Shared Library Functions (lib/utils.ts)"]:::backend
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        PrismaSchema["Prisma Schema\n(prisma/schema.prisma)"]:::data
        Database["Relational Database\n(PostgreSQL/MySQL)"]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        SupabaseAuth["Supabase Auth Service"]:::external
        GeocodeService["Geocoding API\n(Google/Mapbox)"]:::external
        StripeService["Payment Gateway\n(Stripe)"]:::external
    end

    %% Connections
    NextJsPages -->|renders via HTTP| NextJsServer
    Checkout --> NextJsServer
    Favorites --> NextJsServer
    ProfileView --> NextJsServer
    ProfileCreate --> NextJsServer
    PropertyDetails --> NextJsServer
    RentalCreate --> NextJsServer
    RentalEdit --> NextJsServer
    AdminRentals --> NextJsServer
    OwnerDashboard --> NextJsServer
    ReservationView --> NextJsServer
    Trips --> NextJsServer
    AtomicUI --> NextJsPages
    BookingComp --> NextJsPages
    CardComp --> NextJsPages
    FormComp --> NextJsPages
    HomeWidgets --> NextJsPages
    NavbarComp --> NextJsPages
    PropertyComp --> NextJsPages
    RentalDashboardComp --> NextJsPages
    TripsComp --> NextJsPages
    CommonComp --> NextJsPages

    NextJsServer -->|invokes| ConfirmAPI
    NextJsServer -->|invokes| GeocodeAPI
    NextJsServer -->|invokes| PaymentAPI

    ConfirmAPI -->|uses| DBUtil
    GeocodeAPI -->|uses| DBUtil
    PaymentAPI -->|uses| DBUtil

    NextJsServer -->|queries| DBUtil
    NextJsServer -->|auth via| AuthUtil
    NextJsServer -->|validates with| SchemasUtil
    NextJsServer -->|processes dates| CalendarUtil
    NextJsServer -->|general logic| HelperUtil
    NextJsServer -->|state management| StoreUtil
    NextJsServer -->|types| TypesUtil
    NextJsServer -->|handles actions| ActionUtil
    NextJsServer -->|shared funcs| SharedLib

    DBUtil -->|maps schema| PrismaSchema
    PrismaSchema -->|stored in| Database

    NextJsServer -->|auth/session| SupabaseAuth
    NextJsServer -->|geocode requests| GeocodeService
    NextJsServer -->|payment requests| StripeService

    %% Click Events
    click NextJsPages "https://github.com/magic9701/booking-nest/tree/main/app/"
    click Checkout "https://github.com/magic9701/booking-nest/blob/main/app/checkout/page.tsx"
    click Favorites "https://github.com/magic9701/booking-nest/blob/main/app/favorites/page.tsx"
    click ProfileView "https://github.com/magic9701/booking-nest/blob/main/app/profile/page.tsx"
    click ProfileCreate "https://github.com/magic9701/booking-nest/blob/main/app/profile/create/page.tsx"
    click PropertyDetails "https://github.com/magic9701/booking-nest/blob/main/app/properties/[id]/page.tsx"
    click RentalCreate "https://github.com/magic9701/booking-nest/blob/main/app/rentals/create/page.tsx"
    click RentalEdit "https://github.com/magic9701/booking-nest/blob/main/app/rentals/[id]/edit/page.tsx"
    click AdminRentals "https://github.com/magic9701/booking-nest/blob/main/app/rentals/admin/page.tsx"
    click OwnerDashboard "https://github.com/magic9701/booking-nest/blob/main/app/rentals/dashboard/page.tsx"
    click ReservationView "https://github.com/magic9701/booking-nest/blob/main/app/rentals/reservation/page.tsx"
    click Trips "https://github.com/magic9701/booking-nest/blob/main/app/trips/page.tsx"
    click ConfirmAPI "https://github.com/magic9701/booking-nest/blob/main/app/api/confirm/route.ts"
    click GeocodeAPI "https://github.com/magic9701/booking-nest/blob/main/app/api/geocode/route.ts"
    click PaymentAPI "https://github.com/magic9701/booking-nest/blob/main/app/api/payment/route.ts"
    click AtomicUI "https://github.com/magic9701/booking-nest/tree/main/components/ui/"
    click BookingComp "https://github.com/magic9701/booking-nest/tree/main/components/booking/"
    click CardComp "https://github.com/magic9701/booking-nest/tree/main/components/card/"
    click FormComp "https://github.com/magic9701/booking-nest/tree/main/components/form/"
    click HomeWidgets "https://github.com/magic9701/booking-nest/tree/main/components/home/"
    click NavbarComp "https://github.com/magic9701/booking-nest/tree/main/components/navbar/"
    click PropertyComp "https://github.com/magic9701/booking-nest/tree/main/components/properties/"
    click RentalDashboardComp "https://github.com/magic9701/booking-nest/tree/main/components/rental/"
    click TripsComp "https://github.com/magic9701/booking-nest/tree/main/components/trips/"
    click CommonComp "https://github.com/magic9701/booking-nest/tree/main/components/common/"
    click DBUtil "https://github.com/magic9701/booking-nest/blob/main/utils/db.ts"
    click AuthUtil "https://github.com/magic9701/booking-nest/blob/main/utils/supabase.ts"
    click SchemasUtil "https://github.com/magic9701/booking-nest/blob/main/utils/schemas.ts"
    click CalendarUtil "https://github.com/magic9701/booking-nest/blob/main/utils/calendar.ts"
    click HelperUtil "https://github.com/magic9701/booking-nest/blob/main/utils/helper.ts"
    click StoreUtil "https://github.com/magic9701/booking-nest/blob/main/utils/store.ts"
    click TypesUtil "https://github.com/magic9701/booking-nest/blob/main/utils/types.ts"
    click ActionUtil "https://github.com/magic9701/booking-nest/blob/main/utils/action.ts"
    click SharedLib "https://github.com/magic9701/booking-nest/blob/main/lib/utils.ts"
    click PrismaSchema "https://github.com/magic9701/booking-nest/blob/main/prisma/schema.prisma"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#0288D1,color:#000
    classDef backend fill:#E8F5E9,stroke:#43A047,color:#000
    classDef data fill:#FFF3E0,stroke:#FB8C00,color:#000
    classDef external fill:#ECEFF1,stroke:#607D8B,color:#000
```
