# bchiang7/v4 architecture

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

- Interactive diagram: https://gitdiagram.com/bchiang7/v4
- Repository: https://github.com/bchiang7/v4

## Overview

##### Project Type and Purpose
- This is a static personal website built with Gatsby (a React-based static site generator) and hosted on Netlify. It pulls markdown content from the `content/` folder, uses GraphQL at build time to generate HTML/CSS/JS assets, then deploys the result to a CDN.

##### File Structure Highlights (Architectural Clues)
- **Root config files**: `gatsby-config.js`, `gatsby-node.js`, `.babelrc`, ESLint, Prettier, Husky hooks.
- **content/**: Markdown files organized by type (featured, jobs, posts, projects).
- **src/**:
- `pages/` and `templates/` define page entry points and page-template components.
- `components/`: reusable React UI pieces.
- `hooks/`, `utils/`: client-side utility code.
- `styles/`: theme, global styles, Prism for code highlighting.
- `images/`, `static/`: static assets (favicons, PDFs, slides).
- **package.json** & **Netlify**: defines build scripts (`gatsby build`, `gatsby serve`) and deployment via Netlify CI.

##### Key Architectural Patterns
- **Static Site Generation (SSG)**:
- GraphQL schema created at build-time to query markdown and image data.
- Gatsby pipelines (`gatsby-node.js`) programmatically create pages from markdown.
- **Component-Based UI**:
- React components for layout, navigation, sections.
- CSS-in-JS (GlobalStyle, theme variables) for styling.
- **Content-Driven Structure**: All user-visible content lives in `content/`; code simply transforms and renders it.

##### Main Components and Their Interactions
a. **Developer Machine**
– Writes code and markdown.
– Runs `gatsby develop` or pushes to GitHub (with Husky pre-commit hooks).
b. **Version Control / CI**
– GitHub hosts the repo.
– Netlify watches the main branch, triggers builds on push.
c. **Gatsby Build Process**
– Reads `gatsby-config.js` plugins and site metadata.
– Imports all markdown from `content/` via `gatsby-source-filesystem`.
– Transforms markdown to HTML using `gatsby-transformer-remark`.
– Exposes data through GraphQL.
– Executes `createPages` in `gatsby-node.js` using templates (`src/templates/*.js`).
– Bundles React components and CSS into static JS/CSS files.
d. **Hosting / CDN**
– Netlify deploys the `/public` folder's static assets to a CDN.
e. **End Users (Browsers)**
– Request HTML/CSS/JS assets via CDN.
– Hydrate into a React SPA (for any client-side interactivity).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global entities
    Developer["Developer Machine"]:::blue
    GitHub["GitHub Repo"]:::blue
    Netlify["Netlify CI/CD"]:::blue

    subgraph "Gatsby Build Process"
        direction TB
        Config["Root Config & Build Scripts"]:::green
        Content["Content Source\n(content/)"]:::green
        Transformer["Remark Transformer\n(gatsby-transformer-remark)"]:::green
        GraphQL["GraphQL Data Layer"]:::green
        Templates["Page Templates"]:::green
        UIComponents["UI Components"]:::green
        Bundle["Static Asset Generation\n(HTML/CSS/JS)"]:::green
    end

    CDN["CDN Hosting"]:::blue
    Browser["End User Browser"]:::orange

    %% Connections
    Developer -->|"push code & markdown"| GitHub
    GitHub -->|"webhook trigger"| Netlify
    Netlify -->|"build start"| Config
    Config --> Content
    Content --> Transformer
    Transformer --> GraphQL
    GraphQL --> Templates
    GraphQL --> UIComponents
    Templates --> Bundle
    UIComponents --> Bundle
    Bundle -->|"deploy static assets"| CDN
    CDN -->|"serve assets"| Browser

    %% Click Events
    click Config "https://github.com/bchiang7/v4/blob/main/gatsby-config.js"
    click Config "https://github.com/bchiang7/v4/blob/main/gatsby-node.js"
    click Config "https://github.com/bchiang7/v4/blob/main/gatsby-browser.js"
    click Config "https://github.com/bchiang7/v4/blob/main/gatsby-ssr.js"
    click Config "https://github.com/bchiang7/v4/blob/main/.babelrc"
    click Config "https://github.com/bchiang7/v4/blob/main/.eslintrc"
    click Config "https://github.com/bchiang7/v4/blob/main/prettier.config.js"
    click Config "https://github.com/bchiang7/v4/blob/main/package.json"
    click Config "https://github.com/bchiang7/v4/tree/main/.husky/pre-commit"
    click Content "https://github.com/bchiang7/v4/tree/main/content/"
    click Templates "https://github.com/bchiang7/v4/blob/main/src/templates/post.js"
    click Templates "https://github.com/bchiang7/v4/blob/main/src/templates/tag.js"
    click UIComponents "https://github.com/bchiang7/v4/blob/main/src/components/layout.js"
    click UIComponents "https://github.com/bchiang7/v4/blob/main/src/components/nav.js"
    click UIComponents "https://github.com/bchiang7/v4/blob/main/src/components/footer.js"
    click UIComponents "https://github.com/bchiang7/v4/blob/main/src/components/sections/featured.js"
    click UIComponents "https://github.com/bchiang7/v4/blob/main/src/components/sections/jobs.js"

    %% Styles
    classDef blue fill:#cce5ff,stroke:#4da3ff,color:#003366;
    classDef green fill:#d4edda,stroke:#28a745,color:#155724;
    classDef orange fill:#fff3cd,stroke:#ffc107,color:#856404;
```
