# hung2124/blog architecture

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

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

## Overview

##### Project type and purpose
- This is a **static site generator** project: a content-first AI blog template built with the **Astro** framework.
- Purpose: Manage Markdown/MDX content, render it through reusable components & layouts, style via Tailwind, and deploy a high-performance, SEO-optimized blog.

##### File structure
- Top-level:
- `public/` – purely static assets (images, favicon).
- `src/` – source code, subdivided into:
– `content/` (Markdown posts & spec pages)
– `components/` (UI building blocks, subfolders: control, misc, widget)
– `layouts/` (page scaffolding)
– `pages/` (Astro route files generating URLs)
– `plugins/` (remark/rehype/Expressive-Code extensions)
– `styles/` (global, markdown, themes)
– `utils/`, `constants/`, `types/` (helper functions, TS types)
– `i18n/` (multi-language translations)
– `config.ts` (site, navigation, profile settings)
- Config/build files:
- `astro.config.mjs`, `package.json`, `tailwind.config.cjs`, `tsconfig.json`, `.github/workflows/static.yml`.

##### README for additional insights
- Architecture is centered around **Static Site Generation (SSG)** using Astro + Vite/ESBuild.
- Features: content pipeline (Markdown → syntax highlighting → KaTeX → HTML), styling (Tailwind), search (Pagefind), CI/CD (GitHub Actions → GitHub Pages/Vercel).

##### Detail, not over-complication
- Every essential directory as a logical component (Content, Components, Styles, Plugins).
- Plugin chain (remark → rehype → KaTeX) as a sub-pipeline.
- Hosting targets (GitHub Pages, Vercel) under deployment.

## Diagram (Mermaid)

```mermaid
flowchart TD
  subgraph "Content Layer"
    MDPosts["Markdown Posts"]:::static
    click MDPosts "https://github.com/hung2124/blog/tree/main/src/content/posts/"
    SpecPages["Spec Pages"]:::static
    click SpecPages "https://github.com/hung2124/blog/tree/main/src/content/spec/"
    PubImages["Public Images"]:::static
    click PubImages "https://github.com/hung2124/blog/tree/main/public/images/"
    AssetImages["Asset Images"]:::static
    click AssetImages "https://github.com/hung2124/blog/tree/main/src/assets/images/"
  end

  subgraph "Presentation Layer"
    Components["UI Components"]:::static
    click Components "https://github.com/hung2124/blog/tree/main/src/components/"
    ControlComp["Control Components"]:::static
    click ControlComp "https://github.com/hung2124/blog/tree/main/src/components/control/"
    MiscComp["Misc Components"]:::static
    click MiscComp "https://github.com/hung2124/blog/tree/main/src/components/misc/"
    WidgetComp["Widget Components"]:::static
    click WidgetComp "https://github.com/hung2124/blog/tree/main/src/components/widget/"
    Layouts["Page Layouts"]:::static
    click Layouts "https://github.com/hung2124/blog/tree/main/src/layouts/"
    Styles["Styles (Tailwind & CSS)"]:::static
    click Styles "https://github.com/hung2124/blog/tree/main/src/styles/"
    TailwindCfg["tailwind.config.cjs"]:::static
    click TailwindCfg "https://github.com/hung2124/blog/blob/main/tailwind.config.cjs"
    PostCSSCfg["postcss.config.mjs"]:::static
    click PostCSSCfg "https://github.com/hung2124/blog/blob/main/postcss.config.mjs"
    I18nKey["i18n Keys"]:::static
    click I18nKey "https://github.com/hung2124/blog/blob/main/src/i18n/i18nKey.ts"
    I18nLang["i18n Languages"]:::static
    click I18nLang "https://github.com/hung2124/blog/tree/main/src/i18n/languages/"
    I18nTrans["i18n Translation"]:::static
    click I18nTrans "https://github.com/hung2124/blog/blob/main/src/i18n/translation.ts"
  end

  subgraph "Build Layer"
    AstroCFG["Astro Config"]:::process
    click AstroCFG "https://github.com/hung2124/blog/blob/main/astro.config.mjs"
    ViteDev["Vite Dev Server"]:::process
    Remark["Remark & Rehype Plugins"]:::process
    click Remark "https://github.com/hung2124/blog/tree/main/src/plugins/"
    KaTeX["KaTeX Renderer"]:::process
    PageFindIdx["PageFind Indexer"]:::process
    ESBuild["ESBuild Bundler"]:::process
    PostCSS["PostCSS Processor"]:::process
    AstroRender["Astro Renderer"]:::process
  end

  subgraph "Deployment Layer"
    CI["GitHub Actions"]:::deploy
    click CI "https://github.com/hung2124/blog/blob/main/.github/workflows/static.yml"
    Dist["Static Output (dist)"]:::deploy
    PKG["package.json"]:::deploy
    click PKG "https://github.com/hung2124/blog/blob/main/package.json"
    PNPMLock["pnpm-lock.yaml"]:::deploy
    click PNPMLock "https://github.com/hung2124/blog/blob/main/pnpm-lock.yaml"
    Pages["GitHub Pages"]:::deploy
    Vercel["Vercel"]:::deploy
    Netlify["Netlify"]:::deploy
    DevTS["tsconfig.json"]:::deploy
    click DevTS "https://github.com/hung2124/blog/blob/main/tsconfig.json"
    ESLintIgnore[".eslintignore"]:::deploy
    click ESLintIgnore "https://github.com/hung2124/blog/blob/main/.eslintignore"
    GitIgnore[".gitignore"]:::deploy
    click GitIgnore "https://github.com/hung2124/blog/blob/main/.gitignore"
    VSCode[".vscode/"]:::deploy
    click VSCode "https://github.com/hung2124/blog/tree/main/.vscode/"
  end

  GA["Google Analytics"]:::external
  PageFindCDN["PageFind CDN"]:::external
  User["End User Browser"]:::external

  MDPosts --> AstroRender
  SpecPages --> AstroRender
  PubImages --> AstroRender
  AssetImages --> AstroRender

  Components --> AstroRender
  ControlComp --> Components
  MiscComp --> Components
  WidgetComp --> Components
  Layouts --> AstroRender

  Styles --> PostCSS
  TailwindCfg --> PostCSS
  PostCSSCfg --> PostCSS
  PostCSS --> AstroRender

  I18nKey --> AstroRender
  I18nLang --> AstroRender
  I18nTrans --> AstroRender

  AstroCFG --> AstroRender
  ViteDev --> AstroRender
  Remark --> AstroRender
  KaTeX --> AstroRender
  PageFindIdx --> AstroRender
  ESBuild --> Dist
  AstroRender --> ESBuild
  AstroRender --> Dist

  AstroRender --> GA
  AstroRender --> PageFindIdx

  CI --> Dist
  Dist --> Pages
  Dist --> Vercel
  Dist --> Netlify
  Dist --> PageFindCDN
  Pages --> User
  Vercel --> User
  Netlify --> User
  User --> ViteDev

  classDef static fill:#cce5ff,stroke:#333,stroke-width:1px;
  classDef process fill:#d4edda,stroke:#333,stroke-width:1px;
  classDef deploy fill:#ffe5b4,stroke:#333,stroke-width:1px;
  classDef external fill:#e2e3e5,stroke:#333,stroke-width:1px;
```
