ContextLens is a Chrome extension and local FastAPI backend that helps users inspect news screenshots, extract the text, search for source context, and return an evidence-focused summary.
firstspark/
backend/
ocr.py # FastAPI OCR and context-analysis API
context_analyzer.py # OpenAI source-context analysis
chrome-extension/
src/ # React extension source
public/manifest.json # Manifest copied into builds
dist/ # Built extension loaded by Chrome
requirements.txt # Python backend dependencies
.env # Local environment variables
- Python 3.11+ recommended
- Node.js 20+ recommended
- Google Chrome
- An OpenAI API key
From the project root
Create and activate a virtual environment:
python -m venv venv
.\venv\Scripts\Activate.ps1Install Python dependencies:
pip install -r requirements.txtCreate or update .env in the project root:
OPENAI_API_KEY=your_openai_api_key_hereStart the backend server:
uvicorn backend.ocr:app --host 127.0.0.1 --port 8000 --reloadCheck that the backend is running:
curl http://localhost:8000/healthExpected response:
{"status":"ok"}The extension sends image OCR requests to:
http://localhost:8000/ocr
Keep this terminal open while using the extension.
Open a second terminal:
Install frontend dependencies:
npm installBuild the extension:
npm run buildThis creates or updates:
chrome-extension/dist/
- Open Chrome.
- Go to:
chrome://extensions
- Turn on Developer mode in the top-right corner.
- Click Load unpacked.
- Select this folder:
*\dist
- Pin ContextLens from the Chrome extensions menu if you want easy access.
- Make sure the backend server is still running on
localhost:8000. - Click the ContextLens extension icon in Chrome.
- Upload a screenshot or paste an image URL.
- Click Extract context.
- Wait for the extension to:
- extract text from the image,
- identify the main claim,
- search for original source context,
- compare the screenshot with the fuller context,
- return a visual evidence summary.
Backend:
uvicorn backend.ocr:app --host 127.0.0.1 --port 8000 --reloadBuild extension for Chrome:
npm run buildType-check extension:
npm run type-checkMake sure the backend is running:
curl http://localhost:8000/healthIf it is not running, restart:
uvicorn backend.ocr:app --host 127.0.0.1 --port 8000 --reloadCheck that .env exists in the project root and contains:
OPENAI_API_KEY=your_openai_api_key_hereThen stop and restart the backend server.
After editing frontend code:
npm run buildThen go to chrome://extensions and click the reload button on the ContextLens extension card.
Stop the process using port 8000, or run the backend on another port and update API_URL in:
chrome-extension/src/background.ts
Then rebuild and reload the extension.
- The backend uses PaddleOCR for text extraction and OpenAI for source-context analysis.
- The Chrome extension is configured for Manifest V3.
- The built extension folder to load into Chrome is
chrome-extension/dist, notchrome-extension/src.