⏱️ 5 min read

GHP Static Site Generator - Architecture & Design

comprehensive architecture documentation for the GHP Static Site Generator (v1.x.x). It includes high-level concepts, data flow, internal components, and diagrams using Mermaid syntax (standard for GitHub Markdown).

Architecture Overview

System Overview

The GHP Static Site Generator is a high-performance console application designed to convert a recursive directory structure of content files into a fully navigational static HTML website. It supports Markdown (.md) for content authoring and raw HTML fragments (.htm) for custom layouts, wrapping them into a customizable Inja template.

Key Features

High-Level Architecture

The system operates on a linear Pipeline Pattern. It takes three primary inputs (Configuration, Content, Template) and produces a directory of static HTML files.

Pipeline

Core Workflow

The main() function orchestrates the lifecycle of the generation process.

Execution Flow Diagram

Execution Flow

Component Design

The application is structured around data-driven components.

Data Structures

DirNode (The File Tree)

Represents the recursive file system structure in memory.

struct DirNode {
  fs::path relativePath;        // Path relative to input root
  std::string dirName;          // Name of the current folder
  std::vector<fs::path> files;  // .md and .htm files in this folder
  std::vector<DirNode> subdirs; // Nested directories
};

Config

Holds runtime settings loaded from the .cfg file.

struct Config {
  fs::path templatePath; // Path to template.html
  fs::path outputDir;    // Destination folder
  fs::path assetsPath;   // Source assets folder (images/css)
};

Key Logic Units

Tree Builder (buildTree)

Role: Scans the input directory.

Filters:

Sorting: Sorts directories and files alphabetically for consistent navigation order.

Role: Creates the HTML