# simplesphere/simple-nextjs-boilerplate architecture

> Architecture diagram of the GitHub repository simplesphere/simple-nextjs-boilerplate, 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/simplesphere/simple-nextjs-boilerplate
- Repository: https://github.com/simplesphere/simple-nextjs-boilerplate

## Overview

##### Main Components

A. Frontend Layer:
- Next.js Application (Core)
- App Router (shown by the [locale] directory structure)
- Client Components
- Server Components
- UI Component Library
- Radix UI Components
- Custom UI Components (from src/components/ui)
- State Management & Forms
- React Hook Form
- Zod Validation

B. Middleware Layer:
- Next.js Middleware (src/middleware.ts)
- Internationalization Handler (next-intl)
- Authentication Flow

C. Backend Integration:
- Supabase Services
- Authentication
- Database
- Real-time subscriptions (if used)

**┌─────────────────────────────────────────────────────────┐**
- Client Layer (Browser)                  │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Next.js Application                   │
- ┬─────────────────┬────────────────────────┤
- App Router │  Components     │     Utilities          │
- (/src/app) │  (/src/comp.)  │  (/src/utils, /hooks)  │
- ┴─────────────────┴────────────────────────┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Middleware Layer                      │
- ┬────────────────┬─────────────────────┤
- Auth Handler  │  i18n Router   │  API Middleware     │
- ┴────────────────┴─────────────────────┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Supabase Backend                      │
- ┬────────────────┬─────────────────────┤
- Auth Service  │   Database     │  Real-time Events   │
- ┴────────────────┴─────────────────────┘

##### Additional Elements

- Build/Deploy Pipeline
- Development Tools (ESLint, Prettier, Husky)
- Static Asset Handling
- Environment Configuration

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Browser/Client Side"]
    end

    subgraph NextApp["Next.js Application"]
        direction TB
        AppRouter["App Router"]:::nextjs
        click AppRouter "https://github.com/simplesphere/simple-nextjs-boilerplate/tree/main/src/app/[locale]"
        
        subgraph Components["Components Layer"]
            direction TB
            UI["UI Components"]:::component
            click UI "https://github.com/simplesphere/simple-nextjs-boilerplate/tree/main/src/components/ui"
            Forms["Form Components"]:::component
            click Forms "https://github.com/simplesphere/simple-nextjs-boilerplate/tree/main/src/components/form"
            Layout["Layout Components"]:::component
            click Layout "https://github.com/simplesphere/simple-nextjs-boilerplate/tree/main/src/components/layout"
            Nav["Navigation"]:::component
            click Nav "https://github.com/simplesphere/simple-nextjs-boilerplate/tree/main/src/components/layout/nav"
            Sidebar["Sidebar"]:::component
            click Sidebar "https://github.com/simplesphere/simple-nextjs-boilerplate/blob/main/src/components/layout/sidebar/sidebar.tsx"
        end

        subgraph Routes["Application Routes"]
            Auth["Authentication Routes"]:::route
            click Auth "https://github.com/simplesphere/simple-nextjs-boilerplate/tree/main/src/app/[locale]/(auth)"
            Dashboard["Dashboard Routes"]:::route
            click Dashboard "https://github.com/simplesphere/simple-nextjs-boilerplate/tree/main/src/app/[locale]/(dashboard)"
            LoginPage["Login Page"]:::route
            click LoginPage "https://github.com/simplesphere/simple-nextjs-boilerplate/blob/main/src/app/[locale]/(auth)/login/page.tsx"
        end

        subgraph Utils["Utilities"]
            Hooks["Custom Hooks"]:::util
            click Hooks "https://github.com/simplesphere/simple-nextjs-boilerplate/tree/main/src/hooks"
            Types["Type Definitions"]:::util
            click Types "https://github.com/simplesphere/simple-nextjs-boilerplate/blob/main/src/types/index.ts"
            UtilFuncs["Utility Functions"]:::util
            click UtilFuncs "https://github.com/simplesphere/simple-nextjs-boilerplate/blob/main/src/lib/utils.ts"
            Styles["Global Styles"]:::util
            click Styles "https://github.com/simplesphere/simple-nextjs-boilerplate/blob/main/src/assets/globals.css"
        end
    end

    subgraph Middleware["Middleware Layer"]
        AuthMiddleware["Auth Handler"]:::middleware
        click AuthMiddleware "https://github.com/simplesphere/simple-nextjs-boilerplate/blob/main/src/utils/supabase/middleware.ts"
        I18nRouter["i18n Router"]:::middleware
        click I18nRouter "https://github.com/simplesphere/simple-nextjs-boilerplate/blob/main/src/i18n/routing.ts"
        NextMiddleware["Next.js Middleware"]:::middleware
        click NextMiddleware "https://github.com/simplesphere/simple-nextjs-boilerplate/blob/main/src/middleware.ts"
    end

    subgraph Supabase["Supabase Backend"]
        SupabaseAuth["Authentication Service"]:::supabase
        SupabaseDB["Database"]:::supabase
        SupabaseRT["Real-time Events"]:::supabase
        SupabaseClient["Supabase Client"]:::supabase
        click SupabaseClient "https://github.com/simplesphere/simple-nextjs-boilerplate/blob/main/src/utils/supabase/client.ts"
        SupabaseServer["Supabase Server"]:::supabase
        click SupabaseServer "https://github.com/simplesphere/simple-nextjs-boilerplate/blob/main/src/utils/supabase/server.ts"
    end

    Browser <--> AppRouter
    AppRouter --> Routes
    AppRouter --> Components
    Auth --> LoginPage
    LoginPage --> Forms
    Components --> Utils
    Routes --> Middleware
    Middleware --> Supabase
    
    %% Styling
    classDef nextjs fill:#1E40AF,color:white
    classDef component fill:#3B82F6,color:white
    classDef route fill:#60A5FA,color:white
    classDef middleware fill:#F97316,color:white
    classDef supabase fill:#22C55E,color:white
    classDef util fill:#A855F7,color:white

    %% Legend
    subgraph Legend
        L1["Next.js Components"]:::nextjs
        L2["UI Components"]:::component
        L3["Routes"]:::route
        L4["Middleware"]:::middleware
        L5["Supabase Services"]:::supabase
        L6["Utilities"]:::util
    end
```
