# thanhlv-com/thanhlv-blog architecture

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

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

## Overview

This project is a personal blog repository where the author shares insights, studies, and technical knowledge. The repository is structured as a monorepo managed by pnpm and contains at least two main packages:
- The “apps” package – which holds the blog’s content, deployment configurations, and tooling. This package includes the source for blog posts (organized under src/blog, src/short-blog, src/study, etc.), public assets (found in src/public), scripts for processing or generating content, and configuration files for both Vuepress and Vitepress.

##### Main Components
- Repository (monorepo) with two primary modules:
○ Blog Application (packages/apps)
§ Content Source: Contains markdown files for blog posts, short blogs, study notes, public pages, and assets.
§ Build & Scripts: Makefile, deployment scripts, Docker Compose configuration, and various Node.js scripts for content management.
○ Theme Library (packages/libs/theme)
§ Core Vue/Vitepress Components: UI components, styles, and theme configuration used by the blog application.
- CI/CD Pipeline:
○ GitHub Actions workflows (files in .github/workflows) that orchestrate tasks such as testing, building, and deploying the site.
- Deployment & Hosting:
○ GitHub Pages for hosting the built site.
○ Docker (docker-compose.yml) for local development and potentially containerized builds.
- Local Development:
○ “make dev” command defined in the Makefile to locally run the development server, likely using Vitepress or Vuepress.

##### Relationships and Interactions
- The content written in markdown (located in packages/apps/src) is processed and rendered using Vuepress/Vitepress, with the custom theme from packages/libs/theme providing the UI look and feel.
- During development, the “make dev” command triggers a local server that renders content dynamically.
- In the CI/CD pipeline, GitHub Actions fetch the latest changes, build the static site (using configurations found in vitepress and vuepress directories), and deploy the output to GitHub Pages.
- The Docker Compose configuration may be integrated to simulate a local production environment.
- Scripts in packages/apps/script help automate tasks such as generating summaries, handling blogs, or managing study content.

##### Important Architectural Patterns and Design Principles
- Modular Monorepo Architecture: Separation of concerns between content (apps) and presentation/theme (libs/theme).
- Static Site Generation: Using Vuepress/Vitepress to convert markdown content into a static, deployable website.
- CI/CD Automation: Automated building, testing, and deployment via GitHub Actions.
- Extensibility: Use of a theme library and clear separation of content, allowing easy updates or modifications to the UI without affecting the content.

##### Relevant Technologies and Frameworks
- Frontend/Static Site Generators: Vuepress and Vitepress.
- Version Control & CI: GitHub with GitHub Actions workflows.
- Containerization (for local simulation): Docker (docker-compose.yml).
- Package Management: pnpm (monorepo management and workspace definitions).

##### Detail and Clarity
- Component names exactly as used in the project (e.g., “packages/apps”, “packages/libs/theme”, “.github/workflows”).
- External integrations (GitHub Pages for deployment, Docker for local testing).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External
    U("User / Browser"):::external

    %% Deployment
    DEP("GitHub Pages (Deployed Site)"):::deploy

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        GA("GitHub Actions (Global)"):::cicd
        GA2("GitHub Actions (Module)"):::cicd
    end

    %% Build Process Layer
    BP("Build Process (Static Site Generation)"):::build

    %% Repository Monorepo
    subgraph "Repository Monorepo"
        %% Blog Application Module
        subgraph "Blog Application (packages/apps)"
            CS("Content Source (Markdown & Public Assets)"):::blog
            %% Build & Scripts group
            subgraph "Build & Scripts"
                MF("Makefile"):::blog
                DC("docker-compose.yml"):::blog
                CScr("Content Scripts"):::blog
                LD("Local Dev (make dev)"):::dev
            end
            VC("Vuepress/Vitepress Config"):::blog
        end

        %% Theme Library Module
        subgraph "Theme Library (packages/libs/theme)"
            CT("Custom Theme (Vue Components & Styles)"):::theme
        end
    end

    %% Local Development Environment
    DE("Docker Environment"):::dev

    %% Connections from Blog Application & Theme Library to Build Process
    CS --> BP
    VC --> BP
    MF --> BP
    DC --> BP
    CScr --> BP
    CT --> BP

    %% Local development branch from Makefile to Docker Environment
    MF --> LD
    LD --> DE

    %% Build Process to CI/CD and Deployment
    BP -->|"triggers"| GA
    BP -->|"triggers"| GA2
    BP --> HCI[CI/CD Consolidated]:::cicd
    HCI --> DEP

    %% CI/CD Pipeline Consolidation
    GA --- HCI
    GA2 --- HCI

    %% Deployment to User Access
    DEP -->|"serves"| U

    %% Click Events
    click CS "https://github.com/thanhlv-com/thanhlv-blog/tree/main/packages/apps/src"
    click MF "https://github.com/thanhlv-com/thanhlv-blog/tree/main/Makefile"
    click DC "https://github.com/thanhlv-com/thanhlv-blog/blob/main/docker-compose.yml"
    click CScr "https://github.com/thanhlv-com/thanhlv-blog/tree/main/packages/apps/script"
    click VC "https://github.com/thanhlv-com/thanhlv-blog/blob/main/packages/apps/.vitepress"
    click CT "https://github.com/thanhlv-com/thanhlv-blog/tree/main/packages/libs/theme"
    click GA "https://github.com/thanhlv-com/thanhlv-blog/tree/main/.github/workflows"
    click GA2 "https://github.com/thanhlv-com/thanhlv-blog/tree/main/packages/apps/.github/workflows"

    %% Styles
    classDef blog fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef theme fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef cicd fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef deploy fill:#F5B7B1,stroke:#943126,stroke-width:2px;
    classDef dev fill:#D5F5E3,stroke:#1E8449,stroke-width:2px;
    classDef external fill:#FDEBD0,stroke:#D35400,stroke-width:2px;
    classDef build fill:#D6EAF8,stroke:#1F618D,stroke-width:2px;
```
