# e235221/blog architecture

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

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

## Overview

##### Project type and purpose
- This is a JAMstack‐style static blog generator.
- Build step (Node.js) reads Markdown posts, templates, and partials to emit static HTML.
- Deployed to GitHub Pages; at runtime, the browser fetches HTML/CSS/JS and static assets.

##### File structure
- Top level:
- scripts/ — Node.js build logic
- templates/ & partials/ — HTML skeletons
- posts/ — Markdown source + posts.json manifest
- styles/ & assets/ — CSS and static images
- index.html & article.html — built outputs
- Build script (scripts/build.js) stitches templates+partials+posts.json → index.html & article.html
- Client‐side scripts (main.js & article.js) dynamically pull posts.json or Markdown at runtime

##### README insights
- Explains build and local‐run workflow
- Describes how new Markdown → posts.json entry → rebuild
- Clarifies runtime behavior: index.html for listing, article.html?post=slug for rendering a single post

##### Main components
a. Developer environment (local machine)
- Markdown posts & JSON manifest
- Templates & Partials
- Build script (scripts/build.js)
b. CI/CD / Repository
- GitHub repo + .nojekyll
- GitHub Pages host
c. Static Site Artifacts
- index.html, article.html
- CSS (main.css, article.css)
- JS (main.js, article.js, build.js)
- assets/images
d. Client (Browser) at runtime
- HTTP GET static HTML/CSS/JS/assets
- main.js → fetch posts.json → render list
- article.js → read query param → fetch slug.md → convert markdown to HTML

##### Relationships & interactions
- Developer → invokes build script → reads source (templates, partials, posts) → outputs static files
- Developer → pushes to GitHub → GitHub Pages publishes to CDN
- Browser ← HTTP GET static files from GitHub Pages
- Browser (main.js) ← GET /posts/posts.json
- Browser (article.js) ← GET /posts/{slug}.md

##### Architectural patterns & principles
- Static site generation (SSG) at build time
- Client‐side rendering of dynamic content (Markdown → HTML)
- Separation of concerns: templates vs. partials vs. content vs. style vs. runtime scripts

##### Technologies & frameworks
- Node.js (build script)
- Vanilla JavaScript for client behavior (no framework)
- GitHub Pages as static host
- Python’s http.server for local preview

- Transformation steps (Markdown → HTML)
- Query‐parameter mechanism for article.html

## Diagram (Mermaid)

```mermaid
flowchart TB
  subgraph "Build Stage"
    subgraph "Source Assets"
      MD["Markdown Posts (posts/*.md)"]:::dataStore
      JSONSrc["posts.json"]:::dataStore
      TemplateIndex["Index Template (templates/index.html)"]:::sourceAsset
      TemplateArticle["Article Template (templates/article.html)"]:::sourceAsset
      PartialHeader["Header Partial (partials/header.html)"]:::sourceAsset
      PartialFooter["Footer Partial (partials/footer.html)"]:::sourceAsset
    end
    BuildScript["Build Script (scripts/build.js)"]:::buildComp
    MD -->|"reads"| BuildScript
    JSONSrc -->|"reads"| BuildScript
    TemplateIndex -->|"reads"| BuildScript
    TemplateArticle -->|"reads"| BuildScript
    PartialHeader -->|"reads"| BuildScript
    PartialFooter -->|"reads"| BuildScript

    subgraph "Generated Artifacts"
      OutIndex["index.html"]:::output
      OutArticle["article.html"]:::output
      CSSMain["styles/main.css"]:::output
      CSSArticle["styles/article.css"]:::output
      JSMain["scripts/main.js"]:::output
      JSArticle["scripts/article.js"]:::output
      Assets["assets/images/"]:::output
      NoJekyll[".nojekyll"]:::output
      Readme["README.md"]:::output
    end

    BuildScript -->|"outputs"| OutIndex
    BuildScript -->|"outputs"| OutArticle
    BuildScript -->|"outputs"| CSSMain
    BuildScript -->|"outputs"| CSSArticle
    BuildScript -->|"outputs"| JSMain
    BuildScript -->|"outputs"| JSArticle
    BuildScript -->|"outputs"| Assets
    BuildScript -->|"outputs"| NoJekyll
    BuildScript -->|"outputs"| Readme
  end

  subgraph "Deployment"
    GitHubRepo["GitHub Repository"]:::deploy
    GitHubPages["GitHub Pages CDN"]:::deploy
  end

  OutIndex -->|"push → GitHub"| GitHubRepo
  OutArticle -->|"push → GitHub"| GitHubRepo
  CSSMain -->|"push → GitHub"| GitHubRepo
  CSSArticle -->|"push → GitHub"| GitHubRepo
  JSMain -->|"push → GitHub"| GitHubRepo
  JSArticle -->|"push → GitHub"| GitHubRepo
  Assets -->|"push → GitHub"| GitHubRepo
  NoJekyll -->|"push → GitHub"| GitHubRepo
  Readme -->|"push → GitHub"| GitHubRepo
  GitHubRepo -->|"publishes"| GitHubPages

  subgraph "Browser (Client Runtime)"
    Browser["Browser"]:::browser
    Browser -->|"HTTP GET static files"| GitHubPages
    ClientMain["main.js"]:::buildComp
    ClientArticle["article.js"]:::buildComp
    Browser --> ClientMain
    Browser --> ClientArticle
    ClientMain -->|"fetch posts.json"| GitHubPages
    ClientArticle -->|"fetch slug.md"| GitHubPages
  end

  classDef sourceAsset fill:#cce5ff,stroke:#004085,color:#004085
  classDef buildComp fill:#d4edda,stroke:#155724,color:#155724
  classDef dataStore fill:#fff3cd,stroke:#856404,color:#856404
  classDef output fill:#ffe5b4,stroke:#cc8400,color:#cc8400
  classDef deploy fill:#e2e3e5,stroke:#6c757d,color:#6c757d
  classDef browser fill:#e2d6f3,stroke:#5a246e,color:#5a246e

  click MD "https://github.com/e235221/blog/tree/main/posts/"
  click JSONSrc "https://github.com/e235221/blog/blob/main/posts/posts.json"
  click TemplateIndex "https://github.com/e235221/blog/blob/main/templates/index.html"
  click TemplateArticle "https://github.com/e235221/blog/blob/main/templates/article.html"
  click PartialHeader "https://github.com/e235221/blog/blob/main/partials/header.html"
  click PartialFooter "https://github.com/e235221/blog/blob/main/partials/footer.html"
  click BuildScript "https://github.com/e235221/blog/blob/main/scripts/build.js"
  click OutIndex "https://github.com/e235221/blog/blob/main/index.html"
  click OutArticle "https://github.com/e235221/blog/blob/main/article.html"
  click CSSMain "https://github.com/e235221/blog/blob/main/styles/main.css"
  click CSSArticle "https://github.com/e235221/blog/blob/main/styles/article.css"
  click JSMain "https://github.com/e235221/blog/blob/main/scripts/main.js"
  click JSArticle "https://github.com/e235221/blog/blob/main/scripts/article.js"
  click Assets "https://github.com/e235221/blog/tree/main/assets/images/"
  click NoJekyll "https://github.com/e235221/blog/blob/main/.nojekyll"
  click Readme "https://github.com/e235221/blog/blob/main/README.md"
```
