# valeshgopal/nest-away architecture

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

- Interactive diagram: https://gitdiagram.com/valeshgopal/nest-away
- Repository: https://github.com/valeshgopal/nest-away

## Overview

##### Main System Components

a) Frontend Layer:
- Next.js App Router (app directory structure)
- Client Components
- Server Components
- UI Components
- Theme System

b) Backend Layer:
- API Routes
- Server Actions
- Database (Prisma ORM)
- Authentication Middleware
- Supabase Integration

c) External Services:
- Supabase (for storage and possibly auth)
- Database (likely PostgreSQL based on Prisma usage)

##### Component Organization

a) Page Components:
- Home (/)
- Bookings (/bookings)
- Properties (/properties)
- Rentals (/rentals)
- Profile (/profile)
- Reviews (/reviews)
- Favorites (/favorites)

b) Feature Components:
- Navigation System
- Form Components
- Card Components
- UI Components Library

##### Data Flow Architecture

Following flows:

**User Interface**
- ↕
**Page Components**
- ↕
**Server Components/Actions**
- ↕
**Database Layer (Prisma)**
- ↕
**Persistent Storage (PostgreSQL)**

##### Specific Implementation Details

Technical aspects:

- Next.js App Router Architecture
- Server Actions (utils/actions.ts)
- Database Schema (prisma/schema.prisma)
- Authentication Flow (middleware.ts)
- Theme System (dark/light mode)

##### Key Relationships to Highlight

- User Authentication Flow
- Property Listing Management
- Booking Process
- Favoriting System
- Review System
- Image Storage Flow

##### Technical Stack Indicators

Badges or labels for:

- Next.js 13+
- React
- Prisma ORM
- Supabase
- TypeScript
- Tailwind CSS
- Shadcn UI

##### External Services Layer

Important Notes:
- Keep the component relationships clear but not overwhelming
- Related features together (e.g., all booking-related components)
- Authentication flow throughout the system
- Server/client component boundary
- Theme system's global influence
- How the form components interact with server actions

This architecture should emphasize the modern Next.js App Router structure while clearly showing the full-stack nature of the application, with special attention to the property rental/booking domain-specific features.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Legend"
        direction TB
        L1[Frontend Component]:::frontend
        L2[Server Component]:::server
        L3[(Database)]:::database
        L4[External Service]:::external
        L5[API Route]:::api
        L6[Authentication]:::auth
    end

    subgraph "Frontend Layer"
        direction TB
        AppRouter["Next.js App Router"]:::frontend
        click AppRouter "https://github.com/valeshgopal/nest-away/tree/main/app"
        
        ThemeSystem["Theme System"]:::frontend
        click ThemeSystem "https://github.com/valeshgopal/nest-away/blob/main/app/theme-provider.tsx"
        
        subgraph "Page Components"
            direction TB
            Home["Home Page"]:::frontend
            click Home "https://github.com/valeshgopal/nest-away/blob/main/components/home/PropertiesContainer.tsx"
            Properties["Properties"]:::frontend
            click Properties "https://github.com/valeshgopal/nest-away/blob/main/app/properties/page.tsx"
            Bookings["Bookings"]:::frontend
            click Bookings "https://github.com/valeshgopal/nest-away/blob/main/app/bookings/page.tsx"
            Rentals["Rentals"]:::frontend
            click Rentals "https://github.com/valeshgopal/nest-away/blob/main/app/rentals/page.tsx"
            Reviews["Reviews"]:::frontend
            click Reviews "https://github.com/valeshgopal/nest-away/blob/main/app/reviews/page.tsx"
            Favorites["Favorites"]:::frontend
            click Favorites "https://github.com/valeshgopal/nest-away/blob/main/app/favorites/page.tsx"
            Profile["Profile"]:::frontend
            click Profile "https://github.com/valeshgopal/nest-away/blob/main/app/profile/page.tsx"
        end

        subgraph "Core Components"
            direction TB
            Navigation["Navigation System"]:::frontend
            click Navigation "https://github.com/valeshgopal/nest-away/blob/main/components/navbar/Navbar.tsx"
            Forms["Form Components"]:::frontend
            click Forms "https://github.com/valeshgopal/nest-away/blob/main/components/form/FormContainer.tsx"
            Cards["Property Cards"]:::frontend
            click Cards "https://github.com/valeshgopal/nest-away/blob/main/components/card/PropertyCard.tsx"
            UILib["UI Components Library"]:::frontend
            click UILib "https://github.com/valeshgopal/nest-away/tree/main/components/ui"
            DarkMode["Dark Mode Toggle"]:::frontend
            click DarkMode "https://github.com/valeshgopal/nest-away/blob/main/components/navbar/DarkMode.tsx"
        end
    end

    subgraph "Backend Layer"
        direction TB
        ServerActions["Server Actions"]:::server
        click ServerActions "https://github.com/valeshgopal/nest-away/blob/main/utils/actions.ts"
        
        AuthMiddleware["Authentication Middleware"]:::auth
        click AuthMiddleware "https://github.com/valeshgopal/nest-away/blob/main/middleware.ts"
        
        subgraph "Data Management"
            direction TB
            Database[(Database)]:::database
            click Database "https://github.com/valeshgopal/nest-away/blob/main/prisma/schema.prisma"
            PrismaORM["Prisma ORM"]:::server
            click PrismaORM "https://github.com/valeshgopal/nest-away/blob/main/utils/db.ts"
            DataSchemas["Data Schemas"]:::server
            click DataSchemas "https://github.com/valeshgopal/nest-away/blob/main/utils/schemas.ts"
            TypeDefs["Type Definitions"]:::server
            click TypeDefs "https://github.com/valeshgopal/nest-away/blob/main/utils/types.ts"
        end

        subgraph "Utility Systems"
            direction TB
            Categories["Categories System"]:::server
            click Categories "https://github.com/valeshgopal/nest-away/blob/main/utils/categories.ts"
            Amenities["Amenities System"]:::server
            click Amenities "https://github.com/valeshgopal/nest-away/blob/main/utils/amenities.ts"
            Countries["Countries Data"]:::server
            click Countries "https://github.com/valeshgopal/nest-away/blob/main/utils/countries.ts"
            Formatting["Formatting Utils"]:::server
            click Formatting "https://github.com/valeshgopal/nest-away/blob/main/utils/format.ts"
        end
    end

    subgraph "External Services"
        direction TB
        Supabase["Supabase"]:::external
        click Supabase "https://github.com/valeshgopal/nest-away/blob/main/utils/supabase.ts"
        PostgreSQL[(PostgreSQL)]:::database
    end

    %% Relationships
    AppRouter --> ServerActions
    ServerActions --> Database
    Database --> PostgreSQL
    AuthMiddleware --> Supabase
    PrismaORM --> Database
    
    %% Page Component Relations
    Home & Properties & Bookings & Rentals & Reviews & Favorites & Profile --> ServerActions
    
    %% Theme System Relations
    ThemeSystem --> DarkMode
    
    %% Core Component Relations
    Navigation --> AuthMiddleware
    Forms --> ServerActions
    Cards --> ServerActions

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef server fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef api fill:#e74c3c,stroke:#c0392b,color:white
    classDef auth fill:#e67e22,stroke:#d35400,color:white
```
