# tarekulislam03/nexus architecture

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

- Interactive diagram: https://gitdiagram.com/tarekulislam03/nexus
- Repository: https://github.com/tarekulislam03/nexus

## Overview

Nexus is a web search engine: users submit a query through the browser UI, and the FastAPI application serves live-web or local-index results, with optional AI overviews. The backend also supports crawling pages into the local index, index statistics and autocomplete. Ranking, text processing, and index storage form the core retrieval layer. The excerpts show several internal calls directly; some API orchestration is omitted, so documented workflow links use the README as evidence rather than implying source inspection.

Main entry points: [`main.py`](https://github.com/tarekulislam03/nexus/blob/main/main.py) (FastAPI application), [`backend/inverted_index.py`](https://github.com/tarekulislam03/nexus/blob/main/backend/inverted_index.py) (Inverted index), [`backend/web_search.py`](https://github.com/tarekulislam03/nexus/blob/main/backend/web_search.py) (Live web search), [`backend/crawler.py`](https://github.com/tarekulislam03/nexus/blob/main/backend/crawler.py) (Page crawler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Search interface"]
  node_browser["Search UI<br/>[app.js]"]
end

subgraph group_api["API and orchestration"]
  node_api_app["FastAPI application<br/>[main.py]"]
  node_response_cache[("Search cache<br/>[main.py]")]
end

subgraph group_retrieval["Retrieval and indexing"]
  node_live_search["Live web search<br/>[web_search.py]"]
  node_local_crawler["Page crawler<br/>[crawler.py]"]
  node_ranker["BM25 and TF-IDF<br/>[ranker.py]"]
  node_index[("Inverted index<br/>[inverted_index.py]")]
  node_seed_corpus["Seed documents<br/>[seed_data.py]"]
  node_text_processor["Text processor<br/>[text_processor.py]"]
end

subgraph group_enrichment["Search enrichment"]
  node_ai_overview["AI overview<br/>[ai_summarizer.py]"]
end

node_searcher(("Search user"))
node_duckduckgo{{"DuckDuckGo"}}
node_web_pages["Web pages"]
node_openrouter{{"OpenRouter"}}
node_gemini{{"Google Gemini"}}

node_searcher -->|"submits query"| node_browser
node_browser -->|"requests search"| node_api_app
node_api_app -->|"checks cache"| node_response_cache
node_api_app -->|"fetches web results"| node_live_search
node_api_app -->|"ranks local results"| node_ranker
node_api_app -->|"generates overview"| node_ai_overview
node_api_app -->|"starts crawl"| node_local_crawler
node_api_app -->|"serves index data"| node_index
node_api_app -.->|"loads seed corpus"| node_seed_corpus
node_live_search -->|"queries"| node_duckduckgo
node_live_search -->|"fetches content"| node_web_pages
node_local_crawler -->|"fetches pages"| node_web_pages
node_local_crawler -->|"adds documents"| node_index
node_index -->|"tokenizes documents"| node_text_processor
node_ranker -->|"reads postings"| node_index
node_ranker -->|"processes queries"| node_text_processor
node_seed_corpus -->|"adds seed documents"| node_index
node_ai_overview -->|"requests summaries"| node_openrouter
node_ai_overview -.->|"uses fallback"| node_gemini

click node_browser "https://github.com/tarekulislam03/nexus/blob/main/static/app.js"
click node_api_app "https://github.com/tarekulislam03/nexus/blob/main/main.py"
click node_response_cache "https://github.com/tarekulislam03/nexus/blob/main/main.py"
click node_live_search "https://github.com/tarekulislam03/nexus/blob/main/backend/web_search.py"
click node_local_crawler "https://github.com/tarekulislam03/nexus/blob/main/backend/crawler.py"
click node_ranker "https://github.com/tarekulislam03/nexus/blob/main/backend/ranker.py"
click node_index "https://github.com/tarekulislam03/nexus/blob/main/backend/inverted_index.py"
click node_seed_corpus "https://github.com/tarekulislam03/nexus/blob/main/backend/seed_data.py"
click node_text_processor "https://github.com/tarekulislam03/nexus/blob/main/backend/text_processor.py"
click node_ai_overview "https://github.com/tarekulislam03/nexus/blob/main/backend/ai_summarizer.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_browser,node_searcher toneBlue
class node_api_app,node_response_cache toneAmber
class node_live_search,node_local_crawler,node_ranker,node_index,node_seed_corpus,node_text_processor,node_openrouter toneMint
class node_ai_overview toneRose
class node_duckduckgo,node_web_pages,node_gemini toneIndigo
```

## Components

### Search interface

- [Search UI](https://github.com/tarekulislam03/nexus/blob/main/static/app.js): `static/app.js`

### API and orchestration

- [FastAPI application](https://github.com/tarekulislam03/nexus/blob/main/main.py): `main.py`
- [Search cache](https://github.com/tarekulislam03/nexus/blob/main/main.py): `main.py`

### Retrieval and indexing

- [Live web search](https://github.com/tarekulislam03/nexus/blob/main/backend/web_search.py): `backend/web_search.py`
- [Page crawler](https://github.com/tarekulislam03/nexus/blob/main/backend/crawler.py): `backend/crawler.py`
- [BM25 and TF-IDF](https://github.com/tarekulislam03/nexus/blob/main/backend/ranker.py): `backend/ranker.py`
- [Inverted index](https://github.com/tarekulislam03/nexus/blob/main/backend/inverted_index.py): `backend/inverted_index.py`
- [Seed documents](https://github.com/tarekulislam03/nexus/blob/main/backend/seed_data.py): `backend/seed_data.py`
- [Text processor](https://github.com/tarekulislam03/nexus/blob/main/backend/text_processor.py): `backend/text_processor.py`

### Search enrichment

- [AI overview](https://github.com/tarekulislam03/nexus/blob/main/backend/ai_summarizer.py): `backend/ai_summarizer.py`

### Other components

- **Search user**
- **DuckDuckGo**
- **Web pages**
- **OpenRouter**
- **Google Gemini**

## Connections

- Search user → Search UI: submits query (evidence: `README.md`)
- Search UI → FastAPI application: requests search (evidence: `static/app.js`)
- FastAPI application → Search cache: checks cache (evidence: `main.py`)
- FastAPI application → Live web search: fetches web results (evidence: `README.md`)
- FastAPI application → BM25 and TF-IDF: ranks local results (evidence: `README.md`)
- FastAPI application → AI overview: generates overview (evidence: `README.md`)
- FastAPI application → Page crawler: starts crawl (evidence: `README.md`)
- FastAPI application → Inverted index: serves index data (evidence: `main.py`)
- FastAPI application → Seed documents: loads seed corpus (evidence: `main.py`)
- Live web search → DuckDuckGo: queries (evidence: `backend/web_search.py`)
- Live web search → Web pages: fetches content (evidence: `backend/web_search.py`)
- Page crawler → Web pages: fetches pages (evidence: `backend/crawler.py`)
- Page crawler → Inverted index: adds documents (evidence: `backend/crawler.py`)
- Inverted index → Text processor: tokenizes documents (evidence: `backend/inverted_index.py`)
- BM25 and TF-IDF → Inverted index: reads postings (evidence: `backend/ranker.py`)
- BM25 and TF-IDF → Text processor: processes queries (evidence: `backend/ranker.py`)
- Seed documents → Inverted index: adds seed documents (evidence: `backend/seed_data.py`)
- AI overview → OpenRouter: requests summaries (evidence: `backend/ai_summarizer.py`)
- AI overview → Google Gemini: uses fallback (evidence: `backend/ai_summarizer.py`)
