# summersonnn/reddit_analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/summersonnn/reddit_analyzer
- Repository: https://github.com/summersonnn/reddit_analyzer

## Overview

Reddit Thread Analyzer is a Streamlit app that turns a Reddit thread URL and user-selected summary options into summaries and ranked comments. The main flow fetches and structures the thread, optionally enriches the post with image and external-link context, generates summaries, ranks comments, and displays results. Cache helpers reuse or persist analyses locally or in S3. The graph reflects the sampled orchestration and helpers; some frontend and scraping details were omitted, so uncertain internal wiring is left out.

Main entry points: [`frontend/home.py`](https://github.com/summersonnn/reddit_analyzer/blob/main/frontend/home.py) (Home and orchestration), [`analyze_main.py`](https://github.com/summersonnn/reddit_analyzer/blob/main/analyze_main.py) (Analysis orchestration), [`llm_interact.py`](https://github.com/summersonnn/reddit_analyzer/blob/main/llm_interact.py) (LLM client), [`frontend/cache_helpers.py`](https://github.com/summersonnn/reddit_analyzer/blob/main/frontend/cache_helpers.py) (Cache lookup and updates)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_home["Home and orchestration<br/>[home.py]"]
  node_results["Analysis results<br/>[analysis.py]"]
  node_options["Summary options<br/>[home.py]"]
end

subgraph group_thread["Thread processing"]
  node_fetch["Thread retrieval<br/>[analyze_main.py]"]
  node_scraper["Reddit fetch and parsing"]
end

subgraph group_analysis["Analysis and enrichment"]
  node_analysis_flow["Analysis orchestration<br/>[analyze_main.py]"]
  node_media["Media enrichment<br/>[analyze_main.py]"]
  node_web_summary["External-link summaries"]
  node_ranking["Comment ranking"]
  node_llm_client["LLM client<br/>[llm_interact.py]"]
  node_prompt_config["Prompt loading<br/>[config.py]"]
  node_prompts["Prompt definitions<br/>[prompts.yaml]"]
end

subgraph group_cache["Analysis cache"]
  node_cache_flow["Cache lookup and updates<br/>[cache_helpers.py]"]
  node_cache_file[("CSV analysis cache<br/>[analyses.csv]")]
end

node_user(("App user"))
node_reddit["Reddit"]
node_model["LLM and vision API"]
node_s3[("S3 cache")]

node_user -->|"opens app"| node_home
node_home -->|"collects options"| node_options
node_home -->|"checks cache"| node_cache_flow
node_home -->|"requests thread"| node_fetch
node_fetch -->|"fetches and parses"| node_scraper
node_scraper -->|"requests JSON"| node_reddit
node_home -->|"starts analysis"| node_analysis_flow
node_analysis_flow -->|"fetches thread data"| node_scraper
node_analysis_flow -->|"loads prompts"| node_prompt_config
node_prompt_config -->|"reads"| node_prompts
node_analysis_flow -->|"enriches post"| node_media
node_media -->|"analyzes images"| node_llm_client
node_media -->|"summarizes links"| node_web_summary
node_web_summary -->|"requests summary"| node_llm_client
node_analysis_flow -->|"generates summaries"| node_llm_client
node_llm_client -->|"sends completions"| node_model
node_analysis_flow -->|"ranks comments"| node_ranking
node_home -->|"displays results"| node_results
node_cache_flow -->|"reads and writes"| node_cache_file
node_cache_flow -.->|"reads and writes"| node_s3
node_home -.->|"reads cache"| node_s3

click node_home "https://github.com/summersonnn/reddit_analyzer/blob/main/frontend/home.py"
click node_results "https://github.com/summersonnn/reddit_analyzer/blob/main/frontend/analysis.py"
click node_fetch "https://github.com/summersonnn/reddit_analyzer/blob/main/analyze_main.py"
click node_scraper "https://github.com/summersonnn/reddit_analyzer/blob/main/scrape_functions.py"
click node_options "https://github.com/summersonnn/reddit_analyzer/blob/main/frontend/home.py"
click node_analysis_flow "https://github.com/summersonnn/reddit_analyzer/blob/main/analyze_main.py"
click node_media "https://github.com/summersonnn/reddit_analyzer/blob/main/analyze_main.py"
click node_web_summary "https://github.com/summersonnn/reddit_analyzer/blob/main/try_html_summary.py"
click node_ranking "https://github.com/summersonnn/reddit_analyzer/blob/main/thread_analysis_functions.py"
click node_llm_client "https://github.com/summersonnn/reddit_analyzer/blob/main/llm_interact.py"
click node_prompt_config "https://github.com/summersonnn/reddit_analyzer/blob/main/config.py"
click node_prompts "https://github.com/summersonnn/reddit_analyzer/blob/main/prompts.yaml"
click node_cache_flow "https://github.com/summersonnn/reddit_analyzer/blob/main/frontend/cache_helpers.py"
click node_cache_file "https://github.com/summersonnn/reddit_analyzer/blob/main/analyses.csv"

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_home,node_results,node_options,node_user toneBlue
class node_fetch,node_scraper,node_s3 toneAmber
class node_analysis_flow,node_media,node_web_summary,node_ranking,node_llm_client,node_prompt_config,node_prompts,node_model toneMint
class node_cache_flow,node_cache_file toneRose
class node_reddit toneIndigo
```

## Components

### User interface

- [Home and orchestration](https://github.com/summersonnn/reddit_analyzer/blob/main/frontend/home.py): `frontend/home.py`
- [Analysis results](https://github.com/summersonnn/reddit_analyzer/blob/main/frontend/analysis.py): `frontend/analysis.py`
- [Summary options](https://github.com/summersonnn/reddit_analyzer/blob/main/frontend/home.py): `frontend/home.py`

### Thread processing

- [Thread retrieval](https://github.com/summersonnn/reddit_analyzer/blob/main/analyze_main.py): `analyze_main.py`
- [Reddit fetch and parsing](https://github.com/summersonnn/reddit_analyzer/blob/main/scrape_functions.py): `scrape_functions.py`

### Analysis and enrichment

- [Analysis orchestration](https://github.com/summersonnn/reddit_analyzer/blob/main/analyze_main.py): `analyze_main.py`
- [Media enrichment](https://github.com/summersonnn/reddit_analyzer/blob/main/analyze_main.py): `analyze_main.py`
- [External-link summaries](https://github.com/summersonnn/reddit_analyzer/blob/main/try_html_summary.py): `try_html_summary.py`
- [Comment ranking](https://github.com/summersonnn/reddit_analyzer/blob/main/thread_analysis_functions.py): `thread_analysis_functions.py`
- [LLM client](https://github.com/summersonnn/reddit_analyzer/blob/main/llm_interact.py): `llm_interact.py`
- [Prompt loading](https://github.com/summersonnn/reddit_analyzer/blob/main/config.py): `config.py`
- [Prompt definitions](https://github.com/summersonnn/reddit_analyzer/blob/main/prompts.yaml): `prompts.yaml`

### Analysis cache

- [Cache lookup and updates](https://github.com/summersonnn/reddit_analyzer/blob/main/frontend/cache_helpers.py): `frontend/cache_helpers.py`
- [CSV analysis cache](https://github.com/summersonnn/reddit_analyzer/blob/main/analyses.csv): `analyses.csv`

### Other components

- **App user**
- **Reddit**
- **LLM and vision API**
- **S3 cache**

## Connections

- App user → Home and orchestration: opens app
- Home and orchestration → Summary options: collects options
- Home and orchestration → Cache lookup and updates: checks cache
- Home and orchestration → Thread retrieval: requests thread
- Thread retrieval → Reddit fetch and parsing: fetches and parses
- Reddit fetch and parsing → Reddit: requests JSON
- Home and orchestration → Analysis orchestration: starts analysis
- Analysis orchestration → Reddit fetch and parsing: fetches thread data
- Analysis orchestration → Prompt loading: loads prompts
- Prompt loading → Prompt definitions: reads
- Analysis orchestration → Media enrichment: enriches post
- Media enrichment → LLM client: analyzes images
- Media enrichment → External-link summaries: summarizes links
- External-link summaries → LLM client: requests summary
- Analysis orchestration → LLM client: generates summaries
- LLM client → LLM and vision API: sends completions
- Analysis orchestration → Comment ranking: ranks comments
- Home and orchestration → Analysis results: displays results
- Cache lookup and updates → CSV analysis cache: reads and writes
- Cache lookup and updates → S3 cache: reads and writes
- Home and orchestration → S3 cache: reads cache
