# ztkuaikuai/blog architecture

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

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

## Overview

This project is a personal blog built with the Astro framework. The primary purpose of the project is to generate and serve a static blog site complete with various pages (home, posts, tag pages, etc.), custom components, and utilities to calculate reading times and determine application configuration.

##### Main Components
- Astro Framework & Configuration: Represent the Astro configuration files (astro.config.mjs, tailwind.config.mjs, tsconfig.json, etc.) that dictate how the site is built and rendered.
- Source Code Organization (src Directory):
- Components: Identify reusable UI elements such as Navbar, Footer, Hero, Card, Post Header, etc. These are the building blocks of each page.
- Layouts: Show the Base and Post layouts that define the overall page structure.
- Pages: Represent the various pages (index, posts, tag pages) that render the site’s content. Notice the Markdown (.md) files in “src/pages/posts”, which contain the actual blog post content.
- Utilities: Functions and helpers (in src/utils) such as AppConfig.ts, data.util.ts, and readingTime.ts that aid in computing data for display.
- Public Assets: This includes the static files, such as the robots.txt, RSS feed styles, and other assets that are directly served by the server.
- Environment and Package Management: Files like package.json, pnpm-lock.yaml, .gitignore, and other configuration files which are crucial for building, dependency management, and version control.

##### Architectural Patterns and Design Principles
- Static Site Generation: Emphasize that the project leverages Astro to statically generate pages from Markdown content, which is a core design principle.
- Component-Driven Development: The separation between reusable UI components and page layouts is a component-driven architecture.
- Separation of Concerns: UI (components and layouts), content (Markdown in posts), and utilities (helper functions) are clearly separated.
- Declarative Data Flow: Layouts and components receive data (either passed as props or computed) and render it, showing a clear unidirectional data flow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Astro Build & Configuration
    subgraph "Astro Build & Configuration"
        AstroConfig["Astro Config"]
        TailwindConfig["Tailwind Config"]
        TSConfig["TS Config"]
        PackageJSON["Package JSON"]
    end

    %% Build Process
    BuildProc["Astro Build Process"]

    %% Components
    subgraph "Components"
        Navbar["Navbar Component"]
        Footer["Footer Component"]
        Hero["Hero Component"]
        Card["Card Component"]
        PostHeader["PostHeader Component"]
        PostContent["PostContent Component"]
    end

    %% Layouts
    subgraph "Layouts"
        BaseLayout["Base Layout"]
        PostLayout["Post Layout"]
    end

    %% Pages
    subgraph "Pages"
        Home["Home Page"]
        Posts["Blog Posts"]
        Tags["Tag Pages"]
        RSS["RSS Feed Endpoint"]
    end

    %% Utilities
    subgraph "Utilities"
        AppConfig["AppConfig"]
        DataUtil["Data Util"]
        ReadingTime["ReadingTime"]
    end

    %% Public Assets
    subgraph "Public Assets"
        Robots["robots.txt"]
        RSSStyles["RSS Feed Styles"]
    end

    %% Content Source
    MDP["Markdown Posts"]

    %% Connections from Configuration to Build Process
    AstroConfig -->|"feeds"| BuildProc
    TailwindConfig -->|"feeds"| BuildProc
    TSConfig -->|"feeds"| BuildProc
    PackageJSON -->|"feeds"| BuildProc

    %% Build Process to Pages
    BuildProc -->|"builds"| Home
    BuildProc -->|"builds"| Posts
    BuildProc -->|"builds"| Tags
    BuildProc -->|"builds"| RSS
    AppConfig -->|"configures"| BuildProc
    DataUtil -->|"assists"| BuildProc

    %% Pages and Markdown Integration
    Posts -->|"contains"| MDP
    MDP -->|"processed by"| PostLayout

    %% Layouts Integration with Components
    Home -->|"uses"| BaseLayout
    Tags -->|"uses"| BaseLayout
    PostLayout -->|"renders"| PostHeader
    PostLayout -->|"renders"| PostContent

    %% Base Layout includes common UI components
    BaseLayout -->|"includes"| Navbar
    BaseLayout -->|"includes"| Footer
    BaseLayout -->|"includes"| Hero

    %% Blog Posts listing uses Card for previews
    Posts -->|"utilizes"| Card

    %% Utility integration for dynamic content computation
    ReadingTime -->|"calculates"| PostLayout

    %% Public Assets accessed by RSS Feed
    RSS -->|"accesses"| RSSStyles
    RSS -->|"accesses"| Robots

    %% Click Events
    click AstroConfig "https://github.com/ztkuaikuai/blog/blob/main/astro.config.mjs"
    click TailwindConfig "https://github.com/ztkuaikuai/blog/blob/main/tailwind.config.mjs"
    click TSConfig "https://github.com/ztkuaikuai/blog/blob/main/tsconfig.json"
    click PackageJSON "https://github.com/ztkuaikuai/blog/blob/main/package.json"
    click Navbar "https://github.com/ztkuaikuai/blog/blob/main/src/components/Navbar.astro"
    click Footer "https://github.com/ztkuaikuai/blog/blob/main/src/components/Footer.astro"
    click Hero "https://github.com/ztkuaikuai/blog/blob/main/src/components/Hero.astro"
    click Card "https://github.com/ztkuaikuai/blog/blob/main/src/components/Card.astro"
    click PostHeader "https://github.com/ztkuaikuai/blog/blob/main/src/components/PostHeader.astro"
    click PostContent "https://github.com/ztkuaikuai/blog/blob/main/src/components/PostContent.astro"
    click BaseLayout "https://github.com/ztkuaikuai/blog/blob/main/src/layouts/Base.astro"
    click PostLayout "https://github.com/ztkuaikuai/blog/blob/main/src/layouts/post.astro"
    click Home "https://github.com/ztkuaikuai/blog/blob/main/src/pages/index.astro"
    click Posts "https://github.com/ztkuaikuai/blog/tree/main/src/pages/posts/"
    click Tags "https://github.com/ztkuaikuai/blog/tree/main/src/pages/tags/"
    click RSS "https://github.com/ztkuaikuai/blog/blob/main/src/pages/rss.xml.js"
    click AppConfig "https://github.com/ztkuaikuai/blog/blob/main/src/utils/AppConfig.ts"
    click DataUtil "https://github.com/ztkuaikuai/blog/blob/main/src/utils/data.util.ts"
    click ReadingTime "https://github.com/ztkuaikuai/blog/blob/main/src/utils/readingTime.ts"
    click Robots "https://github.com/ztkuaikuai/blog/blob/main/public/robots.txt"
    click RSSStyles "https://github.com/ztkuaikuai/blog/blob/main/public/rss/styles.xsl"

    %% Class Definitions for Color Coding
    classDef config fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef build fill:#FFDEAD,stroke:#333,stroke-width:2px;
    classDef comp fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef layout fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef page fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef util fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef asset fill:#FFA500,stroke:#333,stroke-width:2px;
    classDef content fill:#E6E6FA,stroke:#333,stroke-width:2px;

    class AstroConfig,TailwindConfig,TSConfig,PackageJSON config;
    class BuildProc build;
    class Navbar,Footer,Hero,Card,PostHeader,PostContent comp;
    class BaseLayout,PostLayout layout;
    class Home,Posts,Tags,RSS page;
    class AppConfig,DataUtil,ReadingTime util;
    class Robots,RSSStyles asset;
    class MDP content;
```
