How prithwin55/insightanywhere works
1. High-level shape
The repo is split into two major runtime parts: a Chrome extension for user interaction and page capture, and a Python AI backend that performs retrieval-augmented answering. The design is intentionally stateless: each query is handled against the currently viewed page/video context without long-term storage.
2. Chrome extension UI layer
The chrome-extension/ folder contains the user-facing surface:
- popup.html, popup.js, and styles.css implement the lightweight chat UI shown in the browser.
- manifest.json defines the extension entry points and permissions.
This layer is responsible for collecting the user’s question and displaying answers, not for doing the AI work itself.
3. Extension orchestration layer
chrome-extension/background.js is the likely bridge between the popup and the current tab. In an architecture diagram, treat it as the coordination point that can:
- inspect the active page,
- capture page/YouTube context,
- forward the query plus context to the backend,
- return the generated answer to the popup.
4. Page and video context extraction
The product supports two context sources:
- regular webpages, where readable page text is extracted,
- YouTube pages, where title/description and optionally transcript data are used.
This context capture happens close to the browser runtime so the backend receives only the relevant content for the current tab.
5. Python backend boundary
server.py is the backend entry point and likely exposes an HTTP API used by the extension. It is the boundary between browser-side context collection and the AI pipeline. The extension should be viewed as a client of this service.
6. Retrieval-Augmented Generation pipeline
The README describes the core backend behavior: the input page/video content is processed per request, then split into chunks, embedded, and retrieved against the user’s question before generating the final answer. The important architectural point is that answering is context-conditioned rather than relying on a global knowledge store.
7. Model and prompt layer
llm.py and prompts.py separate the language-model call path from prompt construction. That means the backend likely has a clean split between:
- prompt templates/instructions,
- LLM invocation,
- retrieval results assembled into the final answer.
This helps keep the AI logic isolated from server and extraction logic.
8. Utility/helper layer
helper.py appears to hold shared backend utilities, such as text cleaning, chunking, formatting, or other support logic used by server.py and llm.py. In a diagram, this is a supporting internal module rather than a major subsystem.
9. Data flow end to end
The main request flow is:
- user asks a question in the popup,
- the extension identifies the active page/video,
- context is sent to the Python backend,
- the backend chunks and embeds the context,
- relevant chunks are retrieved,
- the LLM generates an answer,
- the answer is returned to the popup for display.
10. State and persistence boundary
The system explicitly avoids persistent storage and history mixing. That means there is no central document database or user memory layer in the architecture. Each request is isolated to the current page/video context, which simplifies the diagram: no long-lived indexing service is required.
11. Operational/runtime boundary
The repo combines browser-side JavaScript and a Python service. The extension runs inside Chrome, while the AI pipeline runs in Python with dependencies listed in requirements.txt. That dependency split is the main deployment boundary to show.
12. What matters most for the diagram
The key boxes are:
- Chrome extension UI,
- background/orchestration script,
- context extraction from page/YouTube,
- Python backend API,
- RAG/LLM pipeline,
- utility/prompt modules.
The main arrows should show questions and page context flowing from the browser to the backend, and answers flowing back to the popup.
Main entry points: background.js Background Bridge · server.py API Server · popup.js Popup Logic · popup.html Popup UI
Components 12
Chrome Extension
Browser-side UI and page-context capture runtime.
- Manifest · Extension entry points, permissions, and runtime wiring.
chrome-extension/manifest.json - Popup UI · Lightweight chat surface shown in the browser.
chrome-extension/popup.html - Popup Logic · Handles user input and renders answers in the popup.
chrome-extension/popup.js - Background Bridge · Bridges the popup, active tab context, and backend request.
chrome-extension/background.js - Page Context · Collects readable text from regular webpages.
- YouTube Context · Collects title, description, and optional transcript data.
- Styles · Popup presentation and layout styling.
chrome-extension/styles.css
Python Backend
Stateless request-time AI service and RAG pipeline.
- API Server · HTTP boundary between the extension and the AI pipeline.
server.py - RAG Flow · Per-request chunking, embedding, retrieval, and answer assembly.
- Prompts · Builds instructions and response framing for the model.
prompts.py - LLM Call · Invokes the language model to generate the final answer.
llm.py - Helpers · Common backend support for cleaning, chunking, and formatting.
helper.py
Connections 14
- Manifest → Popup UI: declares · Registers the popup as the user-facing extension surface.
- Popup UI → Popup Logic: driven by · Popup markup is controlled by popup logic.
- Popup Logic → Background Bridge: sends question · User questions are handed off to the background script.
- Background Bridge → Page Context: extracts · Reads text from the active webpage.
- Background Bridge → YouTube Context: extracts · Reads video-specific context when on YouTube pages.
- Background Bridge → API Server: requests answer · Forwards question plus current-tab context to the backend.
- Background Bridge → Styles: uses · Popup presentation is styled separately from behavior.
- API Server → RAG Flow: orchestrates · Backend entrypoint coordinates the per-request RAG flow.
- RAG Flow → Helpers: uses · Shared helpers support cleaning, chunking, and formatting.
- RAG Flow → Prompts: builds prompt · Retrieval output is packaged with prompt instructions.
- RAG Flow → LLM Call: generates answer · The model produces the final context-conditioned response.
- LLM Call → Prompts: consumes · Model invocation depends on the constructed prompt.
- API Server → Helpers: validates · Helpers support request handling and input preparation.
- Popup Logic → API Server: receives answer · Returned answers flow back through the extension UI.