# nguyengiabach1201/blogs architecture

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

- Interactive diagram: https://gitdiagram.com/nguyengiabach1201/blogs
- Repository: https://github.com/nguyengiabach1201/blogs

## Overview

##### Main Components
- Blog Content & Data Source: The “src/content” folder holds Markdown files for blog posts (and a configuration file) that are the foundation of the site’s content.
- Frontend/UI Components: The “src/components” and “src/layouts” directories contain reusable UI components (Header, Footer, Card, etc.) and layout templates (Main, PostDetails, Posts, TagPosts) that build up the pages.
- Pages & Routing: The “src/pages” directory defines the site's routes – including index pages, dynamic pages for individual posts ([slug]), paginated lists, tag-based listings, as well as error pages (404), RSS feed, robots.txt, and search pages.
- Utility Functions: The “src/utils” folder provides helper functions for operations like generating OpenGraph images, filtering and sorting posts, and slug creation. The “src/utils/og-templates” subfolder organizes specific OG image templates.
- Build & Deployment Infrastructure: With the Dockerfile, docker-compose.yml, and GitHub workflow files (.github/workflows), the project is set up for containerized builds and automated deployment processes. Astro’s configuration file (astro.config.ts) defines build settings.

- Utility Data Flow: Highlight how utility functions (src/utils) integrate with the content rendering process (e.g., getPostsByTag, slugify) and occasionally contribute to dynamic operations like generating OG images.
- Assets & Styling Integration: Connect “public/assets” and “src/styles” with the rendering pipeline, indicating that these resources are used to enhance the UI and support the overall site design.
- Infrastructure & Deployment: Illustrate that the codebase is containerized (using Dockerfile and docker-compose) and auto-deployed using GitHub workflows. You could show a CI/CD pipeline element that takes the source code and produces a deployable artifact.

##### Architectural Patterns & Design Principles
- Separation of Concerns: The folders for content, components, layouts, and utilities indicate that this project maintains a clear division between data, presentation logic, and helper functions.
- Static Site Generation: Emphasize that the Astro framework is used to convert Markdown and component templates into static HTML pages for fast, SEO-friendly delivery.
- Modular & Reusable Components: Note the use of small, reusable components (like Header, Footer, Card, etc.) and specialized layouts. This supports maintainability and scalability.
- Containerization & CI/CD: The project includes container-specific configurations (Dockerfile, docker-compose) along with GitHub workflows, which reinforces infrastructure as code and continuous deployment practices.

## Diagram (Mermaid)

```mermaid
graph TD
    A["Blog Content (Markdown)"]:::content
    B["Astro Build Process"]:::build
    C["UI Components"]:::ui
    D["Layout Templates"]:::ui
    E["Pages & Routing"]:::ui
    F["Utility Functions"]:::utils
    G["Assets & Styles"]:::assets
    H["Build & Deployment Infrastructure"]:::deploy
    I["Static HTML Output"]:::output

    A -->|"ContentParsing"| B
    C -->|"PageAssembly"| B
    D -->|"PageAssembly"| B
    E -->|"Routing"| B
    F -->|"HelperOps"| B
    B -->|"GenerateStaticHTML"| I
    G -->|"AssetInjection"| I
    H -->|"DeployArtifacts"| I

    subgraph "Blog Content Details"
        direction TB
        A1["config.ts"]:::detail
        A2["hello-world.md"]:::detail
    end
    A ---|"includes"| A1
    A ---|"includes"| A2

    subgraph "UI Component Files"
        direction TB
        C1["Card.tsx"]:::detail
        C2["Header.astro"]:::detail
        C3["Footer.astro"]:::detail
    end
    C ---|"contains"| C1
    C ---|"contains"| C2
    C ---|"contains"| C3

    subgraph "Layout Template Files"
        direction TB
        D1["Layout.astro"]:::detail
        D2["Main.astro"]:::detail
        D3["PostDetails.astro"]:::detail
        D4["Posts.astro"]:::detail
        D5["TagPosts.astro"]:::detail
    end
    D ---|"includes"| D1
    D ---|"includes"| D2
    D ---|"includes"| D3
    D ---|"includes"| D4
    D ---|"includes"| D5

    subgraph "Page Files"
        direction TB
        E1["posts (directory)"]:::detail
        E2["tags (directory)"]:::detail
        E3["404.astro"]:::detail
        E4["rss.xml.ts"]:::detail
        E5["robots.txt.ts"]:::detail
        E6["search.astro"]:::detail
    end
    E ---|"includes"| E1
    E ---|"includes"| E2
    E ---|"includes"| E3
    E ---|"includes"| E4
    E ---|"includes"| E5
    E ---|"includes"| E6

    subgraph "Utility Function Files"
        direction TB
        F1["generateOgImages.tsx"]:::detail
        F2["getPostsByTag.ts"]:::detail
        F3["slugify.ts"]:::detail
        F4["og-templates/post.tsx"]:::detail
        F5["og-templates/site.tsx"]:::detail
    end
    F ---|"includes"| F1
    F ---|"includes"| F2
    F ---|"includes"| F3
    F ---|"includes"| F4
    F ---|"includes"| F5

    subgraph "Asset Files"
        direction TB
        G1["public (directory)"]:::detail
        G2["base.css"]:::detail
    end
    G ---|"contains"| G1
    G ---|"contains"| G2

    subgraph "Deployment Files"
        direction TB
        H1["Dockerfile"]:::detail
        H2["docker-compose.yml"]:::detail
        H3[".github/workflows/deploy.yml"]:::detail
        H4["astro.config.ts"]:::detail
    end
    H ---|"includes"| H1
    H ---|"includes"| H2
    H ---|"includes"| H3
    H ---|"includes"| H4

    click A "https://github.com/nguyengiabach1201/blogs/tree/main/src/content"
    click A1 "https://github.com/nguyengiabach1201/blogs/blob/main/src/content/config.ts"
    click A2 "https://github.com/nguyengiabach1201/blogs/blob/main/src/content/blog/hello-world.md"

    click C "https://github.com/nguyengiabach1201/blogs/tree/main/src/components"
    click C1 "https://github.com/nguyengiabach1201/blogs/blob/main/src/components/Card.tsx"
    click C2 "https://github.com/nguyengiabach1201/blogs/blob/main/src/components/Header.astro"
    click C3 "https://github.com/nguyengiabach1201/blogs/blob/main/src/components/Footer.astro"

    click D "https://github.com/nguyengiabach1201/blogs/tree/main/src/layouts"
    click D1 "https://github.com/nguyengiabach1201/blogs/blob/main/src/layouts/Layout.astro"
    click D2 "https://github.com/nguyengiabach1201/blogs/blob/main/src/layouts/Main.astro"
    click D3 "https://github.com/nguyengiabach1201/blogs/blob/main/src/layouts/PostDetails.astro"
    click D4 "https://github.com/nguyengiabach1201/blogs/blob/main/src/layouts/Posts.astro"
    click D5 "https://github.com/nguyengiabach1201/blogs/blob/main/src/layouts/TagPosts.astro"

    click E "https://github.com/nguyengiabach1201/blogs/tree/main/src/pages"
    click E1 "https://github.com/nguyengiabach1201/blogs/tree/main/src/pages/posts"
    click E2 "https://github.com/nguyengiabach1201/blogs/tree/main/src/pages/tags"
    click E3 "https://github.com/nguyengiabach1201/blogs/blob/main/src/pages/404.astro"
    click E4 "https://github.com/nguyengiabach1201/blogs/blob/main/src/pages/rss.xml.ts"
    click E5 "https://github.com/nguyengiabach1201/blogs/blob/main/src/pages/robots.txt.ts"
    click E6 "https://github.com/nguyengiabach1201/blogs/blob/main/src/pages/search.astro"

    click F "https://github.com/nguyengiabach1201/blogs/tree/main/src/utils"
    click F1 "https://github.com/nguyengiabach1201/blogs/blob/main/src/utils/generateOgImages.tsx"
    click F2 "https://github.com/nguyengiabach1201/blogs/blob/main/src/utils/getPostsByTag.ts"
    click F3 "https://github.com/nguyengiabach1201/blogs/blob/main/src/utils/slugify.ts"
    click F4 "https://github.com/nguyengiabach1201/blogs/blob/main/src/utils/og-templates/post.tsx"
    click F5 "https://github.com/nguyengiabach1201/blogs/blob/main/src/utils/og-templates/site.tsx"

    click G "https://github.com/nguyengiabach1201/blogs/tree/main/public"
    click G2 "https://github.com/nguyengiabach1201/blogs/blob/main/src/styles/base.css"

    click H "https://github.com/nguyengiabach1201/blogs/tree/main/Dockerfile"
    click H1 "https://github.com/nguyengiabach1201/blogs/tree/main/Dockerfile"
    click H2 "https://github.com/nguyengiabach1201/blogs/blob/main/docker-compose.yml"
    click H3 "https://github.com/nguyengiabach1201/blogs/blob/main/.github/workflows/deploy.yml"
    click H4 "https://github.com/nguyengiabach1201/blogs/blob/main/astro.config.ts"

classDef content fill:#add8e6,stroke:#333,stroke-width:2px;
classDef build fill:#90ee90,stroke:#333,stroke-width:2px;
classDef ui fill:#ffdead,stroke:#333,stroke-width:2px;
classDef utils fill:#ffffe0,stroke:#333,stroke-width:2px;
classDef assets fill:#d8bfd8,stroke:#333,stroke-width:2px;
classDef deploy fill:#f08080,stroke:#333,stroke-width:2px;
classDef output fill:#f5f5dc,stroke:#333,stroke-width:2px;
classDef detail fill:#e0f7fa,stroke:#333,stroke-width:1px;
```
