# juleslemee/instagram-algorithm-research architecture

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

- Interactive diagram: https://gitdiagram.com/juleslemee/instagram-algorithm-research
- Repository: https://github.com/juleslemee/instagram-algorithm-research

## Overview

This repository is an academic research system with two separate workflows: Instagram persona simulation and account-bias collection, plus image-based political-bias model training and evaluation. Part 1’s sampled code shows scraper orchestration, browser automation, image categorization, and S3 upload. Part 2’s README documents CLIP/Doc2Vec feature extraction and classifier workflows; its file-level wiring is not established by the excerpts, so those relationships are shown as unverified.

Main entry points: [`research-part-1/src/collector.py`](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/collector.py) (Account Collector), [`research-part-1/src/doomscroller.py`](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/doomscroller.py) (Persona Simulation), [`research-part-1/src/categorizor.py`](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/categorizor.py) (Image Categorizer), [`research-part-1/src/open_ig.py`](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/open_ig.py) (Instagram Login)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Instagram Collection"]
  node_session_runner["Session Runner<br/>[mainsim.py]"]
  node_persona_sim["Persona Simulation<br/>[doomscroller.py]"]
  node_account_runner["Account Runner<br/>[maincol.py]"]
  node_account_collector["Account Collector<br/>[collector.py]"]
  node_account_labels["Political Labels<br/>[collector.py]"]
end

subgraph group_collection_support["Collection Support"]
  node_login_flow["Instagram Login<br/>[open_ig.py]"]
  node_browser["Chrome Driver<br/>[driver_chrome.py]"]
  node_image_categorizer["Image Categorizer<br/>[categorizor.py]"]
  node_topic_list["Topic List<br/>[topics.py]"]
  node_openai_key["OpenAI Key<br/>[openai_key.py]"]
  node_s3_upload["Screenshot Upload<br/>[aws.py]"]
  node_credentials["AWS Credentials<br/>[credentials.py]"]
end

subgraph group_vision["Image Analysis"]
  node_clip_features["CLIP Features<br/>[clip_features.py]"]
  node_clip_model["CLIP Model<br/>[clip_model.py]"]
  node_original_features["Original Features"]
  node_project_features["Project Features"]
end

subgraph group_vision_models["Model Training"]
  node_clip_stage["CLIP Stage Two<br/>[clip_stage_2.py]"]
  node_original_training["Original Training<br/>[og_train_model.py]"]
  node_original_evaluation["Original Evaluation"]
  node_original_eval_modified["Modified Evaluation"]
  node_project_training["Project Training<br/>[our_train_model.py]"]
  node_project_evaluation["Project Evaluation"]
end

node_researcher(("Researcher"))
node_instagram["Instagram"]
node_openai["OpenAI"]
node_aws[("Amazon S3")]
node_research_dataset[("Image Dataset")]

node_researcher -->|"starts simulation"| node_session_runner
node_session_runner -->|"runs"| node_persona_sim
node_researcher -->|"starts collection"| node_account_runner
node_account_runner -->|"runs"| node_account_collector
node_persona_sim -->|"opens reels"| node_login_flow
node_account_collector -->|"opens reels"| node_login_flow
node_login_flow -->|"uses driver"| node_browser
node_persona_sim -->|"controls browser"| node_browser
node_account_collector -->|"controls browser"| node_browser
node_login_flow -->|"logs in"| node_instagram
node_persona_sim -->|"interacts with reels"| node_instagram
node_account_collector -->|"categorizes thumbnails"| node_image_categorizer
node_image_categorizer -->|"requests labels"| node_openai
node_account_collector -->|"uploads screenshots"| node_s3_upload
node_s3_upload -->|"writes images"| node_aws
node_account_collector -->|"writes account labels"| node_account_labels
node_image_categorizer -->|"imports topics"| node_topic_list
node_image_categorizer -->|"loads key"| node_openai_key
node_s3_upload -->|"loads credentials"| node_credentials
node_researcher -->|"supplies images"| node_research_dataset
node_research_dataset -.->|"provides images"| node_clip_features
node_clip_features -.->|"extracts CLIP features"| node_clip_model
node_clip_model -.->|"supports classification"| node_clip_stage
node_research_dataset -.->|"provides images"| node_original_features
node_original_features -.->|"feeds classifier"| node_original_training
node_original_training -.->|"supports evaluation"| node_original_evaluation
node_original_training -.->|"supports evaluation"| node_original_eval_modified
node_research_dataset -.->|"provides images"| node_project_features
node_project_features -.->|"feeds classifier"| node_project_training
node_project_training -.->|"supports evaluation"| node_project_evaluation

click node_session_runner "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/mainsim.py"
click node_persona_sim "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/doomscroller.py"
click node_account_runner "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/maincol.py"
click node_account_collector "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/collector.py"
click node_login_flow "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/open_ig.py"
click node_browser "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/drivers/driver_chrome.py"
click node_account_labels "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/collector.py"
click node_image_categorizer "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/categorizor.py"
click node_topic_list "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/input/topics/topics.py"
click node_openai_key "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/input/keys/openai_key.py"
click node_s3_upload "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/aws.py"
click node_credentials "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/input/keys/credentials.py"
click node_clip_features "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/clip_features.py"
click node_clip_model "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/clip_model.py"
click node_clip_stage "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/clip_stage_2.py"
click node_original_features "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/og_extract_features.py"
click node_original_training "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/og_train_model.py"
click node_original_evaluation "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/og_train_eval_stage_2.py"
click node_original_eval_modified "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/og_train_eval_stage_2_modified.py"
click node_project_features "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/our_extract_features.py"
click node_project_training "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/our_train_model.py"
click node_project_evaluation "https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/our_train_eval_stage_2.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_session_runner,node_persona_sim,node_account_runner,node_account_collector,node_account_labels toneBlue
class node_login_flow,node_browser,node_image_categorizer,node_topic_list,node_openai_key,node_s3_upload,node_credentials,node_aws,node_research_dataset toneAmber
class node_clip_features,node_clip_model,node_original_features,node_project_features toneMint
class node_clip_stage,node_original_training,node_original_evaluation,node_original_eval_modified,node_project_training,node_project_evaluation toneRose
class node_researcher,node_instagram,node_openai toneIndigo
```

## Components

### Instagram Collection

- [Session Runner](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/mainsim.py): `research-part-1/src/mainsim.py`
- [Persona Simulation](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/doomscroller.py): `research-part-1/src/doomscroller.py`
- [Account Runner](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/maincol.py): `research-part-1/src/maincol.py`
- [Account Collector](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/collector.py): `research-part-1/src/collector.py`
- [Political Labels](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/collector.py): `research-part-1/src/collector.py`

### Collection Support

- [Instagram Login](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/open_ig.py): `research-part-1/src/open_ig.py`
- [Chrome Driver](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/drivers/driver_chrome.py): `research-part-1/drivers/driver_chrome.py`
- [Image Categorizer](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/categorizor.py): `research-part-1/src/categorizor.py`
- [Topic List](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/input/topics/topics.py): `research-part-1/input/topics/topics.py`
- [OpenAI Key](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/input/keys/openai_key.py): `research-part-1/input/keys/openai_key.py`
- [Screenshot Upload](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/src/aws.py): `research-part-1/src/aws.py`
- [AWS Credentials](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-1/input/keys/credentials.py): `research-part-1/input/keys/credentials.py`

### Image Analysis

- [CLIP Features](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/clip_features.py): `research-part-2/clip_features.py`
- [CLIP Model](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/clip_model.py): `research-part-2/clip_model.py`
- [Original Features](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/og_extract_features.py): `research-part-2/og_extract_features.py`
- [Project Features](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/our_extract_features.py): `research-part-2/our_extract_features.py`

### Model Training

- [CLIP Stage Two](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/clip_stage_2.py): `research-part-2/clip_stage_2.py`
- [Original Training](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/og_train_model.py): `research-part-2/og_train_model.py`
- [Original Evaluation](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/og_train_eval_stage_2.py): `research-part-2/og_train_eval_stage_2.py`
- [Modified Evaluation](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/og_train_eval_stage_2_modified.py): `research-part-2/og_train_eval_stage_2_modified.py`
- [Project Training](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/our_train_model.py): `research-part-2/our_train_model.py`
- [Project Evaluation](https://github.com/juleslemee/instagram-algorithm-research/blob/master/research-part-2/our_train_eval_stage_2.py): `research-part-2/our_train_eval_stage_2.py`

### Other components

- **Researcher**
- **Instagram**
- **OpenAI**
- **Amazon S3**
- **Image Dataset**

## Connections

- Researcher → Session Runner: starts simulation (evidence: `README.md`)
- Session Runner → Persona Simulation: runs (evidence: `research-part-1/src/mainsim.py`)
- Researcher → Account Runner: starts collection (evidence: `README.md`)
- Account Runner → Account Collector: runs (evidence: `research-part-1/src/maincol.py`)
- Persona Simulation → Instagram Login: opens reels (evidence: `research-part-1/src/doomscroller.py`)
- Account Collector → Instagram Login: opens reels (evidence: `research-part-1/src/collector.py`)
- Instagram Login → Chrome Driver: uses driver (evidence: `research-part-1/src/open_ig.py`)
- Persona Simulation → Chrome Driver: controls browser (evidence: `research-part-1/src/doomscroller.py`)
- Account Collector → Chrome Driver: controls browser (evidence: `research-part-1/src/collector.py`)
- Instagram Login → Instagram: logs in (evidence: `research-part-1/src/open_ig.py`)
- Persona Simulation → Instagram: interacts with reels (evidence: `README.md`)
- Account Collector → Image Categorizer: categorizes thumbnails (evidence: `research-part-1/src/collector.py`)
- Image Categorizer → OpenAI: requests labels (evidence: `research-part-1/src/categorizor.py`)
- Account Collector → Screenshot Upload: uploads screenshots (evidence: `research-part-1/src/collector.py`)
- Screenshot Upload → Amazon S3: writes images (evidence: `research-part-1/src/aws.py`)
- Account Collector → Political Labels: writes account labels (evidence: `research-part-1/src/collector.py`)
- Image Categorizer → Topic List: imports topics (evidence: `research-part-1/src/categorizor.py`)
- Image Categorizer → OpenAI Key: loads key (evidence: `research-part-1/src/categorizor.py`)
- Screenshot Upload → AWS Credentials: loads credentials (evidence: `research-part-1/src/aws.py`)
- Researcher → Image Dataset: supplies images (evidence: `README.md`)
- Image Dataset → CLIP Features: provides images (evidence: `README.md`)
- CLIP Features → CLIP Model: extracts CLIP features (evidence: `README.md`)
- CLIP Model → CLIP Stage Two: supports classification (evidence: `README.md`)
- Image Dataset → Original Features: provides images (evidence: `README.md`)
- Original Features → Original Training: feeds classifier (evidence: `README.md`)
- Original Training → Original Evaluation: supports evaluation (evidence: `README.md`)
- Original Training → Modified Evaluation: supports evaluation (evidence: `README.md`)
- Image Dataset → Project Features: provides images (evidence: `README.md`)
- Project Features → Project Training: feeds classifier (evidence: `README.md`)
- Project Training → Project Evaluation: supports evaluation (evidence: `README.md`)
