# mingi3314/blog-factory architecture

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

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

## Overview

##### Major Components
- Frontend – The Gatsby-based static site:
◦ Files like gatsby-config.js, gatsby-node.js, gatsby-ssr.js, and the “src” folder (with components, layouts, pages, templates, and styles) indicate that the site uses Gatsby (a React-based framework) for rendering blog content.
◦ Organize components into UI elements such as Navigation (navBar), Post grid, SEO integration (seo.tsx), and layout components.
- Content & Image Generation Engine – Automated Scripts:
◦ The “scripts” directory (with generate_content.py, initialize_images.py, configuration files, and prompt modules) handles AI-driven content creation and image initialization.
◦ These scripts interact with external AI APIs (e.g., Mistral API, LangChain API) as described in the README.
- CI/CD & Orchestration – GitHub Actions Workflows:
◦ The .github/workflows directory contains workflows for “Auto Upload Contents” and “Initialize Images”. They automate triggering of content generation and image tasks, commit changes, and deploy the updates.
◦ GitHub Actions is central in triggering periodic (or manual) automation based on repository events.
- External Services & Integrations:
◦ Netlify – For deployment, ensuring that on every commit the updated site is built and served, achieving high Domain Rank and proper CDN integration.
◦ Google Search Console – For site indexing and SEO monitoring (implied by the deployment instructions).
◦ Third-Party APIs – Mistral and (optional) LangChain for content generation and debugging traced via Langsmith.

##### Establish Relationships and Data Flow
- The frontend (Gatsby site) serves as the presentation layer, interacting with static assets (from the “static” folder), dynamic blog posts (in “src/posts/blog”), and site configuration defined in gatsby-meta-config.js.
- The automated scripts (located under “scripts”) run either manually or on a schedule (via GitHub Actions) to generate new blog content and images. These scripts produce new files that are committed back to the repository.
- GitHub Actions (with workflows like auto-upload and image initialization) act as the orchestrator, triggering the scripts, managing deployments, and controlling environment variables (MISTRAL_API_KEY, LANGCHAIN_API_KEY, etc.).
- On each commit, Netlify picks up changes, builds the static site, and deploys the updated blog.
- External APIs are called from the script layer to fetch/generate content and images, with a potential feedback loop (e.g., using API responses to fine-tune SEO meta data).

##### Architectural Patterns and Key Technologies
- Separation of Concerns:
◦ The project cleanly divides content generation, site rendering, and deployment tasks.
- Static Site Generation (SSG) with Gatsby:
◦ Enables fast, SEO-friendly page loads along with rich component-based UI.
- Automation via GitHub Actions:
◦ Continuous integration and scheduled tasks reduce manual intervention.
- Integration with External APIs:
◦ Leverages AI technologies for content creation, showing a microservice-like interaction with third-party services.
- Configurability:
◦ The extensive use of configuration files (e.g., gatsby-meta-config.js, environment variables) permits easy customization.

## Diagram (Mermaid)

```mermaid
graph TD

    %% Subgraph for CI/CD & Automation
    subgraph "CI/CD & Automation"
        GA["GitHub Actions Workflows"]:::actions
        CG["Content Generation Scripts"]:::scripts
    end

    %% External API Services & Configurations
    EX["External API Services & Configurations"]:::external

    %% Deployment Pipeline
    DEP["Deployment Pipeline (Netlify)"]:::deployment

    %% Frontend Layer
    subgraph "Frontend Layer"
        SA["Static Assets & Posts"]:::frontend
        GF["Gatsby Frontend"]:::frontend
    end

    %% Connections for Automation and Content Generation
    GA -->|"trigger_scripts"| CG
    CG -->|"API_calls"| EX
    CG -->|"commit_posts"| SA

    %% CI/CD triggering Deployment
    GA -->|"trigger_build"| DEP
    DEP -->|"deploy_update"| GF

    %% Frontend serving content
    SA -->|"serve_content"| GF

    %% Styles
    classDef frontend fill:#90ee90,stroke:#006400,color:#000,stroke-width:2px;
    classDef scripts fill:#add8e6,stroke:#00008b,color:#000,stroke-width:2px;
    classDef actions fill:#FFD700,stroke:#DAA520,color:#000,stroke-width:2px;
    classDef deployment fill:#FFA07A,stroke:#CD5C5C,color:#000,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#696969,color:#000,stroke-width:2px;

    %% Click Events
    click GF "https://github.com/mingi3314/blog-factory/blob/main/gatsby-config.js"
    click GF "https://github.com/mingi3314/blog-factory/blob/main/gatsby-meta-config.js"
    click GF "https://github.com/mingi3314/blog-factory/blob/main/gatsby-node.js"
    click GF "https://github.com/mingi3314/blog-factory/blob/main/gatsby-ssr.js"
    click GF "https://github.com/mingi3314/blog-factory/tree/main/src/"
    click CG "https://github.com/mingi3314/blog-factory/tree/main/scripts/"
    click GA "https://github.com/mingi3314/blog-factory/tree/main/.github/workflows/"
    click SA "https://github.com/mingi3314/blog-factory/tree/main/static/"
    click SA "https://github.com/mingi3314/blog-factory/tree/main/src/posts/blog"
    click EX "https://github.com/mingi3314/blog-factory/blob/main/gatsby-meta-config.js"
    click EX "https://github.com/mingi3314/blog-factory/blob/main/package.json"
```
