# ubagyan/blogger-ai-automation architecture

> Architecture diagram of the GitHub repository ubagyan/blogger-ai-automation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ubagyan/blogger-ai-automation
- Repository: https://github.com/ubagyan/blogger-ai-automation

## Overview

##### Project Type and Purpose
- This is an automation‐workflow tool written in Google Apps Script. It lives inside a Google Sheet and orchestrates AI-driven blog content creation, image enrichment, auto-publishing to Blogger, and feedback synchronization.

##### File Structure
- Top level only has three entries: LICENSE, README.md, blogAutomation.gs.
- `blogAutomation.gs` is the single script file that contains all business logic, API calls, and menu triggers.

##### README for Insights
- The script connects to four major services:
- Gemini API for text generation
- Pexels API for image retrieval
- Blogger API v3 for publishing and comment retrieval
- Google Sheets for configuration, data storage, and UI menus
- It handles two workflows:
a) Draft generation → publishing → metadata sync
b) Comment and post metadata synchronization

##### Detail Without Over-Segmentation
- Break the orchestrator rectangle into subcomponents or annotate it with function names:
- generateBlogDraft()
- fetchPexelsImage()
- publishToBlogger()
- syncPostsAndComments()
- Which sheet tabs are read/written at each stage (“Sheet1”, “Posts”, “Comments”).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Actors and UI
    User(["User<br/>(Blogger)"]):::user
    GoogleSheets["Google Sheets<br/>UI & Data"]:::sheet
    click GoogleSheets "https://github.com/ubagyan/blogger-ai-automation/blob/main/blogAutomation.gs"

    %% Orchestrator Functions as Pipeline Stages
    subgraph "Draft Generation"
        direction TB
        ORCH1["generateBlogDraft()"]:::orchestrator
        ORCH2["fetchPexelsImage()"]:::orchestrator
        ORCH3["generateImageAltText()"]:::orchestrator
    end
    click ORCH1 "https://github.com/ubagyan/blogger-ai-automation/blob/main/blogAutomation.gs"
    click ORCH2 "https://github.com/ubagyan/blogger-ai-automation/blob/main/blogAutomation.gs"
    click ORCH3 "https://github.com/ubagyan/blogger-ai-automation/blob/main/blogAutomation.gs"

    subgraph "Publishing"
        direction TB
        ORCH4["publishToBlogger()"]:::orchestrator
    end
    click ORCH4 "https://github.com/ubagyan/blogger-ai-automation/blob/main/blogAutomation.gs"

    subgraph "Synchronization"
        direction TB
        ORCH5["syncPostsAndComments()"]:::orchestrator
    end
    click ORCH5 "https://github.com/ubagyan/blogger-ai-automation/blob/main/blogAutomation.gs"

    %% External Services
    Gemini["Gemini AI Service"]:::external
    Pexels["Pexels Image Service"]:::external
    Blogger["Blogger Publishing Service"]:::external

    %% Documentation
    README["README.md"]:::doc
    click README "https://github.com/ubagyan/blogger-ai-automation/blob/main/README.md"
    License["LICENSE"]:::doc
    click License "https://github.com/ubagyan/blogger-ai-automation/tree/main/LICENSE"

    %% Data Flows
    User -->|"click menu"| GoogleSheets
    GoogleSheets -->|"trigger script"| ORCH1

    ORCH1 -->|"generateContent()"| Gemini
    Gemini -->|"returns draft"| ORCH1

    ORCH2 -->|"fetchImage()"| Pexels
    Pexels -->|"returns image URL"| ORCH2

    ORCH3 -->|"generateAltText()"| Gemini
    Gemini -->|"returns alt text"| ORCH3

    ORCH4 -->|"publishPost()"| Blogger
    Blogger -->|"postID & URL"| ORCH4
    ORCH4 -->|"write metadata"| GoogleSheets

    ORCH5 -->|"syncPostsAndComments()"| Blogger
    Blogger -->|"posts & comments"| ORCH5
    ORCH5 -->|"update sheets"| GoogleSheets

    %% Styles
    classDef sheet fill:#cce5ff,stroke:#333,stroke-width:1px;
    classDef orchestrator fill:#ccffcc,stroke:#333,stroke-width:1px;
    classDef external fill:#ffcc99,stroke:#333,stroke-width:1px;
    classDef user fill:#e0e0e0,stroke:#333,stroke-width:1px;
    classDef doc fill:#f2f2f2,stroke:#333,stroke-width:1px;
```
