# retrospct/tpe-web architecture

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

- Interactive diagram: https://gitdiagram.com/retrospct/tpe-web
- Repository: https://github.com/retrospct/tpe-web

## Overview

##### And Label Main Components
- Frontend Client (Next.js Application):
- App folder inside src/app which contains pages (including dynamic pages using [uid]), layout components, and routing.
- Components directory (including UI components, Slice components, and Prismic-specific wrappers) that handle the presentation layer.
- That the website’s pages pull content dynamically from Prismic through configured components like PrismicNextLink and PrismicRichText.
- API Layer:
- API endpoints under src/app/api (such as preview, exit-preview, contact, revalidate, and resend endpoints) that handle server-side interactions.
- Headless CMS Integration:
- Connection to Prismic using the configured client (in prismicio.ts) and the usage of Prismic packages (@prismicio/client, @prismicio/react, and @prismicio/next).
- A Slice Machine component that is used to generate and sync content models (as seen by the presence of customtypes and slices directories along with slicemachine.config.json).
- Database / Data Layer:
- A component for the database (via drizzle configurations in drizzle.config.ts and the src/drizzle folder with migrations). Although the exact database isn’t mentioned by name, recognize that these elements are used to manage data persistence.
- Utility and Helper Libraries:
- Lib/ folder containing helper functions, constants, and validations that support the overall application logic.
- Static Assets:
- Public/ directory that holds images, SVGs, and other static content required by the website.

##### Relationships and Data Flow/Interactions
- From the Prismic CMS (via prismicio.ts) into the Next.js pages and components.
- Between the API endpoints and external integrations (for example, contact form submissions, preview sessions, and revalidation requests).
- That the Slice Machine (and custom types) feeds into the Slices that populate content in the UI, highlighting the modular design of content components.
- That the drizzle (ORM) layer interacts with a database backend, managing migrations and schema, and supporting any runtime data needs.

##### Architectural Patterns and Design Principles
- Separation of concerns:
- Frontend/UI layer (Next.js pages and components) is distinct from the API endpoints.
- Clear delineation between content management (via Prismic and Slice Machine) and content rendering.
- Use of dynamic routing (based on [uid] directories) and server-side functionalities (API routes for preview and content manipulation).
- If applicable, point out the micro-frontends in the form of well-isolated components and Slices that can be independently developed and maintained.

##### Technologies
- Next.js with TypeScript for the web application framework.
- Prismic CMS and its associated libraries (@prismicio/client, @prismicio/react, @prismicio/next) for content management.
- Slice Machine for content modeling and integration.
- Drizzle (and its migrations) for ORM-driven database interactions.
- Tailwind CSS (as suggested by tailwind.config.ts and globals.css) probably used for styling.
- GitHub Actions for CI/CD (noted in the .github/workflows folder).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE1("Pages & Routing (src/app)"):::frontend
        FE2("UI & Presentation Components (src/components)"):::frontend
    end

    %% API Layer
    subgraph "API Layer"
        API("API Endpoints (src/app/api)"):::api
    end

    %% Headless CMS Integration
    subgraph "CMS Integration"
        CMS("Prismic Config (src/prismicio.ts)"):::cms
        SM1("Slice Machine: Custom Types (customtypes)"):::cms
        SM2("Slice Components (src/slices)"):::cms
    end

    %% Data Layer
    subgraph "Data Layer"
        DB1("Drizzle Config (drizzle.config.ts)"):::db
        DB2("Migrations & Schema (src/drizzle)"):::db
    end

    %% Utility and Helpers
    subgraph "Support Libraries"
        UTIL("Utility & Helpers (src/lib)"):::lib
    end

    %% Static Assets
    subgraph "Static Assets"
        STATIC("Static Assets (public)"):::static
    end

    %% Relationships
    CMS -->|"providesContent"| FE1
    SM1 -->|"powersSlices"| FE2
    SM2 -->|"powersSlices"| FE2

    FE1 -->|"callsAPI"| API
    API -->|"drizzleORM"| DB1
    API --> DB2

    FE1 -->|"usesAssets"| STATIC
    FE2 -->|"usesAssets"| STATIC

    UTIL --> FE1
    UTIL --> API

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,color:#1B2631;
    classDef api fill:#F9E79F,stroke:#B7950B,color:#7D6608;
    classDef cms fill:#D5F5E3,stroke:#1D8348,color:#145A32;
    classDef db fill:#FADBD8,stroke:#C0392B,color:#641E16;
    classDef lib fill:#E8DAEF,stroke:#8E44AD,color:#4A235A;
    classDef static fill:#E8F6F3,stroke:#117864,color:#0E6251;

    %% Click Events
    click FE1 "https://github.com/retrospct/tpe-web/tree/main/src/app"
    click FE2 "https://github.com/retrospct/tpe-web/tree/main/src/components"
    click API "https://github.com/retrospct/tpe-web/tree/main/src/app/api"
    click CMS "https://github.com/retrospct/tpe-web/blob/main/src/prismicio.ts"
    click SM1 "https://github.com/retrospct/tpe-web/tree/main/customtypes"
    click SM2 "https://github.com/retrospct/tpe-web/tree/main/src/slices"
    click DB1 "https://github.com/retrospct/tpe-web/blob/main/drizzle.config.ts"
    click DB2 "https://github.com/retrospct/tpe-web/tree/main/src/drizzle"
    click UTIL "https://github.com/retrospct/tpe-web/tree/main/src/lib"
    click STATIC "https://github.com/retrospct/tpe-web/tree/main/public"
```
