# tanisha-s0212/web_search architecture

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

- Interactive diagram: https://gitdiagram.com/tanisha-s0212/web_search
- Repository: https://github.com/tanisha-s0212/web_search

## Overview

Web search is a Streamlit app: a user submits a question, chooses search engines and result limits, and receives links plus readable, website-attributed excerpts. The frontend manages chat history and delegates searching and page extraction to the backend pipeline; the search adapters query DuckDuckGo by default, with optional Brave and Google CSE. Extraction fetches result pages, derives readable text, and labels sources. The graph follows sampled calls and README capabilities; optional integrations are shown separately, and unsampled implementation details are not inferred.

Main entry points: [`backend/pipeline.py`](https://github.com/tanisha-s0212/web_search/blob/main/backend/pipeline.py) (Search and extract), [`frontend/app.py`](https://github.com/tanisha-s0212/web_search/blob/main/frontend/app.py) (Chat and history), [`backend/search/__init__.py`](https://github.com/tanisha-s0212/web_search/blob/main/backend/search/__init__.py) (Engine selection), [`backend/extract/cite.py`](https://github.com/tanisha-s0212/web_search/blob/main/backend/extract/cite.py) (URL and website labels)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Search interface"]
  node_app["Chat and history<br/>[app.py]"]
  node_ui["Result presentation<br/>[ui.py]"]
  node_entry["Streamlit entry<br/>[streamlit_app.py]"]
end

subgraph group_orchestration["Search orchestration"]
  node_settings["Runtime settings<br/>[config.py]"]
  node_pipeline["Search and extract<br/>[pipeline.py]"]
  node_models["Search data models<br/>[models.py]"]
end

subgraph group_search["Search providers"]
  node_registry["Engine selection<br/>[__init__.py]"]
  node_duckduckgo["DuckDuckGo adapter<br/>[duckduckgo.py]"]
  node_brave["Brave adapter<br/>[brave.py]"]
  node_google["Google CSE adapter<br/>[google_cse.py]"]
end

subgraph group_extraction["Page extraction"]
  node_fetcher["HTML fetching<br/>[fetcher.py]"]
  node_readability["Readable text extraction<br/>[readability.py]"]
  node_citation["URL and website labels<br/>[cite.py]"]
end

node_user(("Questioner"))
node_search_web{{"Search services"}}
node_pages{{"Public result pages"}}

node_user -->|"asks question"| node_app
node_entry -->|"starts"| node_app
node_app -->|"renders results"| node_ui
node_app -->|"loads settings"| node_settings
node_app -->|"lists engines"| node_registry
node_app -->|"searches and extracts"| node_pipeline
node_pipeline -->|"loads settings"| node_settings
node_pipeline -->|"selects engines"| node_registry
node_registry -->|"registers"| node_duckduckgo
node_registry -->|"registers optionally"| node_brave
node_registry -->|"registers optionally"| node_google
node_pipeline -->|"fetches pages"| node_fetcher
node_pipeline -->|"extracts text"| node_readability
node_pipeline -->|"normalizes URLs"| node_citation
node_pipeline -->|"builds results"| node_models
node_duckduckgo -->|"queries"| node_search_web
node_brave -->|"queries"| node_search_web
node_google -->|"queries"| node_search_web
node_duckduckgo -->|"labels websites"| node_citation
node_brave -->|"labels websites"| node_citation
node_google -->|"labels websites"| node_citation
node_fetcher -->|"requests HTML"| node_pages

click node_app "https://github.com/tanisha-s0212/web_search/blob/main/frontend/app.py"
click node_ui "https://github.com/tanisha-s0212/web_search/blob/main/frontend/ui.py"
click node_entry "https://github.com/tanisha-s0212/web_search/blob/main/streamlit_app.py"
click node_settings "https://github.com/tanisha-s0212/web_search/blob/main/backend/config.py"
click node_pipeline "https://github.com/tanisha-s0212/web_search/blob/main/backend/pipeline.py"
click node_models "https://github.com/tanisha-s0212/web_search/blob/main/backend/models.py"
click node_registry "https://github.com/tanisha-s0212/web_search/blob/main/backend/search/__init__.py"
click node_duckduckgo "https://github.com/tanisha-s0212/web_search/blob/main/backend/search/duckduckgo.py"
click node_brave "https://github.com/tanisha-s0212/web_search/blob/main/backend/search/brave.py"
click node_google "https://github.com/tanisha-s0212/web_search/blob/main/backend/search/google_cse.py"
click node_fetcher "https://github.com/tanisha-s0212/web_search/blob/main/backend/extract/fetcher.py"
click node_readability "https://github.com/tanisha-s0212/web_search/blob/main/backend/extract/readability.py"
click node_citation "https://github.com/tanisha-s0212/web_search/blob/main/backend/extract/cite.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_app,node_ui,node_entry toneBlue
class node_settings,node_pipeline,node_models toneAmber
class node_registry,node_duckduckgo,node_brave,node_google toneMint
class node_fetcher,node_readability,node_citation toneRose
class node_user,node_search_web,node_pages toneIndigo
```

## Components

### Search interface

- [Chat and history](https://github.com/tanisha-s0212/web_search/blob/main/frontend/app.py): `frontend/app.py`
- [Result presentation](https://github.com/tanisha-s0212/web_search/blob/main/frontend/ui.py): `frontend/ui.py`
- [Streamlit entry](https://github.com/tanisha-s0212/web_search/blob/main/streamlit_app.py): `streamlit_app.py`

### Search orchestration

- [Runtime settings](https://github.com/tanisha-s0212/web_search/blob/main/backend/config.py): `backend/config.py`
- [Search and extract](https://github.com/tanisha-s0212/web_search/blob/main/backend/pipeline.py): `backend/pipeline.py`
- [Search data models](https://github.com/tanisha-s0212/web_search/blob/main/backend/models.py): `backend/models.py`

### Search providers

- [Engine selection](https://github.com/tanisha-s0212/web_search/blob/main/backend/search/__init__.py): `backend/search/__init__.py`
- [DuckDuckGo adapter](https://github.com/tanisha-s0212/web_search/blob/main/backend/search/duckduckgo.py): `backend/search/duckduckgo.py`
- [Brave adapter](https://github.com/tanisha-s0212/web_search/blob/main/backend/search/brave.py): `backend/search/brave.py`
- [Google CSE adapter](https://github.com/tanisha-s0212/web_search/blob/main/backend/search/google_cse.py): `backend/search/google_cse.py`

### Page extraction

- [HTML fetching](https://github.com/tanisha-s0212/web_search/blob/main/backend/extract/fetcher.py): `backend/extract/fetcher.py`
- [Readable text extraction](https://github.com/tanisha-s0212/web_search/blob/main/backend/extract/readability.py): `backend/extract/readability.py`
- [URL and website labels](https://github.com/tanisha-s0212/web_search/blob/main/backend/extract/cite.py): `backend/extract/cite.py`

### Other components

- **Questioner**
- **Search services**
- **Public result pages**

## Connections

- Questioner → Chat and history: asks question (evidence: `README.md`)
- Streamlit entry → Chat and history: starts (evidence: `streamlit_app.py`)
- Chat and history → Result presentation: renders results (evidence: `frontend/app.py`)
- Chat and history → Runtime settings: loads settings (evidence: `frontend/app.py`)
- Chat and history → Engine selection: lists engines (evidence: `frontend/app.py`)
- Chat and history → Search and extract: searches and extracts (evidence: `frontend/app.py`)
- Search and extract → Runtime settings: loads settings (evidence: `backend/pipeline.py`)
- Search and extract → Engine selection: selects engines (evidence: `backend/pipeline.py`)
- Engine selection → DuckDuckGo adapter: registers (evidence: `backend/search/__init__.py`)
- Engine selection → Brave adapter: registers optionally (evidence: `backend/search/__init__.py`)
- Engine selection → Google CSE adapter: registers optionally (evidence: `backend/search/__init__.py`)
- Search and extract → HTML fetching: fetches pages (evidence: `backend/pipeline.py`)
- Search and extract → Readable text extraction: extracts text (evidence: `backend/pipeline.py`)
- Search and extract → URL and website labels: normalizes URLs (evidence: `backend/pipeline.py`)
- Search and extract → Search data models: builds results (evidence: `backend/pipeline.py`)
- DuckDuckGo adapter → Search services: queries (evidence: `backend/search/duckduckgo.py`)
- Brave adapter → Search services: queries (evidence: `backend/search/brave.py`)
- Google CSE adapter → Search services: queries (evidence: `backend/search/google_cse.py`)
- DuckDuckGo adapter → URL and website labels: labels websites (evidence: `backend/search/duckduckgo.py`)
- Brave adapter → URL and website labels: labels websites (evidence: `backend/search/brave.py`)
- Google CSE adapter → URL and website labels: labels websites (evidence: `backend/search/google_cse.py`)
- HTML fetching → Public result pages: requests HTML (evidence: `backend/extract/fetcher.py`)
