# mh4gf/mysite architecture

> Architecture diagram of the GitHub repository mh4gf/mysite, 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/mh4gf/mysite
- Repository: https://github.com/mh4gf/mysite

## Overview

##### Core System Layers and Main Components
- Frontend Application (Next.js App):
- The central hub is the Next.js application found mainly in the “app” folder.
- It contains file-based routing directories such as (pages), dynamic [slug] routes (for articles and other pages), and dedicated pages for special content (like “thinking-in-career”).
- UI Components:
- Content Management:
- The “contents” directory (with subfolders for “articles” and “about”) together with a “contentlayer.config.ts” file indicate that markdown content is processed and integrated into the Next.js pages.
- Utility and Helper Functions:
- “app/_utils” and other helper files help with common tasks such as date formatting, class name (cn) composition, and constants.
- Static Assets and Public Resources:
- The “public” directory holds images and static files (including the site manifest).
- CI/CD and Testing:
- GitHub workflows (in .github/workflows) for continuous integration, along with Playwright and Vitest configurations, indicate automated testing and quality assurance.
- Build and Configuration Tools:
- Config files like “next.config.js”, “tailwind.config.js”, “postcss.config.js” are key to the build and styling pipeline.

##### Relationships and Interactions
- The Next.js application (frontend) organizes pages following the new App Router with several nested directories. These pages dynamically import various feature modules (e.g., articles, markdownRenderer) to render specific content.
- Content stored as markdown in the “contents” folder is processed (likely via Contentlayer) and then injected into React component pages.
- UI components and feature modules (such as those handling commands or theme changes) interface directly with the Next.js pages, contributing to the dynamic user experience.
- There is a clear separation between presentation (in “_components”) and logical features (in “_features”), which then cooperate to render complete pages.
- Testing (both e2e and unit tests) is interwoven: tests within “__vrt__”, “__tests__” folders ensure the reliability of key parts.
- GitHub workflows further ensure code quality and automated deployment processes.

##### Architectural Patterns/Design Principles
- File-Based Routing: The project utilizes Next.js’s app directory with file-based dynamic routing (e.g., [slug]) to manage different pages and content types.
- Separation of Concerns: The architecture clearly separates UI components, feature logic, utility functions, and content data. Each “_features” subfolder focuses on a distinct functionality (like markdown processing or theme management).
- Modular Design: The modularity is evident from the breakdown of functionality across various folders, making it easier to update or replace components without major system-wide changes.
- Test-Driven Development: Multiple test directories (e.g., __vrt__, __tests__) indicate that testing is an integral part of the development process.
- Integration with Static Site Generation and API Layer: Besides dynamic rendering, the integration (e.g., content fetching from markdown) suggests that some parts of the application might be pre-rendered for performance.

## Diagram (Mermaid)

```mermaid
flowchart TD
    APP["Next.js Application (Frontend)"]:::app

    subgraph "Frontend Components"
        A1["Pages & Routing"]:::pages
        A2["UI Components (Reusables)"]:::components
        subgraph "Feature Modules"
            F1["Articles Feature"]:::feature
            F2["Color Mode (Theming)"]:::feature
            F3["Command Palette"]:::feature
            F4["Markdown Rendering"]:::feature
            F5["Rich Link Card"]:::feature
            F6["Tweet Embeds"]:::feature
            F7["View Transitions"]:::feature
            F8["Top Section/Work Experience"]:::feature
        end
    end

    subgraph "Content & Assets"
        C2["Content Processor/Configuration"]:::config
        C1["Markdown Contents"]:::content
        CA["Static Assets & Public Resources"]:::assets
    end

    subgraph "Utilities & Build"
        U1["Utilities & Helpers"]:::utils
        subgraph "Build & Config Tools"
            B1["next.config.js"]:::build
            B2["tailwind.config.js"]:::build
            B3["postcss.config.js"]:::build
        end
    end

    subgraph "CI/CD & Testing"
        T1["CI/CD (GitHub Workflows)"]:::ci
        T2["E2E Testing & Unit Tests"]:::ci
    end

    %% Relationships within Frontend
    APP -->|"contains"| A1
    APP -->|"includes"| A2
    A2 -->|"render"| A1
    F1 -->|"render"| A1
    F2 -->|"render"| A1
    F3 -->|"render"| A1
    F4 -->|"render"| A1
    F5 -->|"render"| A1
    F6 -->|"render"| A1
    F7 -->|"render"| A1
    F8 -->|"render"| A1

    %% Content Management Relationships
    C2 -->|"process"| C1
    C1 -->|"feeds"| A1
    CA -->|"serve"| A1

    %% Utilities & Build Relationships
    U1 -->|"support"| A1
    B1 -->|"configure"| APP
    B2 -->|"configure"| APP
    B3 -->|"configure"| APP

    %% CI/CD & Testing Relationships
    T1 -.->|"quality"| APP
    T2 -.->|"quality"| APP

    %% Click Events
    click APP "https://github.com/mh4gf/mysite/tree/main/app"
    click A1 "https://github.com/mh4gf/mysite/tree/main/app/(pages)"
    click A2 "https://github.com/mh4gf/mysite/tree/main/app/_components"
    click F1 "https://github.com/mh4gf/mysite/tree/main/app/_features/articles"
    click F2 "https://github.com/mh4gf/mysite/tree/main/app/_features/colorMode"
    click F3 "https://github.com/mh4gf/mysite/tree/main/app/_features/command"
    click F4 "https://github.com/mh4gf/mysite/tree/main/app/_features/markdownRenderer"
    click F5 "https://github.com/mh4gf/mysite/tree/main/app/_features/richLinkCard"
    click F6 "https://github.com/mh4gf/mysite/tree/main/app/_features/tweetEmbed"
    click F7 "https://github.com/mh4gf/mysite/tree/main/app/_features/viewTransition"
    click F8 "https://github.com/mh4gf/mysite/tree/main/app/_features/top"
    click C1 "https://github.com/mh4gf/mysite/tree/main/contents"
    click C2 "https://github.com/mh4gf/mysite/blob/main/contentlayer.config.ts"
    click U1 "https://github.com/mh4gf/mysite/tree/main/app/_utils"
    click CA "https://github.com/mh4gf/mysite/tree/main/public"
    click T1 "https://github.com/mh4gf/mysite/tree/main/.github/workflows"
    click T2 "https://github.com/mh4gf/mysite/tree/main/app/__vrt__"
    click B1 "https://github.com/mh4gf/mysite/blob/main/next.config.js"
    click B2 "https://github.com/mh4gf/mysite/blob/main/tailwind.config.js"
    click B3 "https://github.com/mh4gf/mysite/blob/main/postcss.config.js"

    %% Styles
    classDef app fill:#ADD8E6,stroke:#00008B,stroke-width:2px;
    classDef pages fill:#90EE90,stroke:#006400,stroke-width:2px;
    classDef components fill:#FFDAB9,stroke:#CD853F,stroke-width:2px;
    classDef feature fill:#FFDEAD,stroke:#CD853F,stroke-width:2px;
    classDef content fill:#C1FFC1,stroke:#228B22,stroke-width:2px;
    classDef config fill:#ADD8E6,stroke:#00008B,stroke-width:2px;
    classDef utils fill:#FFEFD5,stroke:#8B4513,stroke-width:2px;
    classDef assets fill:#E0FFFF,stroke:#20B2AA,stroke-width:2px;
    classDef ci fill:#F0E68C,stroke:#BDB76B,stroke-width:2px;
    classDef build fill:#D3D3D3,stroke:#696969,stroke-width:2px;
```
