# shihab-miah/facebook-automatic-ai-news-scrapper---publisher architecture

> Architecture diagram of the GitHub repository shihab-miah/facebook-automatic-ai-news-scrapper---publisher, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shihab-miah/facebook-automatic-ai-news-scrapper---publisher
- Repository: https://github.com/shihab-miah/facebook-automatic-ai-news-scrapper---publisher

## Overview

1. **What this repo is**
   - The repository is structured as a **single automation pipeline** plus supporting documentation/assets.
   - The intended behavior, per the README, is: **scrape news → rewrite headline with AI → publish to a Facebook Page**.

2. **Core executable boundary**
   - The only source file in the tree is **`src/main.gs`**, so the runtime appears to center on **one main script entrypoint** rather than a multi-service application.
   - There is no visible package manifest, service directory, or separate backend/frontend split in the tree.

3. **Primary data flow**
   - The pipeline is linear:
     - collect content from news sources,
     - transform it with an AI model,
     - send the generated post to Facebook.
   - The main architectural value is in this **content-processing chain**, not in user interaction or persistent storage.

4. **Content ingestion subsystem**
   - The README describes **multi-source scraping** from configurable news sites.
   - This is the first external boundary: the repo consumes public web content and extracts article links/headlines before any AI or publishing step.

5. **AI rewriting subsystem**
   - The second boundary is the **headline generation/rewrite step** using **GPT-2 via Hugging Face Transformers** as described in the README.
   - Architecturally, this acts as a transformation layer between raw scraped content and the publishable Facebook post text.

6. **Publishing subsystem**
   - The output boundary is the **Facebook Graph API**, which posts to a **Facebook Page** rather than a personal profile.
   - The repository treats publishing as an automated API integration, not a manual review workflow.

7. **Execution and scheduling**
   - The README places the bot under **GitHub Actions**, which means the repo is designed to run **on a schedule and/or manual workflow dispatch** in GitHub’s CI environment.
   - That makes GitHub Actions the orchestrator, while the script itself is the worker logic.

8. **Secrets and configuration boundary**
   - The repo depends on four runtime secrets:
     - `FB_EMAIL`
     - `FB_PASSWORD`
     - `PAGE_ID`
     - `ACCESS_TOKEN`
   - These are kept in **GitHub Secrets**, so credentials are injected at runtime rather than stored in source.

9. **Supporting documentation and assets**
   - `docs/setup_guide.md` likely contains operational setup instructions.
   - `assets/screenshots` is documentation support only; it does not appear to participate in runtime behavior.
   - These files are part of the onboarding/usage layer, not the core automation path.

10. **Important architecture note**
   - There is a **clear mismatch** between the README and the file tree: the README describes a **Python/Playwright/Transformers** project, but the repo tree shows a **`.gs` script**, which strongly suggests **Google Apps Script** or at least a non-Python implementation.
   - For an architecture diagram, treat the README as the **stated target architecture** and `src/main.gs` as the **single implementation entrypoint**, but note that the documentation and code structure are not fully aligned.

Main entry points: [`src/main.gs`](https://github.com/shihab-miah/facebook-automatic-ai-news-scrapper---publisher/blob/main/src/main.gs) (Main script), [`README.md`](https://github.com/shihab-miah/facebook-automatic-ai-news-scrapper---publisher/blob/main/README.md) (README), [`docs/setup_guide.md`](https://github.com/shihab-miah/facebook-automatic-ai-news-scrapper---publisher/blob/main/docs/setup_guide.md) (Setup guide), [`assets/screenshots`](https://github.com/shihab-miah/facebook-automatic-ai-news-scrapper---publisher/tree/main/assets/screenshots) (Screenshots)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Automation runtime"]
  node_github_actions["GitHub Actions<br/>orchestrator"]
  node_main_script["Main script<br/>entrypoint<br/>[main.gs]"]
  node_scrape_sources[("News sources<br/>ingest")]
  node_extract_news["Scrape news<br/>collector"]
  node_normalize_content["Clean text<br/>transform"]
  node_gpt2_model(("GPT-2<br/>ai-model"))
  node_hf_transformers["Transformers<br/>ml-runtime"]
  node_rewrite_headline["Rewrite headline<br/>transform"]
  node_compose_post["Compose post<br/>formatter"]
  node_facebook_api[("Facebook Graph<br/>publish-api")]
  node_page_target["Facebook Page<br/>destination"]
  node_github_secrets{{"Secrets<br/>config"}}
end

subgraph group_support["Support files"]
  node_readme["README<br/>docs<br/>[README.md]"]
  node_setup_guide["Setup guide<br/>docs<br/>[setup_guide.md]"]
  node_screenshots["Screenshots<br/>assets"]
end

node_readme -->|"describes"| node_github_actions
node_readme -->|"points to"| node_main_script
node_readme -->|"references"| node_setup_guide
node_setup_guide -->|"configures"| node_github_secrets
node_github_actions -->|"runs"| node_main_script
node_main_script -->|"reads from"| node_scrape_sources
node_scrape_sources -->|"feeds"| node_extract_news
node_extract_news -->|"cleans"| node_normalize_content
node_normalize_content -->|"uses"| node_hf_transformers
node_hf_transformers -->|"hosts"| node_gpt2_model
node_gpt2_model -->|"generates"| node_rewrite_headline
node_rewrite_headline -->|"formats"| node_compose_post
node_compose_post -->|"publishes to"| node_facebook_api
node_facebook_api -->|"posts on"| node_page_target
node_github_secrets -->|"injects"| node_main_script
node_screenshots -->|"illustrates"| node_setup_guide

click node_readme "https://github.com/shihab-miah/facebook-automatic-ai-news-scrapper---publisher/blob/main/README.md"
click node_main_script "https://github.com/shihab-miah/facebook-automatic-ai-news-scrapper---publisher/blob/main/src/main.gs"
click node_setup_guide "https://github.com/shihab-miah/facebook-automatic-ai-news-scrapper---publisher/blob/main/docs/setup_guide.md"
click node_screenshots "https://github.com/shihab-miah/facebook-automatic-ai-news-scrapper---publisher/tree/main/assets/screenshots"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_github_actions,node_main_script,node_scrape_sources,node_extract_news,node_normalize_content,node_gpt2_model,node_hf_transformers,node_rewrite_headline,node_compose_post,node_facebook_api,node_page_target,node_github_secrets toneBlue
class node_readme,node_setup_guide,node_screenshots toneAmber
```

## Components

### Automation runtime

Scheduled execution and the main script that runs the news-to-Facebook pipeline.

- **GitHub Actions**: orchestrator · CI scheduler and manual runner that triggers the automation workflow.
- [Main script](https://github.com/shihab-miah/facebook-automatic-ai-news-scrapper---publisher/blob/main/src/main.gs): entrypoint · Single implementation entrypoint for the automation logic. · `src/main.gs`
- **News sources**: ingest · Configured external sites that provide articles and headlines.
- **Scrape news**: collector · Collects links and headline data from public news pages.
- **Clean text**: transform · Prepares scraped content for downstream rewriting.
- **GPT-2**: ai-model · Language model used for headline rewriting.
- **Transformers**: ml-runtime · Hugging Face runtime described in the README for model inference.
- **Rewrite headline**: transform · Generates a publishable Facebook-style headline from scraped news content.
- **Compose post**: formatter · Builds the final post text sent to Facebook.
- **Facebook Graph**: publish-api · Graph API boundary used to publish to a Facebook Page.
- **Facebook Page**: destination · The page receiving automated posts.
- **Secrets**: config · Runtime credentials injected through GitHub Secrets: FB_EMAIL, FB_PASSWORD, PAGE_ID, ACCESS_TOKEN.

### Support files

Documentation and assets that explain or illustrate the workflow.

- [README](https://github.com/shihab-miah/facebook-automatic-ai-news-scrapper---publisher/blob/main/README.md): docs · Stated project behavior and setup summary; describes the intended automation pipeline. · `README.md`
- [Setup guide](https://github.com/shihab-miah/facebook-automatic-ai-news-scrapper---publisher/blob/main/docs/setup_guide.md): docs · Operational setup instructions for running the automation. · `docs/setup_guide.md`
- [Screenshots](https://github.com/shihab-miah/facebook-automatic-ai-news-scrapper---publisher/tree/main/assets/screenshots): assets · Illustrative images supporting the documentation. · `assets/screenshots`

## Connections

- README → GitHub Actions: describes · The README documents scheduled GitHub Actions execution.
- README → Main script: points to · The README explains the single-script workflow.
- README → Setup guide: references · Operational setup is documented separately.
- Setup guide → Secrets: configures · Setup requires injecting runtime credentials.
- GitHub Actions → Main script: runs · GitHub Actions invokes the main automation script.
- Main script → News sources: reads from · The script starts by pulling content from news sources.
- News sources → Scrape news: feeds · Source sites are collected and parsed into article data.
- Scrape news → Clean text: cleans · Scraped data is normalized before AI rewriting.
- Clean text → Transformers: uses · Normalized text is prepared for model inference.
- Transformers → GPT-2: hosts · Transformers runtime provides the GPT-2 model layer.
- GPT-2 → Rewrite headline: generates · The model rewrites or generates the headline text.
- Rewrite headline → Compose post: formats · Rewritten text is packaged into a publishable post.
- Compose post → Facebook Graph: publishes to · Final post content is sent through the Facebook Graph API.
- Facebook Graph → Facebook Page: posts on · The API boundary targets a Facebook Page.
- Secrets → Main script: injects · Credentials and IDs are provided to the runtime at execution time.
- Screenshots → Setup guide: illustrates · Screenshots support the onboarding documentation.
