# chrisj1259/followersreport architecture

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

- Interactive diagram: https://gitdiagram.com/chrisj1259/followersreport
- Repository: https://github.com/chrisj1259/followersreport

## Overview

#### Purpose and entry points
Instagram Follower Report is a local-first Python application that analyzes timestamped Instagram export snapshots. It reports follower/following relationships, historical unilateral unfollows, and manually or network-detected disabled accounts. It has two delivery modes:
- CLI/local HTTP server: `run.py`
- Windows native window wrapping the same local app: `app.py`

Core UI is a browser/WebView-rendered single page in `index.html`.

#### Analysis and report pipeline
`run.py` is the primary backend and command dispatcher. It imports export files, reads snapshots, computes follower/following set differences and historical comparisons, writes the active report cache, and serves the UI on loopback only.
- `run.py`
- `index.html`

Snapshot input is Instagram JSON (`followers_1.json`, `following.json`) staged under dated data directories. The pipeline retains dates so it can distinguish current non-mutual relationships from accounts that previously followed but later unfollowed.

#### Local storage and profile boundary
Source/CLI mode uses repository-local `data/`, `dist/`, and `ig-session/`. Installed mode relocates mutable state to `%APPDATA%\InstagramFollowerReport\`, keeping packaged program files read-only.

Desktop accounts are isolated profiles: snapshots, disabled-account flags, and report state are associated with an internal profile ID rather than the visible Instagram username. Migration supports moving legacy single-account data into a selected profile.
- `run.py`
- `app.py`

#### UI and local API boundary
The frontend is a self-contained HTML/CSS/JavaScript application. It displays stat cards and relationship panels, supports drag/drop or file-based snapshot import, profile selection, and flag/unflag actions. It communicates only with the local Python server/application state; no hosted web backend is involved.
- `index.html`
- `run.py`

#### Instagram status and live-count integration
Optional Instagram integration is isolated in `ig_helper.py`. It uses Scrapling with Chrome for an explicit visible login, persists a local browser session, then performs authenticated profile checks for live counts and flagged-account rechecks. Ambiguous failures preserve flags. A separate CLI mode can perform anonymous checks for deleted/deactivated pages.
- `ig_helper.py`
- `run.py`

The required runtime is Python 3.10+. Chrome and `scrapling[fetchers]` are optional except for login, live counts, and authenticated status rechecks.

#### Windows desktop packaging
`app.py` launches the local application inside pywebview for the Windows desktop experience. Packaging builds a PyInstaller executable, then produces an Inno Setup installer that installs or bootstraps Microsoft Edge WebView2 and creates Windows shortcuts/uninstall metadata.
- `app.py`
- `build.py`
- `build.spec`
- `installer.iss`

#### Release/update infrastructure
The installed application checks public GitHub Releases for newer versions and can download/run the newer installer, while preserving `%APPDATA%` data. GitHub Actions builds/tests normal changes and builds tagged releases for distribution.
- `.github/workflows/build.yml`
- `app.py`
- `build.py`

Main entry points: [`run.py`](https://github.com/chrisj1259/followersreport/blob/main/run.py) (CLI and loopback server), [`build.py`](https://github.com/chrisj1259/followersreport/blob/main/build.py) (Executable build), [`ig_helper.py`](https://github.com/chrisj1259/followersreport/blob/main/ig_helper.py) (Instagram status helper), [`app.py`](https://github.com/chrisj1259/followersreport/blob/main/app.py) (Release updater)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Local Analysis App"]
  node_cli_server["CLI and loopback server<br/>Python dispatcher<br/>[run.py]"]
  node_report_engine["Relationship analysis<br/>report pipeline<br/>[run.py]"]
  node_local_api["Local UI API<br/>loopback API<br/>[run.py]"]
  node_web_ui["Single-page UI<br/>HTML/JavaScript<br/>[index.html]"]
end

subgraph group_storage["Local State"]
  node_snapshot_exports["Instagram JSON snapshots<br/>input data"]
  node_local_data[("Snapshots and report cache<br/>mutable storage")]
  node_profiles[("Internal profile state<br/>profile boundary")]
  node_legacy_migration["Legacy data migration<br/>migration flow<br/>[app.py]"]
end

subgraph group_instagram["Optional Instagram Integration"]
  node_ig_helper["Instagram status helper<br/>authenticated checker<br/>[ig_helper.py]"]
  node_chrome_session["Chrome session<br/>local browser session"]
  node_anonymous_check["Anonymous status checks<br/>CLI mode<br/>[run.py]"]
end

subgraph group_desktop["Windows Distribution"]
  node_desktop_shell["Windows WebView shell<br/>pywebview launcher<br/>[app.py]"]
  node_update_check["Release updater<br/>GitHub release client<br/>[app.py]"]
end

subgraph group_release["Build and Release"]
  node_pyinstaller_build["Executable build<br/>PyInstaller build<br/>[build.py]"]
  node_pyinstaller_spec["PyInstaller spec<br/>packaging spec<br/>[build.spec]"]
  node_inno_installer["Windows installer<br/>Inno Setup<br/>[installer.iss]"]
  node_github_actions["CI and tagged releases<br/>GitHub Actions workflow<br/>[build.yml]"]
end

node_snapshot_exports -->|"import"| node_cli_server
node_cli_server -->|"analyze"| node_report_engine
node_report_engine -->|"write active report"| node_local_data
node_cli_server -->|"serve"| node_local_api
node_web_ui -->|"local actions and reports"| node_local_api
node_local_api -->|"read/update profile state"| node_profiles
node_report_engine -->|"associate report with profile"| node_profiles
node_legacy_migration -->|"migrate selected account"| node_profiles
node_desktop_shell -->|"launch same local app"| node_cli_server
node_cli_server -->|"request authenticated checks"| node_ig_helper
node_ig_helper -->|"persist login"| node_chrome_session
node_anonymous_check -.->|"alternate status mode"| node_ig_helper
node_ig_helper -->|"update disabled-account flags"| node_profiles
node_pyinstaller_build -->|"use spec"| node_pyinstaller_spec
node_pyinstaller_build -->|"package"| node_desktop_shell
node_pyinstaller_build -->|"stage executable"| node_inno_installer
node_github_actions -->|"build/test/release"| node_pyinstaller_build
node_update_check -->|"download and run update"| node_inno_installer
node_update_check -.->|"preserve AppData"| node_local_data

click node_cli_server "https://github.com/chrisj1259/followersreport/blob/main/run.py"
click node_report_engine "https://github.com/chrisj1259/followersreport/blob/main/run.py"
click node_local_api "https://github.com/chrisj1259/followersreport/blob/main/run.py"
click node_web_ui "https://github.com/chrisj1259/followersreport/blob/main/index.html"
click node_legacy_migration "https://github.com/chrisj1259/followersreport/blob/main/app.py"
click node_ig_helper "https://github.com/chrisj1259/followersreport/blob/main/ig_helper.py"
click node_anonymous_check "https://github.com/chrisj1259/followersreport/blob/main/run.py"
click node_desktop_shell "https://github.com/chrisj1259/followersreport/blob/main/app.py"
click node_pyinstaller_build "https://github.com/chrisj1259/followersreport/blob/main/build.py"
click node_pyinstaller_spec "https://github.com/chrisj1259/followersreport/blob/main/build.spec"
click node_inno_installer "https://github.com/chrisj1259/followersreport/blob/main/installer.iss"
click node_update_check "https://github.com/chrisj1259/followersreport/blob/main/app.py"
click node_github_actions "https://github.com/chrisj1259/followersreport/blob/main/.github/workflows/build.yml"

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_cli_server,node_report_engine,node_local_api,node_web_ui toneBlue
class node_snapshot_exports,node_local_data,node_profiles,node_legacy_migration toneAmber
class node_ig_helper,node_chrome_session,node_anonymous_check toneMint
class node_desktop_shell,node_update_check toneRose
class node_pyinstaller_build,node_pyinstaller_spec,node_inno_installer,node_github_actions toneIndigo
```

## Components

### Local Analysis App

- [CLI and loopback server](https://github.com/chrisj1259/followersreport/blob/main/run.py): Python dispatcher · Imports snapshots, generates reports, and serves the local UI. · `run.py`
- [Relationship analysis](https://github.com/chrisj1259/followersreport/blob/main/run.py): report pipeline · Compares dated follower and following snapshots for current and historical changes. · `run.py`
- [Local UI API](https://github.com/chrisj1259/followersreport/blob/main/run.py): loopback API · Exposes local application state and actions without a hosted backend. · `run.py`
- [Single-page UI](https://github.com/chrisj1259/followersreport/blob/main/index.html): HTML/JavaScript · Imports snapshots, displays reports, manages profiles, and flags accounts. · `index.html`

### Local State

- **Instagram JSON snapshots**: input data · Dated followers_1.json and following.json exports retain relationship history.
- **Snapshots and report cache**: mutable storage · Uses repository-local data/ in source mode and AppData in installed mode.
- **Internal profile state**: profile boundary · Separates snapshots, flags, and report state by internal profile ID.
- [Legacy data migration](https://github.com/chrisj1259/followersreport/blob/main/app.py): migration flow · Moves prior single-account data into a selected profile. · `app.py`

### Optional Instagram Integration

- [Instagram status helper](https://github.com/chrisj1259/followersreport/blob/main/ig_helper.py): authenticated checker · Performs visible login, live-count checks, and flagged-account rechecks. · `ig_helper.py`
- **Chrome session**: local browser session · Scrapling/Chrome session persisted locally for authenticated checks.
- [Anonymous status checks](https://github.com/chrisj1259/followersreport/blob/main/run.py): CLI mode · Checks deleted or deactivated profile pages without login. · `run.py`

### Windows Distribution

- [Windows WebView shell](https://github.com/chrisj1259/followersreport/blob/main/app.py): pywebview launcher · Hosts the same local application in a native Windows window. · `app.py`
- [Release updater](https://github.com/chrisj1259/followersreport/blob/main/app.py): GitHub release client · Downloads and runs a newer installer while preserving AppData state. · `app.py`

### Build and Release

- [Executable build](https://github.com/chrisj1259/followersreport/blob/main/build.py): PyInstaller build · `build.py`
- [PyInstaller spec](https://github.com/chrisj1259/followersreport/blob/main/build.spec): packaging spec · `build.spec`
- [Windows installer](https://github.com/chrisj1259/followersreport/blob/main/installer.iss): Inno Setup · Installs the executable, WebView2 support, shortcuts, and uninstall metadata. · `installer.iss`
- [CI and tagged releases](https://github.com/chrisj1259/followersreport/blob/main/.github/workflows/build.yml): GitHub Actions workflow · Builds/tests changes and publishes distributable tagged releases. · `.github/workflows/build.yml`

## Connections

- Instagram JSON snapshots → CLI and loopback server: import
- CLI and loopback server → Relationship analysis: analyze
- Relationship analysis → Snapshots and report cache: write active report
- CLI and loopback server → Local UI API: serve
- Single-page UI → Local UI API: local actions and reports
- Local UI API → Internal profile state: read/update profile state
- Relationship analysis → Internal profile state: associate report with profile
- Legacy data migration → Internal profile state: migrate selected account
- Windows WebView shell → CLI and loopback server: launch same local app
- CLI and loopback server → Instagram status helper: request authenticated checks
- Instagram status helper → Chrome session: persist login
- Anonymous status checks → Instagram status helper: alternate status mode
- Instagram status helper → Internal profile state: update disabled-account flags
- Executable build → PyInstaller spec: use spec
- Executable build → Windows WebView shell: package
- Executable build → Windows installer: stage executable
- CI and tagged releases → Executable build: build/test/release
- Release updater → Windows installer: download and run update
- Release updater → Snapshots and report cache: preserve AppData
