# jhb-software/website architecture

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

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

## Overview

##### Main Components
- CMS Backend: Represented by the “cms” directory. This includes the core payload CMS configuration (payload.config.ts), various collections (content types like Articles, Authors, Pages, etc.), endpoints (such as those for GraphQL, sitemap, and static pages), and custom blocks.
- CMS Plugins: Emphasize the “cms/plugins/cms-content-translator” as a significant custom functionality component. Show client components, providers, resolvers (including openAI integration), translation processing modules, and utility functions.
- Website Frontend: Represented by the “web” directory. This part uses Astro for static and dynamic rendering. It includes dedicated modules for integrating with the CMS (e.g., cms/sdk, cms/api calls such as getPageData, getRedirects, etc.) and components for UI blocks, layout, and pages.
- Shared Utilities/Configurations: Highlight that there are monorepo-level configurations (pnpm-workspace.yaml, .gitignore, vercel.json) that enable integration/deployment between both parts.

##### Their Relationships and Interactions
- A directional data flow between the Website Frontend and the CMS. For example, the website’s API calls (e.g., getPageData, getSitemap) fetch data from CMS endpoints.
- Point out that configuration and build scripts (e.g., next.config.ts for CMS, astro.config.mjs for web) help tie everything together during deployment (noting Vercel deploy configurations in both cms and web directories).

##### Architectural Patterns and Design Principles
- Separation of Concerns: The architectural design separates the presentation layer (frontend website) from the content storage, management, and processing layer (CMS). This clear boundary ensures modularity.
- Modular/Plugin Architecture: Within the CMS, note how the translator plugin is encapsulated with its own client components, providers, resolvers, and utilities. This plugin-based approach makes the system extensible.
- API-Driven Communication: The frontend communicates with the CMS using API endpoints (both REST and GraphQL), meaning the data flow is directed along well-defined interfaces.
- Monorepo Structure: The project leverages a single repository (pnpm-workspace) to manage dependencies and link the two major parts, ensuring consistency and ease of configuration across the system.

##### Relevant Technologies, Frameworks, or Libraries
- CMS: Next.js (indicated by files like next.config.ts and next-env.d.ts), custom payload CMS configurations, and specialized plugins.
- Website: Astro (astor.config.mjs and .astro components) for static/dynamic UI.
- Tooling: ESLint, Prettier for code formatting and linting; pnpm for package management; and Vercel for deployment (as indicated by vercel.json files).

##### Elements
- Clear labels for:
- Website Frontend (Astro-based UI)
- CMS Backend (Next.js, payload CMS configuration, collections, endpoints, custom blocks)
- Translator Plugin (client components, providers, APIs, resolvers with external services like openAI)
- Shared Services (API interfaces between frontend and backend, and deployment tools)
- User interface components (frontend UI components in Astro and CMS client components)
- Business logic components (CMS endpoints, collections, blocks)
- Plugin/extension points (translator plugin layers: providers, API calls, resolvers)
- Infrastructure/configuration components (build configs, deployment settings)

## Diagram (Mermaid)

```mermaid
graph TD
    %% CMS Backend Subgraph
    subgraph "CMS Backend"
        A["Payload Config"]:::backend
        B["Collections"]:::backend
        C["Endpoints"]:::backend
        D["Blocks"]:::backend
        E["Fields"]:::backend
    end

    %% CMS Translator Plugin Subgraph
    subgraph "CMS Translator Plugin"
        F["Translator Plugin"]:::plugin
        G["Client Components & Providers"]:::plugin
        H["Translation Ops"]:::plugin
        I["Resolvers"]:::plugin
        J["External Service (openAI)"]:::external
    end

    %% Website Frontend Subgraph
    subgraph "Website Frontend"
        K["Astro Config & Components"]:::frontend
        L["CMS Integration (SDK/API)"]:::frontend
    end

    %% Shared Configurations Subgraph
    subgraph "Shared Configurations"
        M["Pnpm Workspace"]:::shared
        N["Deployment Settings"]:::shared
        O["Git Ignore"]:::shared
    end

    %% Internal CMS Backend Relationships
    A -->|"configures"| B
    A -->|"configures"| C
    A -->|"configures"| D
    A -->|"configures"| E

    %% Website Frontend to CMS Backend Interaction
    L -->|"fetchesData"| C

    %% Translator Plugin Internal Flow
    G -->|"translates"| H
    H -->|"callsResolver"| I
    I -->|"externalCall"| J

    %% Shared Configurations Influencing Components
    N -->|"deploys"| A
    N -->|"deploys"| K
    M -->|"manages"| A
    M -->|"manages"| K
    O -->|"appliesTo"| A
    O -->|"appliesTo"| K

    %% Styles
    classDef frontend fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
    classDef backend fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
    classDef plugin fill:#A9DFBF,stroke:#28B463,stroke-width:2px;
    classDef shared fill:#F5CBA7,stroke:#E67E22,stroke-width:2px;
    classDef external fill:#D2B4DE,stroke:#9B59B6,stroke-width:2px;

    %% Click Events
    click A "https://github.com/jhb-software/website/blob/main/cms/src/payload.config.ts"
    click B "https://github.com/jhb-software/website/tree/main/cms/src/collections/"
    click C "https://github.com/jhb-software/website/tree/main/cms/src/endpoints/"
    click D "https://github.com/jhb-software/website/tree/main/cms/src/blocks/"
    click E "https://github.com/jhb-software/website/tree/main/cms/src/fields/"
    click F "https://github.com/jhb-software/website/tree/main/cms/plugins/cms-content-translator/"
    click G "https://github.com/jhb-software/website/tree/main/cms/plugins/cms-content-translator/src/client/"
    click H "https://github.com/jhb-software/website/tree/main/cms/plugins/cms-content-translator/src/translate/"
    click I "https://github.com/jhb-software/website/tree/main/cms/plugins/cms-content-translator/src/resolvers/"
    click K "https://github.com/jhb-software/website/blob/main/web/astro.config.mjs"
    click L "https://github.com/jhb-software/website/tree/main/web/src/cms/sdk/"
    click M "https://github.com/jhb-software/website/blob/main/pnpm-workspace.yaml"
    click N "https://github.com/jhb-software/website/blob/main/cms/vercel.json"
    click O "https://github.com/jhb-software/website/blob/main/.gitignore"
```
