# by-hahn/blog architecture

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

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

## Overview

This is a custom Node.js static publishing system. Authors place dated Markdown posts in category directories; a full build parses and validates them, renders post pages and site indexes from templates, and emits static assets and metadata for hosting. Readers then receive complete HTML, while browser-side JavaScript manages theme preference. The README documents additional capabilities, including TOCs, featured posts, category pages, reading time, SEO metadata, and sitemap generation. The build script is excerpted only in part, so edges for documented but unsampled behavior cite the README.

Main entry points: [`scripts/build.js`](https://github.com/by-hahn/blog/blob/main/scripts/build.js) (Build orchestrator), [`src/template-post.html`](https://github.com/by-hahn/blog/blob/main/src/template-post.html) (Post template), [`src/template-index.html`](https://github.com/by-hahn/blog/blob/main/src/template-index.html) (Index template), [`src/assets/js/theme.js`](https://github.com/by-hahn/blog/blob/main/src/assets/js/theme.js) (Theme preference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_content["Content model"]
  node_markdown["Markdown posts"]
  node_frontmatter["Post metadata"]
end

subgraph group_build["Static generation"]
  node_builder["Build orchestrator<br/>[build.js]"]
  node_validation["Input validation<br/>[build.js]"]
  node_content_parser["Content parsing<br/>[build.js]"]
  node_post_renderer["Post rendering<br/>[build.js]"]
  node_toc["TOC generation<br/>[build.js]"]
  node_metadata["SEO metadata<br/>[build.js]"]
  node_home_renderer["Homepage generation<br/>[build.js]"]
  node_category_renderer["Category pages<br/>[build.js]"]
  node_sitemap["Sitemap generation<br/>[build.js]"]
end

subgraph group_site["Site experience"]
  node_post_template["Post template<br/>[template-post.html]"]
  node_index_template["Index template"]
  node_theme["Theme preference<br/>[theme.js]"]
  node_styles["Responsive styling<br/>[main.css]"]
end

subgraph group_delivery["Published site"]
  node_static_output["Generated site<br/>[build.js]"]
  node_hosting["Static hosting"]
end

node_authors(("Authors"))
node_readers(("Readers"))

node_authors -->|"write"| node_markdown
node_authors -->|"set metadata"| node_frontmatter
node_builder -->|"reads posts"| node_markdown
node_builder -->|"loads template"| node_post_template
node_builder -->|"loads template"| node_index_template
node_builder -->|"validates input"| node_validation
node_builder -->|"parses posts"| node_content_parser
node_content_parser -->|"renders Markdown"| node_post_renderer
node_post_renderer -->|"extracts headings"| node_toc
node_builder -->|"builds pages"| node_post_renderer
node_post_renderer -->|"fills placeholders"| node_post_template
node_post_renderer -->|"adds post metadata"| node_metadata
node_builder -->|"builds homepage"| node_home_renderer
node_home_renderer -->|"fills placeholders"| node_index_template
node_builder -->|"builds category pages"| node_category_renderer
node_builder -->|"generates sitemap"| node_sitemap
node_builder -->|"writes files"| node_static_output
node_post_template -->|"renders into"| node_static_output
node_index_template -->|"renders into"| node_static_output
node_theme -->|"sets preference"| node_readers
node_static_output -->|"deploys"| node_hosting
node_hosting -->|"serves pages"| node_readers
node_static_output -->|"includes assets"| node_styles
node_static_output -->|"includes script"| node_theme

click node_markdown "https://github.com/by-hahn/blog/tree/main/posts"
click node_frontmatter "https://github.com/by-hahn/blog/tree/main/posts"
click node_builder "https://github.com/by-hahn/blog/blob/main/scripts/build.js"
click node_validation "https://github.com/by-hahn/blog/blob/main/scripts/build.js"
click node_content_parser "https://github.com/by-hahn/blog/blob/main/scripts/build.js"
click node_post_renderer "https://github.com/by-hahn/blog/blob/main/scripts/build.js"
click node_toc "https://github.com/by-hahn/blog/blob/main/scripts/build.js"
click node_metadata "https://github.com/by-hahn/blog/blob/main/scripts/build.js"
click node_home_renderer "https://github.com/by-hahn/blog/blob/main/scripts/build.js"
click node_category_renderer "https://github.com/by-hahn/blog/blob/main/scripts/build.js"
click node_sitemap "https://github.com/by-hahn/blog/blob/main/scripts/build.js"
click node_post_template "https://github.com/by-hahn/blog/blob/main/src/template-post.html"
click node_index_template "https://github.com/by-hahn/blog/blob/main/src/template-index.html"
click node_theme "https://github.com/by-hahn/blog/blob/main/src/assets/js/theme.js"
click node_styles "https://github.com/by-hahn/blog/blob/main/src/assets/css/main.css"
click node_static_output "https://github.com/by-hahn/blog/blob/main/scripts/build.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_markdown,node_frontmatter toneBlue
class node_builder,node_validation,node_content_parser,node_post_renderer,node_toc,node_metadata,node_home_renderer,node_category_renderer,node_sitemap toneAmber
class node_post_template,node_index_template,node_theme,node_styles toneMint
class node_static_output,node_hosting toneRose
class node_authors,node_readers toneIndigo
```

## Components

### Content model

- [Markdown posts](https://github.com/by-hahn/blog/tree/main/posts): `posts`
- [Post metadata](https://github.com/by-hahn/blog/tree/main/posts): `posts`

### Static generation

- [Build orchestrator](https://github.com/by-hahn/blog/blob/main/scripts/build.js): `scripts/build.js`
- [Input validation](https://github.com/by-hahn/blog/blob/main/scripts/build.js): `scripts/build.js`
- [Content parsing](https://github.com/by-hahn/blog/blob/main/scripts/build.js): `scripts/build.js`
- [Post rendering](https://github.com/by-hahn/blog/blob/main/scripts/build.js): `scripts/build.js`
- [TOC generation](https://github.com/by-hahn/blog/blob/main/scripts/build.js): `scripts/build.js`
- [SEO metadata](https://github.com/by-hahn/blog/blob/main/scripts/build.js): `scripts/build.js`
- [Homepage generation](https://github.com/by-hahn/blog/blob/main/scripts/build.js): `scripts/build.js`
- [Category pages](https://github.com/by-hahn/blog/blob/main/scripts/build.js): `scripts/build.js`
- [Sitemap generation](https://github.com/by-hahn/blog/blob/main/scripts/build.js): `scripts/build.js`

### Site experience

- [Post template](https://github.com/by-hahn/blog/blob/main/src/template-post.html): `src/template-post.html`
- [Index template](https://github.com/by-hahn/blog/blob/main/src/template-index.html): `src/template-index.html`
- [Theme preference](https://github.com/by-hahn/blog/blob/main/src/assets/js/theme.js): `src/assets/js/theme.js`
- [Responsive styling](https://github.com/by-hahn/blog/blob/main/src/assets/css/main.css): `src/assets/css/main.css`

### Published site

- [Generated site](https://github.com/by-hahn/blog/blob/main/scripts/build.js): `scripts/build.js`
- **Static hosting**

### Other components

- **Authors**
- **Readers**

## Connections

- Authors → Markdown posts: write (evidence: `README.md`)
- Authors → Post metadata: set metadata (evidence: `README.md`)
- Build orchestrator → Markdown posts: reads posts (evidence: `README.md`)
- Build orchestrator → Post template: loads template (evidence: `README.md`)
- Build orchestrator → Index template: loads template (evidence: `README.md`)
- Build orchestrator → Input validation: validates input (evidence: `scripts/build.js`)
- Build orchestrator → Content parsing: parses posts (evidence: `scripts/build.js`)
- Content parsing → Post rendering: renders Markdown (evidence: `README.md`)
- Post rendering → TOC generation: extracts headings (evidence: `README.md`)
- Build orchestrator → Post rendering: builds pages (evidence: `scripts/build.js`)
- Post rendering → Post template: fills placeholders (evidence: `scripts/build.js`)
- Post rendering → SEO metadata: adds post metadata (evidence: `README.md`)
- Build orchestrator → Homepage generation: builds homepage (evidence: `README.md`)
- Homepage generation → Index template: fills placeholders (evidence: `scripts/build.js`)
- Build orchestrator → Category pages: builds category pages (evidence: `README.md`)
- Build orchestrator → Sitemap generation: generates sitemap (evidence: `README.md`)
- Build orchestrator → Generated site: writes files (evidence: `README.md`)
- Post template → Generated site: renders into (evidence: `README.md`)
- Index template → Generated site: renders into (evidence: `README.md`)
- Theme preference → Readers: sets preference (evidence: `README.md`)
- Generated site → Static hosting: deploys (evidence: `README.md`)
- Static hosting → Readers: serves pages (evidence: `README.md`)
- Generated site → Responsive styling: includes assets (evidence: `README.md`)
- Generated site → Theme preference: includes script (evidence: `README.md`)
