# junaidulhassan/webpilot-chromeextension architecture

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

- Interactive diagram: https://gitdiagram.com/junaidulhassan/webpilot-chromeextension
- Repository: https://github.com/junaidulhassan/webpilot-chromeextension

## Overview

WebPilot is a browser-extension RAG assistant for asking questions about web pages, PDFs, and YouTube videos, with conversation history and configurable model, tone, and embeddings. The main flow runs from the extension popup to the FastAPI service, which prepares source content for retrieval and streams grounded answers back. Sampled code shows FAISS rather than the README’s Chroma description, and the sampled model registry shows Google and Groq providers; unsampled details are not expanded.

Main entry points: [`Backend/backend.py`](https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/backend.py) (HTTP API), [`Backend/RAG_QnA.py`](https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG_QnA.py) (RAG chat model), [`popup/popup.js`](https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/popup/popup.js) (Extension UI), [`Backend/RAG.py`](https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG.py) (Source ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_extension["Browser extension"]
  node_popup["Extension UI<br/>[popup.js]"]
  node_conversation_store[("Conversation history<br/>[storage.js]")]
end

subgraph group_api["Backend API"]
  node_backend["HTTP API<br/>[backend.py]"]
  node_page_classify["Source detection<br/>[backend.py]"]
end

subgraph group_rag["RAG processing"]
  node_source_extract["Source ingestion<br/>[RAG.py]"]
  node_document_chunks["Document chunking<br/>[RAG.py]"]
  node_vector_index[("Vector index<br/>[RAG.py]")]
  node_qa_model["RAG chat model<br/>[RAG_QnA.py]"]
  node_retrieval["Context retrieval<br/>[RAG_QnA.py]"]
  node_chat_memory[("Chat memory<br/>[RAG_QnA.py]")]
  node_prompt["Prompt assembly<br/>[RAG_QnA.py]"]
end

subgraph group_config["Models and state"]
  node_settings["Model and tone settings<br/>[RAG_QnA.py]"]
  node_app_logging["Backend logging<br/>[logging_config.py]"]
end

node_user(("User"))
node_active_tab["Active page"]
node_youtube_transcripts["YouTube transcripts"]
node_llm["Generation providers"]
node_embedding["Embedding providers"]

node_user -->|"asks or configures"| node_popup
node_active_tab -.->|"provides page context"| node_popup
node_popup -->|"saves history"| node_conversation_store
node_popup -->|"posts page and chat"| node_backend
node_backend -->|"streams answers"| node_popup
node_backend -->|"classifies source"| node_page_classify
node_backend -->|"loads source"| node_source_extract
node_source_extract -->|"fetches transcript"| node_youtube_transcripts
node_source_extract -->|"splits documents"| node_document_chunks
node_document_chunks -->|"indexes chunks"| node_vector_index
node_backend -->|"streams response"| node_qa_model
node_qa_model -->|"retrieves context"| node_retrieval
node_retrieval -.->|"searches vectors"| node_vector_index
node_qa_model -->|"loads chat history"| node_chat_memory
node_qa_model -->|"assembles prompt"| node_prompt
node_prompt -.->|"generates answer"| node_llm
node_qa_model -.->|"builds embeddings"| node_embedding
node_backend -->|"updates settings"| node_settings
node_backend -->|"records activity"| node_app_logging
node_qa_model -->|"logs operations"| node_app_logging

click node_popup "https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/popup/popup.js"
click node_conversation_store "https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/popup/storage.js"
click node_backend "https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/backend.py"
click node_page_classify "https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/backend.py"
click node_source_extract "https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG.py"
click node_document_chunks "https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG.py"
click node_vector_index "https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG.py"
click node_qa_model "https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG_QnA.py"
click node_retrieval "https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG_QnA.py"
click node_chat_memory "https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG_QnA.py"
click node_prompt "https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG_QnA.py"
click node_settings "https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG_QnA.py"
click node_app_logging "https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/logging_config.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_popup,node_conversation_store,node_user toneBlue
class node_backend,node_page_classify toneAmber
class node_source_extract,node_document_chunks,node_vector_index,node_qa_model,node_retrieval,node_chat_memory,node_prompt toneMint
class node_settings,node_app_logging toneRose
class node_active_tab,node_youtube_transcripts,node_llm,node_embedding toneIndigo
```

## Components

### Browser extension

- [Extension UI](https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/popup/popup.js): `popup/popup.js`
- [Conversation history](https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/popup/storage.js): `popup/storage.js`

### Backend API

- [HTTP API](https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/backend.py): `Backend/backend.py`
- [Source detection](https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/backend.py): `Backend/backend.py`

### RAG processing

- [Source ingestion](https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG.py): `Backend/RAG.py`
- [Document chunking](https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG.py): `Backend/RAG.py`
- [Vector index](https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG.py): `Backend/RAG.py`
- [RAG chat model](https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG_QnA.py): `Backend/RAG_QnA.py`
- [Context retrieval](https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG_QnA.py): `Backend/RAG_QnA.py`
- [Chat memory](https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG_QnA.py): `Backend/RAG_QnA.py`
- [Prompt assembly](https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG_QnA.py): `Backend/RAG_QnA.py`

### Models and state

- [Model and tone settings](https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/RAG_QnA.py): `Backend/RAG_QnA.py`
- [Backend logging](https://github.com/junaidulhassan/webpilot-chromeextension/blob/main/Backend/logging_config.py): `Backend/logging_config.py`

### Other components

- **User**
- **Active page**
- **YouTube transcripts**
- **Generation providers**
- **Embedding providers**

## Connections

- User → Extension UI: asks or configures (evidence: `README.md`)
- Active page → Extension UI: provides page context
- Extension UI → Conversation history: saves history (evidence: `popup/popup.js`)
- Extension UI → HTTP API: posts page and chat (evidence: `popup/popup.js`)
- HTTP API → Extension UI: streams answers (evidence: `popup/popup.js`)
- HTTP API → Source detection: classifies source (evidence: `Backend/backend.py`)
- HTTP API → Source ingestion: loads source (evidence: `Backend/backend.py`)
- Source ingestion → YouTube transcripts: fetches transcript (evidence: `Backend/RAG.py`)
- Source ingestion → Document chunking: splits documents (evidence: `Backend/RAG.py`)
- Document chunking → Vector index: indexes chunks (evidence: `Backend/RAG.py`)
- HTTP API → RAG chat model: streams response (evidence: `Backend/backend.py`)
- RAG chat model → Context retrieval: retrieves context (evidence: `Backend/RAG_QnA.py`)
- Context retrieval → Vector index: searches vectors (evidence: `Backend/RAG_QnA.py`)
- RAG chat model → Chat memory: loads chat history (evidence: `Backend/RAG_QnA.py`)
- RAG chat model → Prompt assembly: assembles prompt (evidence: `Backend/RAG_QnA.py`)
- Prompt assembly → Generation providers: generates answer
- RAG chat model → Embedding providers: builds embeddings
- HTTP API → Model and tone settings: updates settings (evidence: `Backend/backend.py`)
- HTTP API → Backend logging: records activity (evidence: `Backend/backend.py`)
- RAG chat model → Backend logging: logs operations (evidence: `Backend/RAG_QnA.py`)
