# sayandey18/wp-headless architecture

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

- Interactive diagram: https://gitdiagram.com/sayandey18/wp-headless
- Repository: https://github.com/sayandey18/wp-headless

## Overview

##### Project Type and Purpose
- This is a full-stack headless-CMS front-end: a Next.js/React application that uses Faust.js to fetch content from a WordPress backend via GraphQL.
- Purpose: Render SEO-optimized pages (SSR/SSG), pull posts/pages/projects/comments from WordPress, serve assets (images, sounds), and provide features like comments, newsletters, etc.

##### File Structure
- Top-Level Config & Scripts:
- next.config.mjs, faust.config.js → Next.js & Faust setup
- package.json, pnpm-lock.yaml → dependencies & scripts
- blueprint-schema.json, possibleTypes.json → GraphQL schema introspection
- Public: `/public/assets` → static images & sound files
- Source Code (`/src`):
- components/ → reusable UI pieces (cards, buttons, headers, footers, comment widgets)
- graphql/ → query & mutation definitions
- pages/ → Next.js routing (SSR/SSG pages, API endpoints under `/api/faust`)
- styles/ → global CSS & Tailwind config
- wp-templates/ → Faust.js page templates mapping WP nodes to Next.js routes
- Deployment & Tooling:
- vercel.json → Vercel deployment settings
- ESLint, Prettier, Tailwind, PostCSS configs

##### README for Additional Insights
- Key features: SSR/SSG via Next.js, GraphQL for data, Faust.js integration, WPGraphQL on WP side
- Prerequisites: Node ≥18, WP instance with WPGraphQL plugin
- Workflow: `pnpm install` → generate possibleTypes → `pnpm dev`

a. Main Components
1. Client (Browser/Mobile)
2. Next.js Frontend
- Pages & Routing Layer
- Faust.js GraphQL Client
- Static Assets (served from `/public`)
3. GraphQL API Layer
- WPGraphQL Endpoint on WordPress
4. WordPress Backend
- Headless CMS content (posts, pages, media, comments)
5. Deployment Platform
- Vercel (SSR/SSG hosting, CDN for static assets)
b. Relationships & Interactions
- Client → Next.js (HTTP/HTTPS)
- Next.js (SSR/SSG) → WPGraphQL (GraphQL queries & mutations)
- Next.js ↔ Static Assets (images/sounds) via CDN
- Next.js → Vercel Hosting & CDN
c. Architectural Patterns & Principles
- Headless CMS pattern
- SSR/SSG for SEO and performance
- Component-based design (React)
- GraphQL data fetching
- Separation of concerns: UI, data layer, CMS
d. Key Technologies & Frameworks
- React & Next.js (pages, SSR/SSG, API routes)
- Faust.js (GraphQL client abstractions)
- WPGraphQL & WordPress (content source)
- Tailwind CSS, PostCSS for styling
- Vercel for deployment/CDN

##### Essential Details to Capture
- The internal GraphQL folder: group queries & mutations as part of the GraphQL Client block.
- Static `/public/assets` serve directly from CDN—show asset flow.
- API routes in `/pages/api/faust` handle preview and serverless functions—indicate these under the Next.js server block.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Browser("Browser / Client"):::frontend

    %% Frontend Layer
    subgraph "Next.js Frontend" 
        direction TB
        Pages["Pages & Routing\n(src/pages)"]:::frontend
        Components["UI Components\n(src/components)"]:::frontend
        Styles["Global Styles\n(src/styles & Tailwind)"]:::frontend
        GraphQLClient["Faust.js GraphQL Client\n(src/graphql)"]:::api
        Templates["WP-Templates\n(src/wp-templates)"]:::frontend
        APIRoutes["API Routes\n(src/pages/api/faust)"]:::api
        ConfigFiles["Config Files"]:::frontend
        Pages --> Components
        Pages --> Templates
        Pages --> APIRoutes
        Components --> Styles
        Pages --> GraphQLClient
        GraphQLClient --> Templates
        ConfigFiles --> Pages
        ConfigFiles --> Styles
        ConfigFiles --> GraphQLClient
    end

    %% Static Assets
    Assets["Static Assets\n(public/assets)"]:::assets

    %% GraphQL API Layer
    subgraph "GraphQL API Layer"
        WPGraphQL["WPGraphQL Endpoint"]:::api
    end

    %% WordPress Backend
    subgraph "WordPress CMS" 
        ContentDB["Content Store\n(posts, pages, media, comments)"]:::cms
    end

    %% Hosting & CDN
    subgraph "Vercel Hosting & CDN" 
        SSR["SSR/SSG Hosting"]:::hosting
        CDN["Static CDN"]:::hosting
    end

    %% Relationships
    Browser -->|"HTTP/HTTPS"| Pages
    Pages -->|"fetches via Faust.js"| WPGraphQL
    GraphQLClient -->|"queries/mutations"| WPGraphQL
    WPGraphQL -->|"serves content"| ContentDB
    Pages -->|"serves assets"| CDN
    Assets -->|"deployed to CDN"| CDN
    Pages -->|"deployed to Vercel"| SSR
    SSR -->|"delivers pages"| Browser

    %% Click Events
    click nextConfig "https://github.com/sayandey18/wp-headless/blob/master/next.config.mjs"
    click faustConfig "https://github.com/sayandey18/wp-headless/blob/master/faust.config.js"
    click blueprint "https://github.com/sayandey18/wp-headless/blob/master/blueprint-schema.json"
    click possibleTypes "https://github.com/sayandey18/wp-headless/blob/master/possibleTypes.json"
    click assetsImages "https://github.com/sayandey18/wp-headless/tree/master/public/assets/images"
    click assetsSounds "https://github.com/sayandey18/wp-headless/tree/master/public/assets/sounds"
    click uiComponents "https://github.com/sayandey18/wp-headless/tree/master/src/components"
    click graphqlGeneral "https://github.com/sayandey18/wp-headless/blob/master/src/graphql/general.js"
    click graphqlMutations "https://github.com/sayandey18/wp-headless/blob/master/src/graphql/mutations.js"
    click pagesDir "https://github.com/sayandey18/wp-headless/tree/master/src/pages"
    click apiRoutes "https://github.com/sayandey18/wp-headless/blob/master/src/pages/api/faust/[[...route]].js"
    click wpTemplates "https://github.com/sayandey18/wp-headless/tree/master/src/wp-templates"
    click styles "https://github.com/sayandey18/wp-headless/blob/master/src/styles/globals.css"
    click tailwind "https://github.com/sayandey18/wp-headless/blob/master/tailwind.config.mjs"
    click postcss "https://github.com/sayandey18/wp-headless/blob/master/postcss.config.mjs"
    click vercelConfig "https://github.com/sayandey18/wp-headless/blob/master/vercel.json"
    click packageJson "https://github.com/sayandey18/wp-headless/blob/master/package.json"
    click lockfile "https://github.com/sayandey18/wp-headless/blob/master/pnpm-lock.yaml"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#333,stroke-width:1px;
    classDef api fill:#FFE0B2,stroke:#333,stroke-width:1px;
    classDef cms fill:#FFF3B0,stroke:#333,stroke-width:1px;
    classDef hosting fill:#D0FFD6,stroke:#333,stroke-width:1px;
    classDef assets fill:#F0E0FF,stroke:#333,stroke-width:1px;
```
