Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Thread Lens

A Chrome extension + FastAPI backend that analyzes Reddit threads and surfaces structured opinion insights directly on the Reddit page.

What It Does

  • Adds an Analyze button to Reddit post action rows.
  • Sends the current post URL to a local backend (http://127.0.0.1:3001).
  • Runs a multi-step AI pipeline to summarize discussion and viewpoints.
  • Renders results inline on Reddit.
  • Stores the latest analysis in extension local storage for popup viewing.

Features

  • Inline analysis UI on Reddit
    • appears below post controls after clicking Analyze
    • persists until page reload
    • supports analyzing multiple posts on the same page
  • Structured output
    • consensus
    • main_debate
    • viewpoints (with sentiment)
    • most_heated
    • gap (missing perspective)
  • Popup support
    • latest analysis is also visible from the extension popup

Project Structure

opinion-intelligence-system/
├── backend/
│   ├── main.py              # FastAPI app (/test, /analyze)
│   ├── analyze.py           # End-to-end orchestration
│   ├── pipeline.py          # Scoring, clustering, sentiment, output shaping
│   ├── reddit_scraper.py    # Reddit scraping logic
│   └── requirements.txt
├── extension/
│   ├── manifest.json        # Chrome extension config (MV3)
│   ├── background.js        # Service worker, calls backend
│   ├── content.js           # Injects Analyze button + inline results
│   └── popup/
│       ├── popup.html
│       ├── popup.js
│       └── style.css
└── README.md

Prerequisites

  • Python 3.10+ (recommended 3.11/3.12)
  • Google Chrome (or Chromium-based browser with extension support)
  • API credentials compatible with your configured LLM endpoint

Backend Setup

From project root:

cd backend
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Create backend/.env:

OPENAI_API_KEY=your_api_key
OPENAI_API_BASE=your_api_base_url
OPENAI_MODEL=your_model_name

Run backend:

python main.py

Expected:

  • API on http://127.0.0.1:3001
  • Health check: GET http://127.0.0.1:3001/test

Extension Setup (Load Unpacked)

  1. Open chrome://extensions
  2. Turn on Developer mode
  3. Click Load unpacked
  4. Select the extension/ folder
  5. Keep backend running on 127.0.0.1:3001

How To Use

  1. Open a Reddit page (https://www.reddit.com/...)
  2. Click Analyze on a post
  3. Wait for analysis to finish
  4. View results inline under the post controls

You can click Analyze on multiple posts; each post keeps its own result panel.

API Contract

Request

POST /analyze

{
  "reddit_url": "https://www.reddit.com/r/.../comments/..."
}

Response (success)

{
  "success": true,
  "data": {
    "consensus": "...",
    "main_debate": "...",
    "viewpoints": [
      {
        "title": "Viewpoint 1",
        "summary": "...",
        "sentiment": "positive|negative|neutral"
      }
    ],
    "most_heated": "...",
    "gap": "...",
    "metadata": {
      "reddit_url": "...",
      "post_title": "...",
      "total_comments_analyzed": 0,
      "num_clusters": 0
    }
  }
}

Response (error)

{
  "success": false,
  "error": "error message"
}

About

Chrome extension + AI backend that analyzes Reddit threads and surfaces structured opinion insights — consensus, debates, viewpoints, and missing perspectives — directly on the page.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages