# mr04vv/blog architecture

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

- Interactive diagram: https://gitdiagram.com/mr04vv/blog
- Repository: https://github.com/mr04vv/blog

## Overview

##### Project Type and Purpose
- This is a full-stack blog system where articles are written as MDX files stored under the “app/articles” directory.
- The README’s quick “bun i” and “bun run dev” instructions confirm that Bun is used for dependency management and running the development server.
- The presence of directories like “app/components”, “app/islands”, “app/routes”, and “app/server.ts” points to a web server handling routing/rendering along with a client-side UI.

##### Key Components
a. Frontend Components:
- UI Elements: Under “app/components” you have header, footer, articleListItem, profile, etc. These represent the reusable UI pieces.
- Islands: “app/islands” contains interactive components (e.g., cursor-demo, themeButton) that are rendered in isolation for better client performance.
- Styling & Themes: “app/styles” and “app/theme.ts” denote the CSS and theming logic (also backed by Tailwind and PostCSS configs).
b. Content Management / Articles:
- MDX Content: The “app/articles” directory holds dated folders with MDX files. These represent the blog posts.
- MDX Components: “app/lib/mdxComponents” provides custom components (like anchorLink, articleImage, externalOgp) for rendering MDX content.
c. Server and Routing:
- Server Entry Point: “app/server.ts” acts as the central entry to the server logic.
- Routing: “app/routes” includes the main index, dynamic entry routes ([slug].tsx), ogp routes, and even a render utility (“_renderer.tsx”), organizing the URL paths for the site.
d. Utility & Library Modules:
- Helper Functions & Types: “app/lib”, “app/constants”, “app/utils”, and “app/types” provide shared functionality, constants, and type definitions.
- Fetch and Date Helpers: For processing content and external data, functions like “fetchOgp.ts” in “app/lib” are in place.
e. Infrastructure & Configurations:
- Build and Deployment: Files like “bunfig.toml”, “tsconfig.json”, “vite.config.ts”, “tailwind.config.js”, and “postcss.config.js” are central for building and styling.
- CI/CD: The “.github” directory shows actions and workflows (including a custom action for setting up Bun) for automation.
- Static Assets: “assets” and “public” directories hold static files including theme definitions (“theme.json”) and other assets.
- Wrangler & Deployment: The presence of “wrangler.toml” implies potential deployment to Cloudflare Workers.

##### Architectural Relationships and Interactions
- The Web Server (server.ts) handles incoming HTTP requests and routes them via the “app/routes” handlers.
- Depending on the route, the server uses MDX processing (via the components and lib/mdxComponents) to render articles as HTML.
- The UI components residing in “app/components” are composed together to form the main pages (index and entry pages), while islands add client-side interactivity.
- Styling and theming are applied globally through “app/styles” and “app/theme.ts”, influenced by Tailwind and external theme files.
- Utility modules provide shared processing logic (e.g., date formatting, fetching external OGP data) that interconnect various parts of the presentation and server logic.

##### Design Patterns & Principles in Use
- Separation of Concerns: Clear separation between routing, view components, MDX content, and utility functions.
- Component-based Architecture: Frontend UI leverages React-based components (.tsx files) for modularity and reusability.
- Configuration-driven Setup: Use of multiple configuration files ensures that build, theme, and deployment processes are standardized.
- Declarative Routing: Dynamic routes (e.g., [slug].tsx) indicate a pattern where request parameters determine the rendered content.

## Diagram (Mermaid)

```mermaid
graph TD
    A["HTTP Request"]
    B["Server (app/server.ts)"]
    C["Routing Handlers (app/routes)"]
    D["UI Components (app/components)"]
    E["Interactive Islands (app/islands)"]
    F["Styles (app/styles)"]
    G["Theme Manager (app/theme.ts)"]
    H["MDX Article Content (app/articles)"]
    I["Custom MDX Components (app/lib/mdxComponents)"]
    J["Utility & Libraries (app/lib & others)"]

    subgraph "Build & Deployment Configs"
        J1["bunfig.toml"]
        J2["tsconfig.json"]
        J3["vite.config.ts"]
        J4["tailwind.config.js"]
        J5["postcss.config.js"]
    end

    K["CI/CD Pipelines (.github)"]
    L["Static Assets (assets & public)"]
    M["Cloudflare Deployment (wrangler.toml)"]

    %% Data Flow
    A --> B
    B --> C
    C --> D
    C --> H
    H --> I
    I --> D
    D --> E
    F --> D
    G --> D
    J --> I
    J --> B
    J --> D

    %% Infrastructure connections
    K --> J1
    J1 --> B
    J2 --> B
    J3 --> B
    J4 --> B
    J5 --> B
    J1 --> M
    B --> L

    %% Styles
    class A external
    class B,C backend
    class D,E,F,G frontend
    class H,I content
    class J utility
    class J1,J2,J3,J4,J5,K,L,M infra

    %% Click Events
    click B "https://github.com/mr04vv/blog/blob/main/app/server.ts"
    click C "https://github.com/mr04vv/blog/tree/main/app/routes"
    click D "https://github.com/mr04vv/blog/tree/main/app/components"
    click E "https://github.com/mr04vv/blog/tree/main/app/islands"
    click F "https://github.com/mr04vv/blog/tree/main/app/styles"
    click G "https://github.com/mr04vv/blog/blob/main/app/theme.ts"
    click H "https://github.com/mr04vv/blog/tree/main/app/articles"
    click I "https://github.com/mr04vv/blog/tree/main/app/lib/mdxComponents"
    click J "https://github.com/mr04vv/blog/tree/main/app/lib"
    click J1 "https://github.com/mr04vv/blog/blob/main/bunfig.toml"
    click J2 "https://github.com/mr04vv/blog/blob/main/tsconfig.json"
    click J3 "https://github.com/mr04vv/blog/blob/main/vite.config.ts"
    click J4 "https://github.com/mr04vv/blog/blob/main/tailwind.config.js"
    click J5 "https://github.com/mr04vv/blog/blob/main/postcss.config.js"
    click K "https://github.com/mr04vv/blog/blob/main/.github"
    click L "https://github.com/mr04vv/blog/tree/main/assets"
    click M "https://github.com/mr04vv/blog/blob/main/wrangler.toml"

    %% Class Definitions
    classDef external fill:#ffe6e6,stroke:#ff0000,stroke-width:2px;
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef content fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef utility fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef infra fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
```
