# linychuo/my-blog architecture

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

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

## Overview

##### Main Components
- Command-Line Entry Point (main.rs): This module serves as the application’s starting point; it gathers parameters (paths to posts, static files, templates, etc.) and kicks off the build process.
- Core Blog Building Logic (blogger.rs): This module encapsulates the blog generator’s main behavior. It handles rendering of individual posts, generating the index page, and copying over static assets.
- Article Handling (post.rs): This component represents individual articles. It manages parsing markdown content and converting it to an internal representation before rendering.
- Content Directories:
- Posts: Contains original markdown files for each blog post.
- Templates: Contains Handlebars (*.hbs) templates for various parts of the blog (layout, navigation, footer, post page, etc.).
- Static: Contains static resources like CSS, images, and maybe JavaScript.

##### Relationships and Data Flow
- The entry point (main.rs) reads command-line arguments to determine the directories for posts, static files, and templates, as well as the build output directory.
- It then invokes the blogger module which:
- Iterates over the markdown posts in the “posts” directory.
- Uses post.rs to parse each Markdown file into an article object.
- Passes these articles along with template files from “templates” to the Handlebars engine for HTML rendering.
- Manages the copying of static resources from the “static” folder to the build output.
- The output is a complete static website, stored in the build directory, with HTML files and linked assets.

##### Architectural Patterns and Principles
- Separation of Concerns: The project is clearly divided into content data (posts), presentation (templates and static assets), and business logic (Rust modules in “src”).
- Pipeline Architecture: There is a clear sequence—input parsing, content transformation (markdown to HTML via templates), and asset management.
- Modular Design: Splitting functionality among different modules (main.rs, blogger.rs, post.rs) ensures each part of the blog generation process is logically isolated.

##### Technologies and Libraries
- Rust: The core programming language used.
- Handlebars for Rust: The template engine used for rendering HTML from templates.
- Markdown Processing: Although not explicitly mentioned in the file names, an internal mechanism (or a library) is assumed to parse markdown files.
- Command-Line Argument Parsing: Used in main.rs to obtain input paths and configuration constants.

##### Instructing the Principal Software Engineer to Include the Following
- Input flow from the posts, static, and templates directories into the processing engine.
- Data flow from main.rs to blogger.rs and from blogger.rs to post.rs.
- Output flow from the processing engine into the build directory.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Nodes for Modules
    CLI["Command-Line Interface (main.rs)"] 
    BLOG["Blog Building Engine (blogger.rs)"]
    ARTICLE["Article Processor (post.rs)"]

    %% Nodes for Data Sources
    POSTS["Posts (Markdown Files)"]
    TEMPLATES["Templates (Handlebars Files)"]
    STATIC["Static Assets"]
    OUTPUT["Build Output (Static Site)"]

    %% Data Flow from CLI and Data Sources to BLOG
    CLI -->|"invokes_build_process"| BLOG
    POSTS -->|"provides_markdown"| BLOG
    TEMPLATES -->|"provides_templates"| BLOG
    STATIC -->|"provides_assets"| BLOG

    %% Internal processing in BLOG
    BLOG -->|"parses_posts"| ARTICLE
    ARTICLE -->|"returns_articles"| BLOG

    %% BLOG outputs the final static site
    BLOG -->|"HTML_Rendering_with_Handlebars"| OUTPUT

    %% Click Events for Modules and Data Directories
    click CLI "https://github.com/linychuo/my-blog/blob/rust-build/src/main.rs"
    click BLOG "https://github.com/linychuo/my-blog/blob/rust-build/src/blogger.rs"
    click ARTICLE "https://github.com/linychuo/my-blog/blob/rust-build/src/post.rs"
    click POSTS "https://github.com/linychuo/my-blog/tree/rust-build/posts/"
    click TEMPLATES "https://github.com/linychuo/my-blog/tree/rust-build/templates/"
    click STATIC "https://github.com/linychuo/my-blog/tree/rust-build/static/"

    %% Styles
    classDef moduleClass fill:#AED6F1,stroke:#000,stroke-width:2px;
    classDef dataClass fill:#ABEBC6,stroke:#000,stroke-width:2px;
    
    class CLI,BLOG,ARTICLE moduleClass;
    class POSTS,TEMPLATES,STATIC,OUTPUT dataClass;
```
