# rraphaelph/instaunf architecture

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

- Interactive diagram: https://gitdiagram.com/rraphaelph/instaunf
- Repository: https://github.com/rraphaelph/instaunf

## Overview

InstaUnf is a Chrome extension for analyzing Instagram follow relationships and managing unfollows. The principal workflow starts in the popup: it identifies the logged-in account, loads cached analysis or fetches paginated following and follower lists, then filters and renders non-followers for individual or bulk unfollow and whitelist actions. Supporting branches track scan limits and analysis trends, refresh the toolbar badge, and expose a floating Instagram button that opens a detached popup. Popup excerpts show calls to API, cache, and whitelist functionality; links to other helpers are documented or uncertain where the excerpt omits wiring.

Main entry points: [`popup/popup.js`](https://github.com/rraphaelph/instaunf/blob/master/popup/popup.js) (Popup workflow), [`background/service-worker.js`](https://github.com/rraphaelph/instaunf/blob/master/background/service-worker.js) (Service worker), [`content/content.js`](https://github.com/rraphaelph/instaunf/blob/master/content/content.js) (Floating button), [`utils/api.js`](https://github.com/rraphaelph/instaunf/blob/master/utils/api.js) (Following fetch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interfaces"]
  node_popup["Popup workflow<br/>[popup.js]"]
  node_fab["Floating button<br/>[content.js]"]
end

subgraph group_analysis["Analysis and actions"]
  node_following["Following fetch<br/>[api.js]"]
  node_followers["Followers fetch<br/>[api.js]"]
  node_unfollow_api["Unfollow API<br/>[api.js]"]
end

subgraph group_state["Local state"]
  node_cache[("Analysis cache<br/>[cache.js]")]
  node_whitelist[("Whitelist<br/>[whitelist.js]")]
  node_snapshots[("Trend snapshots<br/>[snapshot.js]")]
  node_limits[("Daily scan limits<br/>[limits.js]")]
  node_baseline[("Follower baseline<br/>[notifications.js]")]
end

subgraph group_background["Background integration"]
  node_service_worker["Service worker<br/>[service-worker.js]"]
  node_chrome_badge["Chrome badge"]
  node_detached_window["Detached popup"]
end

node_toolbar_user(("Toolbar user"))
node_instagram_page(("Instagram page"))
node_instagram{{"Instagram API"}}
node_chrome_storage[("Chrome local storage")]

node_toolbar_user -->|"opens"| node_popup
node_popup -->|"requests"| node_following
node_popup -->|"requests"| node_followers
node_popup -.->|"loads and saves"| node_cache
node_popup -->|"reads and updates"| node_whitelist
node_popup -->|"invokes"| node_unfollow_api
node_following -->|"fetches pages"| node_instagram
node_followers -->|"fetches pages"| node_instagram
node_unfollow_api -->|"posts unfollow"| node_instagram
node_cache -->|"reads and writes"| node_chrome_storage
node_whitelist -->|"reads and writes"| node_chrome_storage
node_snapshots -->|"reads and writes"| node_chrome_storage
node_limits -->|"reads and writes"| node_chrome_storage
node_baseline -->|"reads and writes"| node_chrome_storage
node_popup -.->|"checks limits"| node_limits
node_popup -.->|"records trends"| node_snapshots
node_popup -.->|"updates baseline"| node_baseline
node_instagram_page -->|"hosts"| node_fab
node_fab -->|"reads badge count"| node_chrome_storage
node_fab -->|"requests window"| node_service_worker
node_popup -.->|"sends badge count"| node_service_worker
node_service_worker -->|"reads snapshots"| node_chrome_storage
node_service_worker -->|"updates"| node_chrome_badge
node_service_worker -->|"creates"| node_detached_window

click node_popup "https://github.com/rraphaelph/instaunf/blob/master/popup/popup.js"
click node_fab "https://github.com/rraphaelph/instaunf/blob/master/content/content.js"
click node_following "https://github.com/rraphaelph/instaunf/blob/master/utils/api.js"
click node_followers "https://github.com/rraphaelph/instaunf/blob/master/utils/api.js"
click node_unfollow_api "https://github.com/rraphaelph/instaunf/blob/master/utils/api.js"
click node_cache "https://github.com/rraphaelph/instaunf/blob/master/utils/cache.js"
click node_whitelist "https://github.com/rraphaelph/instaunf/blob/master/utils/whitelist.js"
click node_snapshots "https://github.com/rraphaelph/instaunf/blob/master/utils/snapshot.js"
click node_limits "https://github.com/rraphaelph/instaunf/blob/master/utils/limits.js"
click node_baseline "https://github.com/rraphaelph/instaunf/blob/master/utils/notifications.js"
click node_service_worker "https://github.com/rraphaelph/instaunf/blob/master/background/service-worker.js"

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_popup,node_fab,node_toolbar_user toneBlue
class node_following,node_followers,node_unfollow_api,node_chrome_storage toneAmber
class node_cache,node_whitelist,node_snapshots,node_limits,node_baseline,node_instagram toneMint
class node_service_worker,node_chrome_badge,node_detached_window toneRose
class node_instagram_page toneIndigo
```

## Components

### User interfaces

- [Popup workflow](https://github.com/rraphaelph/instaunf/blob/master/popup/popup.js): `popup/popup.js`
- [Floating button](https://github.com/rraphaelph/instaunf/blob/master/content/content.js): `content/content.js`

### Analysis and actions

- [Following fetch](https://github.com/rraphaelph/instaunf/blob/master/utils/api.js): `utils/api.js`
- [Followers fetch](https://github.com/rraphaelph/instaunf/blob/master/utils/api.js): `utils/api.js`
- [Unfollow API](https://github.com/rraphaelph/instaunf/blob/master/utils/api.js): `utils/api.js`

### Local state

- [Analysis cache](https://github.com/rraphaelph/instaunf/blob/master/utils/cache.js): `utils/cache.js`
- [Whitelist](https://github.com/rraphaelph/instaunf/blob/master/utils/whitelist.js): `utils/whitelist.js`
- [Trend snapshots](https://github.com/rraphaelph/instaunf/blob/master/utils/snapshot.js): `utils/snapshot.js`
- [Daily scan limits](https://github.com/rraphaelph/instaunf/blob/master/utils/limits.js): `utils/limits.js`
- [Follower baseline](https://github.com/rraphaelph/instaunf/blob/master/utils/notifications.js): `utils/notifications.js`

### Background integration

- [Service worker](https://github.com/rraphaelph/instaunf/blob/master/background/service-worker.js): `background/service-worker.js`
- **Chrome badge**
- **Detached popup**

### Other components

- **Toolbar user**
- **Instagram page**
- **Instagram API**
- **Chrome local storage**

## Connections

- Toolbar user → Popup workflow: opens (evidence: `README.md`)
- Popup workflow → Following fetch: requests (evidence: `popup/popup.js`)
- Popup workflow → Followers fetch: requests (evidence: `popup/popup.js`)
- Popup workflow → Analysis cache: loads and saves
- Popup workflow → Whitelist: reads and updates (evidence: `popup/popup.js`)
- Popup workflow → Unfollow API: invokes (evidence: `popup/popup.js`)
- Following fetch → Instagram API: fetches pages (evidence: `utils/api.js`)
- Followers fetch → Instagram API: fetches pages (evidence: `utils/api.js`)
- Unfollow API → Instagram API: posts unfollow (evidence: `utils/api.js`)
- Analysis cache → Chrome local storage: reads and writes (evidence: `utils/cache.js`)
- Whitelist → Chrome local storage: reads and writes (evidence: `utils/whitelist.js`)
- Trend snapshots → Chrome local storage: reads and writes (evidence: `utils/snapshot.js`)
- Daily scan limits → Chrome local storage: reads and writes (evidence: `utils/limits.js`)
- Follower baseline → Chrome local storage: reads and writes (evidence: `utils/notifications.js`)
- Popup workflow → Daily scan limits: checks limits
- Popup workflow → Trend snapshots: records trends
- Popup workflow → Follower baseline: updates baseline
- Instagram page → Floating button: hosts (evidence: `README.md`)
- Floating button → Chrome local storage: reads badge count (evidence: `content/content.js`)
- Floating button → Service worker: requests window (evidence: `content/content.js`)
- Popup workflow → Service worker: sends badge count
- Service worker → Chrome local storage: reads snapshots (evidence: `background/service-worker.js`)
- Service worker → Chrome badge: updates (evidence: `background/service-worker.js`)
- Service worker → Detached popup: creates (evidence: `background/service-worker.js`)
