# payloadcms/website architecture

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

- Interactive diagram: https://gitdiagram.com/payloadcms/website
- Repository: https://github.com/payloadcms/website

## Overview

##### High-Level Architecture Components

a. Frontend Layer:
- Next.js 13 App Router application
- Client-side components for dynamic features
- SCSS Modules for styling
- MDX rendering for documentation

b. Backend Layer:
- Payload CMS integration
- GraphQL API
- Authentication system
- Stripe integration for Payload Cloud

c. External Services:
- GitHub integration for documentation
- Algolia for search functionality
- Stripe for payments
- Discord integration

##### Key Architectural Patterns to Highlight

a. Route Structure:
- Frontend routes under `src/app/(frontend)`
- Admin routes under `src/app/(payload)`
- API routes under `src/app/(frontend)/api`

b. Component Organization:
- Shared components in `src/components`
- Block-based architecture for content (`src/blocks`)
- Form handling system (`src/forms`)

##### Data Flow Architecture

**[Client Layer]**
- ↕
**[Next.js App Router]**
- ↕
**[API Layer]**
- ↕
**[External Services]**

##### Detailed Component Breakdown

**Frontend Components:**
- Public Pages
- Cloud Dashboard
- Documentation System
- Authentication UI

**Backend Services:**
- Payload CMS
- GraphQL API
- Authentication
- Payment Processing

**External Integrations:**
- GitHub (Docs)
- Stripe (Payments)
- Algolia (Search)
- Discord (Community)

##### Key Features to Highlight

- Theme System (Light/Dark mode)
- Documentation Versioning
- Cloud Platform Dashboard
- CMS Integration
- Authentication Flow
- Payment Processing

##### Specific Implementation Details

**Authentication Flow:**
**[Login/Signup Pages] → [Auth Provider] → [API Routes] → [Payload CMS]**

**Content Delivery:**
**[CMS] → [GraphQL API] → [Next.js Pages] → [Client Components]**

**Cloud Platform:**
**[Dashboard UI] → [API Layer] → [Stripe Integration] → [Project Management]**

##### Development Environment

**Local Development:**
- Next.js Dev Server (Port 3000)
- API Routes
- Custom Domain (local.payloadcms.com)
- Environment Variables

##### Labels
- Clear component names
- API route paths
- Integration points
- Data flow indicators

This architecture should be represented in a clean, hierarchical layout that emphasizes the separation of concerns while showing the interconnected nature of the system's components.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Frontend Layer"
        NextApp["Next.js App Router"]
        ClientComp["Client Components"]
        SCSS["SCSS Modules"]
        MDX["MDX Rendering"]
    end

    subgraph "Backend Layer"
        PayloadCMS["Payload CMS"]
        GraphQL["GraphQL API"]
        Auth["Authentication"]
        StripeInt["Stripe Integration"]
    end

    subgraph "Route Structure"
        FrontendRoutes["Frontend Routes"]
        AdminRoutes["Admin Routes"]
        APIRoutes["API Routes"]
    end

    subgraph "Component Organization"
        SharedComp["Shared Components"]
        BlockArch["Block Architecture"]
        FormHandle["Form Handling"]
    end

    subgraph "External Services"
        GitHub["GitHub Integration"]
        Algolia["Algolia Search"]
        Stripe["Stripe"]
        Discord["Discord Integration"]
    end

    subgraph "Core Features"
        Theme["Theme System"]
        Docs["Documentation"]
        Cloud["Cloud Platform"]
        Collections["CMS Collections"]
    end

    subgraph "Development Tools"
        EnvConfig["Environment Config"]
        BuildConfig["Build Configuration"]
        TypeDefs["Type Definitions"]
    end

    %% Relationships
    NextApp --> PayloadCMS
    NextApp --> GraphQL
    ClientComp --> Auth
    PayloadCMS --> Collections
    Cloud --> StripeInt
    Docs --> MDX
    APIRoutes --> ExternalServices
    Auth --> PayloadCMS
    GraphQL --> Collections

    %% Click events
    click NextApp "https://github.com/payloadcms/website/tree/main/src/app/(frontend)"
    click ClientComp "https://github.com/payloadcms/website/tree/main/src/components"
    click SCSS "https://github.com/payloadcms/website/tree/main/src/css"
    click MDX "https://github.com/payloadcms/website/tree/main/src/components/MDX"
    click PayloadCMS "https://github.com/payloadcms/website/tree/main/src/app/(payload)"
    click GraphQL "https://github.com/payloadcms/website/tree/main/src/app/(payload)/api/graphql"
    click Auth "https://github.com/payloadcms/website/tree/main/src/providers/Auth"
    click StripeInt "https://github.com/payloadcms/website/blob/main/src/app/(frontend)/(cloud)/cloud/_api/updatePaymentMethod.ts"
    click FrontendRoutes "https://github.com/payloadcms/website/tree/main/src/app/(frontend)/(pages)"
    click AdminRoutes "https://github.com/payloadcms/website/tree/main/src/app/(payload)/admin"
    click APIRoutes "https://github.com/payloadcms/website/tree/main/src/app/(frontend)/api"
    click SharedComp "https://github.com/payloadcms/website/tree/main/src/components"
    click BlockArch "https://github.com/payloadcms/website/tree/main/src/blocks"
    click FormHandle "https://github.com/payloadcms/website/tree/main/src/forms"
    click GitHub "https://github.com/payloadcms/website/blob/main/src/app/(frontend)/(cloud)/cloud/_api/fetchGitHubToken.ts"
    click Algolia "https://github.com/payloadcms/website/tree/main/src/adapters/AlgoliaSearchBox"
    click Discord "https://github.com/payloadcms/website/tree/main/src/components/DiscordGitBody"
    click Theme "https://github.com/payloadcms/website/tree/main/src/providers/Theme"
    click Docs "https://github.com/payloadcms/website/tree/main/src/app/(frontend)/(pages)/docs"
    click Cloud "https://github.com/payloadcms/website/tree/main/src/app/(frontend)/(cloud)"
    click Collections "https://github.com/payloadcms/website/tree/main/src/collections"
    click EnvConfig "https://github.com/payloadcms/website/blob/main/.env.example"
    click BuildConfig "https://github.com/payloadcms/website/blob/main/next.config.js"
    click TypeDefs "https://github.com/payloadcms/website/blob/main/src/payload-types.ts"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white
    classDef core fill:#9b59b6,stroke:#8e44ad,color:white
    classDef dev fill:#f1c40f,stroke:#f39c12,color:black

    class NextApp,ClientComp,SCSS,MDX frontend
    class PayloadCMS,GraphQL,Auth,StripeInt backend
    class GitHub,Algolia,Stripe,Discord external
    class Theme,Docs,Cloud,Collections core
    class EnvConfig,BuildConfig,TypeDefs dev
```
