# henryalbu/auto-instagram-posting-bot architecture

> Architecture diagram of the GitHub repository henryalbu/auto-instagram-posting-bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/henryalbu/auto-instagram-posting-bot
- Repository: https://github.com/henryalbu/auto-instagram-posting-bot

## Overview

AIPB is a desktop GUI bot that collects images and captions from 9gag or an Instagram account, queues them locally, then uses Selenium to publish them to Instagram. The main workflow runs from the GUI through the posting loop; collection differs by source. Local queue and duplicate tracking support that flow. The README also documents category selection, polling, post limits, and Facebook login. Source excerpts show the core calls and file transfers; unsampled UI and initialization details are represented only where documented.

Main entry points: [`insta.py`](https://github.com/henryalbu/auto-instagram-posting-bot/blob/master/insta.py) (Posting loop), [`ninegag.py`](https://github.com/henryalbu/auto-instagram-posting-bot/blob/master/ninegag.py) (9gag collector), [`insta_scraper.py`](https://github.com/henryalbu/auto-instagram-posting-bot/blob/master/insta_scraper.py) (Instagram scraper), [`app.py`](https://github.com/henryalbu/auto-instagram-posting-bot/blob/master/app.py) (Desktop UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["User Control"]
  node_gui["Desktop UI<br/>[app.py]"]
  node_settings["Runtime settings<br/>[settings.py]"]
end

subgraph group_collection["Image Collection"]
  node_ninegag["9gag collector<br/>[ninegag.py]"]
  node_scraper["Instagram scraper<br/>[insta_scraper.py]"]
end

subgraph group_state["Local State"]
  node_queue["Post queue"]
  node_dupes["Duplicate ledger"]
  node_images["Image files"]
end

subgraph group_publishing["Instagram Publishing"]
  node_loop["Posting loop<br/>[insta.py]"]
  node_browser["Browser automation<br/>[insta.py]"]
end

node_user(("Bot operator"))
node_ninegag_service(("9gag"))
node_source_instagram(("Source Instagram"))
node_scraper_cli["Scraper CLI"]
node_instagram(("Posting Instagram"))
node_facebook(("Facebook login"))

node_user -->|"configures run"| node_gui
node_gui -->|"sets options"| node_settings
node_gui -->|"starts posting"| node_loop
node_loop -->|"reads options"| node_settings
node_loop -->|"requests posts"| node_ninegag
node_loop -->|"requests posts"| node_scraper
node_ninegag -->|"fetches images"| node_ninegag_service
node_scraper -->|"runs scraper"| node_scraper_cli
node_scraper_cli -->|"retrieves media"| node_source_instagram
node_ninegag -->|"writes posts"| node_queue
node_scraper -->|"writes posts"| node_queue
node_ninegag -->|"records IDs"| node_dupes
node_scraper -->|"records IDs"| node_dupes
node_ninegag -->|"downloads images"| node_images
node_scraper_cli -->|"saves media"| node_images
node_loop -->|"loads next post"| node_queue
node_loop -->|"drives publishing"| node_browser
node_browser -->|"reads caption"| node_queue
node_browser -->|"selects image"| node_images
node_browser -->|"logs in and posts"| node_instagram
node_browser -.->|"uses login"| node_facebook

click node_gui "https://github.com/henryalbu/auto-instagram-posting-bot/blob/master/app.py"
click node_settings "https://github.com/henryalbu/auto-instagram-posting-bot/blob/master/settings.py"
click node_loop "https://github.com/henryalbu/auto-instagram-posting-bot/blob/master/insta.py"
click node_ninegag "https://github.com/henryalbu/auto-instagram-posting-bot/blob/master/ninegag.py"
click node_scraper "https://github.com/henryalbu/auto-instagram-posting-bot/blob/master/insta_scraper.py"
click node_browser "https://github.com/henryalbu/auto-instagram-posting-bot/blob/master/insta.py"

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_gui,node_settings toneBlue
class node_ninegag,node_scraper toneAmber
class node_queue,node_dupes,node_images toneMint
class node_loop,node_browser toneRose
class node_user,node_ninegag_service,node_source_instagram,node_scraper_cli,node_instagram,node_facebook toneIndigo
```

## Components

### User Control

- [Desktop UI](https://github.com/henryalbu/auto-instagram-posting-bot/blob/master/app.py): `app.py`
- [Runtime settings](https://github.com/henryalbu/auto-instagram-posting-bot/blob/master/settings.py): `settings.py`

### Image Collection

- [9gag collector](https://github.com/henryalbu/auto-instagram-posting-bot/blob/master/ninegag.py): `ninegag.py`
- [Instagram scraper](https://github.com/henryalbu/auto-instagram-posting-bot/blob/master/insta_scraper.py): `insta_scraper.py`

### Local State

- **Post queue**
- **Duplicate ledger**
- **Image files**

### Instagram Publishing

- [Posting loop](https://github.com/henryalbu/auto-instagram-posting-bot/blob/master/insta.py): `insta.py`
- [Browser automation](https://github.com/henryalbu/auto-instagram-posting-bot/blob/master/insta.py): `insta.py`

### Other components

- **Bot operator**
- **9gag**
- **Source Instagram**
- **Scraper CLI**
- **Posting Instagram**
- **Facebook login**

## Connections

- Bot operator → Desktop UI: configures run (evidence: `README.md`)
- Desktop UI → Runtime settings: sets options (evidence: `app.py`)
- Desktop UI → Posting loop: starts posting (evidence: `app.py`)
- Posting loop → Runtime settings: reads options (evidence: `insta.py`)
- Posting loop → 9gag collector: requests posts (evidence: `insta.py`)
- Posting loop → Instagram scraper: requests posts (evidence: `insta.py`)
- 9gag collector → 9gag: fetches images (evidence: `ninegag.py`)
- Instagram scraper → Scraper CLI: runs scraper (evidence: `insta_scraper.py`)
- Scraper CLI → Source Instagram: retrieves media
- 9gag collector → Post queue: writes posts (evidence: `ninegag.py`)
- Instagram scraper → Post queue: writes posts (evidence: `insta_scraper.py`)
- 9gag collector → Duplicate ledger: records IDs (evidence: `ninegag.py`)
- Instagram scraper → Duplicate ledger: records IDs (evidence: `insta_scraper.py`)
- 9gag collector → Image files: downloads images (evidence: `ninegag.py`)
- Scraper CLI → Image files: saves media
- Posting loop → Post queue: loads next post (evidence: `insta.py`)
- Posting loop → Browser automation: drives publishing (evidence: `insta.py`)
- Browser automation → Post queue: reads caption (evidence: `insta.py`)
- Browser automation → Image files: selects image (evidence: `insta.py`)
- Browser automation → Posting Instagram: logs in and posts (evidence: `insta.py`)
- Browser automation → Facebook login: uses login (evidence: `insta.py`)
