# wirtzdan/website architecture

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

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

## Overview

##### Main Components
- Frontend UI Layer:
- Pages (located under the pages directory): These include static pages (e.g., about, index, 404) as well as dynamic routes (like [slug] for blog posts).
- Components (in the components folder): Smaller building blocks such as headers, footers, blog cards, navigation components, etc.
- Layouts (in the layouts folder): These provide page structure for sections like blogs, legal pages, newsletters, etc.
- Backend / API Layer:
- API Endpoints (in pages/api): The endpoints (e.g., addSubscriber.js, sendSuggestion.js) that handle server-side logic and integrations.
- Library (in the lib folder):
▪ Integration with Airtable (lib/airtable.js) to serve as the backend for pages like blog, books, and tools.
▪ Notion-related functionality (under lib/notion) to handle additional content or rendering style.
▪ Helper libraries such as lib/rss.js and lib/usePagination.js that support content delivery.
- Data Management:
- Local JSON files (in the data folder) used to store structured data (e.g., experience, interests) that may be used in pages such as the portfolio.
- External Services:
- Airtable: Used as a backend data store.
- Raindrop: Mentioned in the README as a possible integration (and others like Notion APIs).
- Configuration & Static Assets:
- Configuration files (e.g., next.config.js, next-seo.config.js, .env.example) and styling/theme files (theme.js).
- Public assets (static images, favicons, sounds, and the RSS XML) are located under the public folder.

##### Relationships and Interactions
- The Pages in Next.js serve as entry points that tie the UI components, layouts, and API endpoints together.
- Components are reused across pages to build the UI, and they fetch or display data provided by the API endpoints.
- The API layer (in pages/api) receives requests (triggered by client-side actions) and makes external calls (e.g., to Airtable via the lib/airtable module) to pull or update data.
- The lib directory acts as an abstraction over external integrations (Airtable, Notion, etc.) and provides utilities used by both pages and API endpoints.
- Static assets (public folder) and environmental configuration allow for seamless local development and production deployment.

##### Architectural Patterns and Design Principles
- Component-Based Architecture: The use of React components and dedicated directories for components/layouts illustrates a strong separation of UI concerns.
- API-First Interaction: The usage of API routes in Next.js to handle backend interactions fits well with modern full-stack Next.js applications.
- External Service Integration: Airtable is used as a simple backend, and its integration is abstracted out in the lib folder.
- Configuration Management: Environment variables (with .env.example and .env.local) separate configuration settings from code.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend UI Layer"
        P["Pages (Next.js)"]
        RC["React Components"]
        LT["Layouts"]
        P -->|"renders"| RC
        P -->|"applies_layout"| LT
    end

    subgraph "Backend / API Layer"
        API["API Endpoints"]
        subgraph "Libraries"
            Airt["Airtable Integration"]
            Notion["Notion Module"]
            RSS["RSS Utility"]
            PAG["Pagination Utility"]
        end
        API -->|"calls"| Airt
        API -->|"calls"| Notion
        API -->|"calls"| RSS
        API -->|"calls"| PAG
    end

    subgraph "Data & Assets"
        Data["Local Data Files"]
        Config["Configuration Files"]
        Public["Public Assets"]
    end

    subgraph "External Services"
        ExtAirt["Airtable"]
        Raindrop["Raindrop"]
    end

    %% Interactions between layers
    P -->|"fetches_data_from"| API
    Config -->|"configures"| P
    Config -->|"configures"| API
    Data -->|"supplies_data_to"| P
    API -->|"integrates_with"| ExtAirt
    Airt -->|"interfaces_with"| ExtAirt
    API -->|"possible_integration"| Raindrop

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef backend fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;
    classDef config fill:#f8bbd0,stroke:#880e4f,stroke-width:2px;
    classDef external fill:#ffcdd2,stroke:#b71c1c,stroke-width:2px;
    
    class P,RC,LT frontend;
    class API,Airt,Notion,RSS,PAG backend;
    class Data,Config,Public config;
    class ExtAirt,Raindrop external;

    %% Click Events
    click P "https://github.com/wirtzdan/website/tree/master/pages/"
    click RC "https://github.com/wirtzdan/website/tree/master/components/"
    click LT "https://github.com/wirtzdan/website/tree/master/layouts/"
    click API "https://github.com/wirtzdan/website/tree/master/pages/api/"
    click Airt "https://github.com/wirtzdan/website/blob/master/lib/airtable.js"
    click Notion "https://github.com/wirtzdan/website/tree/master/lib/notion/"
    click RSS "https://github.com/wirtzdan/website/blob/master/lib/rss.js"
    click PAG "https://github.com/wirtzdan/website/blob/master/lib/usePagination.js"
    click Data "https://github.com/wirtzdan/website/tree/master/data/"
    click Config "https://github.com/wirtzdan/website/blob/master/next.config.js"
    click Public "https://github.com/wirtzdan/website/tree/master/public/"
```
