# sudeepmahato16/airbnb-clone architecture

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

- Interactive diagram: https://gitdiagram.com/sudeepmahato16/airbnb-clone
- Repository: https://github.com/sudeepmahato16/airbnb-clone

## Overview

##### Main Components

A. Frontend Layer:
- Client-Side Components (React/Next.js)
- Pages (/app directory structure)
- Reusable Components (/components)
- Modals (Authentication, Search, Rent)
- Navigation and Layout
- Client-side Hooks (/hooks)

B. Backend Layer:
- API Routes (/app/api)
- Authentication endpoints
- EdgeStore integration (for image handling)
- Stripe webhooks
- Middleware (middleware.ts)
- Database Layer (MongoDB with Prisma ORM)

C. External Services:
- Authentication Providers (GitHub, Google via NextAuth)
- EdgeStore (Image storage)
- Stripe (Payment processing)
- Leaflet (Map functionality)

##### Component Relationships

**[Client Layer] ←→ [API Routes] ←→ [External Services]**
- ↕
- [Database Layer]

##### Detailed Component Breakdown

A. Client Layer (Top):
- Home (/)
- Listings (/listings)
- Trips (/trips)
- Favorites (/favorites)
- Properties (/properties)
- Reservations (/reservations)

B. Shared Components (Middle):
- Authentication Modal
- Search Modal
- Rent Modal
- Navigation Components
- Input Components
- Component

C. API Layer (Middle):
- NextAuth Routes
- EdgeStore Routes
- Stripe Webhook Handler
- Service Layer (/services)

D. Data Layer (Bottom):
- Prisma Schema
- MongoDB Database
- External Storage (EdgeStore)

##### Flow Indicators

- User authentication flow
- Property listing creation
- Booking process
- Image upload flow
- Payment processing
- Data fetching paths

##### Additional Notes

- Scaling considerations
- Caching layers
- Error boundary implementations
- Where TypeScript types are enforced
- Integration points with external services

Remember to include notes about the tech stack:
- Next.js 13+
- TypeScript
- Tailwind CSS
- MongoDB
- Prisma ORM
- NextAuth
- Leaflet
- Stripe
- EdgeStore

This will give other developers a clear understanding of how the different parts of the system interact while maintaining a practical level of detail for implementation and maintenance purposes.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        direction TB
        HomePage["Home Page"]:::frontend
        ListingsPage["Listings Page"]:::frontend
        TripsPage["Trips Page"]:::frontend
        FavoritesPage["Favorites Page"]:::frontend
        PropertiesPage["Properties Page"]:::frontend
        ReservationsPage["Reservations Page"]:::frontend

        subgraph Components["Core Components"]
            direction TB
            Nav["Navigation"]:::frontend
            AuthModal["Auth Modal"]:::frontend
            SearchModal["Search Modal"]:::frontend
            RentModal["Rent Modal"]:::frontend
            MapComp["Map Component"]:::frontend
        end

        subgraph Utils["Client Utilities"]
            direction TB
            Hooks["Hooks"]:::frontend
            Types["Types"]:::frontend
            Helpers["Helpers"]:::frontend
        end
    end

    subgraph API["API Layer"]
        direction TB
        AuthAPI["Authentication API"]:::api
        EdgeStoreAPI["EdgeStore API"]:::api
        StripeWebhook["Stripe Webhook"]:::api
        
        subgraph Services["Service Layer"]
            direction TB
            AuthService["Auth Service"]:::service
            ListingService["Listing Service"]:::service
            ReservationService["Reservation Service"]:::service
            PropertiesService["Properties Service"]:::service
            FavoriteService["Favorite Service"]:::service
        end
    end

    subgraph External["External Services"]
        direction TB
        NextAuth["NextAuth"]:::external
        EdgeStore["EdgeStore"]:::external
        Stripe["Stripe"]:::external
        Leaflet["Leaflet"]:::external
    end

    subgraph Data["Data Layer"]
        direction TB
        MongoDB[(MongoDB)]:::database
        PrismaORM["Prisma ORM"]:::database
        DBConfig["Database Config"]:::config
    end

    Middleware["Middleware"]:::security

    %% Connections
    Client --> API
    API --> External
    API --> Data
    Middleware --> API
    Services --> Data

    %% Click Events
    click HomePage "https://github.com/sudeepmahato16/airbnb-clone/blob/main/app/page.tsx"
    click ListingsPage "https://github.com/sudeepmahato16/airbnb-clone/blob/main/app/listings/[listingId]/page.tsx"
    click TripsPage "https://github.com/sudeepmahato16/airbnb-clone/blob/main/app/trips/page.tsx"
    click FavoritesPage "https://github.com/sudeepmahato16/airbnb-clone/blob/main/app/favorites/page.tsx"
    click PropertiesPage "https://github.com/sudeepmahato16/airbnb-clone/blob/main/app/properties/page.tsx"
    click ReservationsPage "https://github.com/sudeepmahato16/airbnb-clone/blob/main/app/reservations/page.tsx"
    click Nav "https://github.com/sudeepmahato16/airbnb-clone/blob/main/components/navbar/index.tsx"
    click AuthModal "https://github.com/sudeepmahato16/airbnb-clone/blob/main/components/modals/AuthModal.tsx"
    click SearchModal "https://github.com/sudeepmahato16/airbnb-clone/blob/main/components/modals/SearchModal.tsx"
    click RentModal "https://github.com/sudeepmahato16/airbnb-clone/blob/main/components/modals/RentModal.tsx"
    click MapComp "https://github.com/sudeepmahato16/airbnb-clone/blob/main/components/Map.tsx"
    click AuthAPI "https://github.com/sudeepmahato16/airbnb-clone/blob/main/app/api/auth/[...nextauth]/route.ts"
    click EdgeStoreAPI "https://github.com/sudeepmahato16/airbnb-clone/blob/main/app/api/edgestore/[...edgestore]/route.ts"
    click StripeWebhook "https://github.com/sudeepmahato16/airbnb-clone/blob/main/app/api/webhooks/stripe/route.ts"
    click AuthService "https://github.com/sudeepmahato16/airbnb-clone/blob/main/services/auth.ts"
    click ListingService "https://github.com/sudeepmahato16/airbnb-clone/blob/main/services/listing.ts"
    click ReservationService "https://github.com/sudeepmahato16/airbnb-clone/blob/main/services/reservation.ts"
    click PropertiesService "https://github.com/sudeepmahato16/airbnb-clone/blob/main/services/properties.ts"
    click FavoriteService "https://github.com/sudeepmahato16/airbnb-clone/blob/main/services/favorite.ts"
    click DBConfig "https://github.com/sudeepmahato16/airbnb-clone/blob/main/lib/db.ts"
    click Hooks "https://github.com/sudeepmahato16/airbnb-clone/tree/main/hooks"
    click Types "https://github.com/sudeepmahato16/airbnb-clone/blob/main/types/index.ts"
    click Helpers "https://github.com/sudeepmahato16/airbnb-clone/blob/main/utils/helper.ts"
    click Middleware "https://github.com/sudeepmahato16/airbnb-clone/blob/main/middleware.ts"
    click PrismaORM "https://github.com/sudeepmahato16/airbnb-clone/blob/main/prisma/schema.prisma"

    %% Styles
    classDef frontend fill:#3498db,color:white
    classDef api fill:#2ecc71,color:white
    classDef service fill:#95a5a6,color:white
    classDef external fill:#f1c40f,color:black
    classDef database fill:#9b59b6,color:white
    classDef security fill:#e74c3c,color:white
    classDef config fill:#1abc9c,color:white
```
