# ngkhang/airbnb-nextjs architecture

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

- Interactive diagram: https://gitdiagram.com/ngkhang/airbnb-nextjs
- Repository: https://github.com/ngkhang/airbnb-nextjs

## Overview

##### Main Components

A. Client-Side Components:
- Browser/User Interface
- Client-side Runtime (Next.js Client)
- React Components Layer

B. Server-Side Components:
- Next.js Server Runtime
- Server Components
- File-based Routing System

C. Build-time Components:
- Next.js Build System
- Asset Optimization Pipeline
- Font Optimization System

**┌─────────────────────────────────────┐**
- Client Layer              │
- ┘
- ↕
**┌─────────────────────────────────────┐**
- Server Layer              │
- ┘
- ↕
**┌─────────────────────────────────────┐**
- Build/Static Layer          │
- ┘

##### Specific Component Details

A. Client Layer (Blue tones):
- Rectangle: Browser viewport
- Rounded Rectangle: React Components
- Hexagon: Client-side Runtime

B. Server Layer (Green tones):
- Rectangle: Next.js Server
- Diamonds: Server Components
- Circles: API Routes

C. Build Layer (Orange tones):
- Rectangle: Build System
- Parallelograms: Asset Pipeline
- Octagons: Configuration

##### Important Relationships

- File-based routing system connecting to both server and client components
- Build pipeline's connection to both static assets and server components
- Demonstrate the font optimization system's integration with the build process

##### Technical Stack Highlights

- Next.js 13+ App Router
- React Server Components
- TailwindCSS
- TypeScript
- Font Optimization (next/font)

##### Key Architectural Patterns to Emphasize

- File-system Based Routing (show how src/app structure maps to routes)
- Server/Client Component Separation
- Static and Dynamic Rendering Paths
- Asset Optimization Flow

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef client fill:#d4e6ff,stroke:#333
    classDef server fill:#d4ffdb,stroke:#333
    classDef build fill:#ffe7d4,stroke:#333
    classDef config fill:#f9f9f9,stroke:#333
    classDef routing fill:#e6d4ff,stroke:#333

    %% Client Layer
    subgraph ClientLayer
        Browser["Browser/User Interface"]:::client
        ClientRuntime["Next.js Client Runtime"]:::client
        ReactComponents["React Components"]:::client
    end

    %% Server Layer
    subgraph ServerLayer
        NextServer["Next.js Server Runtime"]:::server
        ServerComponents["Server Components"]:::server
        RootLayout["Root Layout"]:::server
        MainPage["Main Page"]:::server
    end

    %% Build Layer
    subgraph BuildLayer
        BuildSystem["Next.js Build System"]:::build
        AssetOptimization["Asset Optimization Pipeline"]:::build
        FontOptimization["Font Optimization System"]:::build
    end

    %% Configuration Nodes
    NextConfig["next.config.mjs"]:::config
    TSConfig["tsconfig.json"]:::config
    TailwindConfig["tailwind.config.ts"]:::config
    PostCSSConfig["postcss.config.mjs"]:::config
    ESLintConfig[".eslintrc.json"]:::config
    GlobalStyles["globals.css"]:::config

    %% Routing System
    FileBasedRouting["File-based Routing System"]:::routing

    %% Relationships
    Browser --> ClientRuntime
    ClientRuntime --> ReactComponents
    ReactComponents --> ServerComponents
    ServerComponents --> NextServer
    NextServer --> BuildSystem
    BuildSystem --> AssetOptimization
    BuildSystem --> FontOptimization
    FileBasedRouting --> ServerComponents
    FileBasedRouting --> ReactComponents
    RootLayout --> ServerComponents
    MainPage --> ServerComponents
    GlobalStyles --> AssetOptimization

    %% Click Events
    click RootLayout "https://github.com/ngkhang/airbnb-nextjs/blob/main/src/app/layout.tsx"
    click MainPage "https://github.com/ngkhang/airbnb-nextjs/blob/main/src/app/page.tsx"
    click FontOptimization "https://github.com/ngkhang/airbnb-nextjs/tree/main/src/app/fonts"
    click GlobalStyles "https://github.com/ngkhang/airbnb-nextjs/blob/main/src/app/globals.css"
    click NextConfig "https://github.com/ngkhang/airbnb-nextjs/blob/main/next.config.mjs"
    click TSConfig "https://github.com/ngkhang/airbnb-nextjs/blob/main/tsconfig.json"
    click TailwindConfig "https://github.com/ngkhang/airbnb-nextjs/blob/main/tailwind.config.ts"
    click PostCSSConfig "https://github.com/ngkhang/airbnb-nextjs/blob/main/postcss.config.mjs"
    click ESLintConfig "https://github.com/ngkhang/airbnb-nextjs/blob/main/.eslintrc.json"
    click FileBasedRouting "https://github.com/ngkhang/airbnb-nextjs/tree/main/src/app"

    %% Legend
    subgraph Legend
        L1["Client Components"]:::client
        L2["Server Components"]:::server
        L3["Build System"]:::build
        L4["Configuration"]:::config
        L5["Routing"]:::routing
    end
```
