# go-555/github-actions-note architecture

> Architecture diagram of the GitHub repository go-555/github-actions-note, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/go-555/github-actions-note
- Repository: https://github.com/go-555/github-actions-note

## Overview

##### Project Type and Purpose
- This is a CI/CD pipeline repository that implements a “Note Workflow” on GitHub Actions. Its goal is to automate researching, drafting, fact-checking, and posting blog posts to note.com using various AI and browser-automation services.

##### File Structure Analysis
- `.github/workflows/note.yaml` defines the main workflow with four sequential jobs: Research, Write, Fact-check, Post.
- `login-note.mjs` is a standalone Playwright script to obtain and persist note.com login cookies (storageState) as JSON. The resulting file’s contents are stored in the `NOTE_STORAGE_STATE_JSON` secret.
- `package.json` + `package-lock.json` define dependencies: Playwright, Claude Code SDK, Anthropic SDK, Tavily API, and `marked`.
- `.env.sample` hints at environment variable usage but secrets live in GitHub repo settings.
- There are no “frontend” or “backend” directories; this is purely an automation/tool pipeline.

##### Key Components
a. GitHub Actions Runner
- Hosts the workflow defined in `.github/workflows/note.yaml`.
- Trigger: Manual dispatch with inputs (`theme`, `target`, etc.).
b. Workflow Jobs (in order)
1. Research Agent
- Uses Claude Code SDK → WebSearch & WebFetch.
2. Writing Agent
- Uses Anthropic Claude Sonnet for title/body/tags.
3. Fact-check Agent
- Uses Tavily API to verify facts and adjust content.
4. Post Agent
- Uses Playwright (+ `marked`) to load note.com, set storageState (from `NOTE_STORAGE_STATE_JSON`), and draft/publish.
c. External Services
- Claude Code SDK endpoints for web research.
- Anthropic Claude API for text generation.
- Tavily API for fact verification.
- .com website (via Playwright).
d. Secrets & Storage
- `ANTHROPIC_API_KEY`, `TAVILY_API_KEY`, `NOTE_STORAGE_STATE_JSON`.
- `login-note.mjs` generates `note-state.json` locally (excluded from git), whose contents become `NOTE_STORAGE_STATE_JSON`.

##### Relationships & Data Flow
- Manual trigger on GitHub → Runner spins up → workflow inputs propagate to each job.
- Each job consumes the output of the previous (implicitly via job ordering and shared workspace or via parameters).
- The final job reads `NOTE_STORAGE_STATE_JSON` (unpacked to a temp file) to log into note.com and post.

##### Architectural Patterns / Principles
- Pipeline/Orchestration pattern: clearly staged sequential jobs.
- Separation of concerns: each job has a single responsibility.
- Secret management: sensitive tokens and storage state kept in GitHub Secrets.
- Extensibility: Adding a new agent is as simple as adding another job.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Trigger Layer
    subgraph "Trigger & Inputs"
        User["User (Manual Dispatch)"]:::trigger
        Inputs["Workflow Inputs"]:::trigger
    end

    %% Local Setup Layer
    subgraph "Local Setup"
        Login["Note.com Login Script\n(login-note.mjs)"]:::browser
        Secret["NOTE_STORAGE_STATE_JSON\n(GitHub Secret)"]:::secret
        Login -->|generates storageState| Secret
    end

    %% GitHub Actions Runner
    subgraph "GitHub Actions Runner"
        WF["Workflow Definition\n(.github/workflows/note.yaml)"]:::gha
        AltWF["Alternative Workflow\n(.github/workflows/note-perplexity.yaml)"]:::gha
        Research["Research Agent\n(Claude Code SDK)"]:::ai_claude
        Write["Writing Agent\n(Anthropic Claude Sonnet)"]:::ai_anthropic
        Fact["Fact-check Agent\n(Tavily API)"]:::ai_tavily
        Post["Post Agent\n(Playwright + marked)"]:::browser
        User --> WF
        WF --> Research --> Write --> Fact --> Post
        Secret --> Post
    end

    %% External Services
    subgraph "External Services"
        ClaudeCode["Claude Code SDK"]:::ai_claude
        Anthropic["Anthropic Claude API"]:::ai_anthropic
        Tavily["Tavily API"]:::ai_tavily
        NoteCom["note.com"]:::browser
    end

    %% Connections to APIs
    Research -->|"uses WebSearch/WebFetch"| ClaudeCode
    Write -->|"generates text"| Anthropic
    Fact -->|"verifies facts"| Tavily
    Post -->|"automates posting"| NoteCom
    Post -->|"converts MD→HTML"| Marked["marked"]:::browser

    %% Repository Files
    subgraph "Repository Files"
        Package["package.json"]:::repo
        Env[".env.sample"]:::repo
        Readme["README.md"]:::repo
    end

    %% File usage arrows
    Package --> Research
    Package --> Write
    Package --> Fact
    Package --> Post
    Env --> WF
    Readme --> User

    %% Click Events
    click WF "https://github.com/go-555/github-actions-note/blob/main/.github/workflows/note.yaml"
    click AltWF "https://github.com/go-555/github-actions-note/blob/main/.github/workflows/note-perplexity.yaml"
    click Research "https://github.com/go-555/github-actions-note/blob/main/.github/workflows/note.yaml"
    click Write "https://github.com/go-555/github-actions-note/blob/main/.github/workflows/note.yaml"
    click Fact "https://github.com/go-555/github-actions-note/blob/main/.github/workflows/note.yaml"
    click Post "https://github.com/go-555/github-actions-note/blob/main/.github/workflows/note.yaml"
    click Login "https://github.com/go-555/github-actions-note/blob/main/login-note.mjs"
    click Package "https://github.com/go-555/github-actions-note/blob/main/package.json"
    click Env "https://github.com/go-555/github-actions-note/blob/main/.env.sample"
    click Readme "https://github.com/go-555/github-actions-note/blob/main/README.md"

    %% Styles
    classDef trigger fill:#FFF2CC,stroke:#333,stroke-width:1px
    classDef gha fill:#EDEDED,stroke:#333,stroke-width:1px
    classDef ai_claude fill:#FFD966,stroke:#333,stroke-width:1px
    classDef ai_anthropic fill:#9FC5E8,stroke:#333,stroke-width:1px
    classDef ai_tavily fill:#F4CCCC,stroke:#333,stroke-width:1px
    classDef browser fill:#D9EAD3,stroke:#333,stroke-width:1px
    classDef secret fill:#D5A6BD,stroke:#333,stroke-width:1px
    classDef repo fill:#EAEAEA,stroke:#333,stroke-width:1px
```
