# arseglaz/competetive-search-bot architecture

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

- Interactive diagram: https://gitdiagram.com/arseglaz/competetive-search-bot
- Repository: https://github.com/arseglaz/competetive-search-bot

## Overview

Competitive Search Bot accepts Telegram text queries, searches Wikipedia, GitHub, and Stack Overflow concurrently, then returns a combined message that identifies unavailable sources when a provider fails. The graph captures configuration and polling setup, query handling and formatting, provider orchestration, source integrations, and result models. Relationships are based on the shown entry point and excerpts, plus README capability statements; unsampled handler registration and start/help behavior are not expanded beyond documented behavior.

Main entry points: [`bot/services/search_service.py`](https://github.com/arseglaz/competetive-search-bot/blob/main/bot/services/search_service.py) (Concurrent search service), [`bot/__main__.py`](https://github.com/arseglaz/competetive-search-bot/blob/main/bot/__main__.py) (Polling application), [`bot/handlers/search.py`](https://github.com/arseglaz/competetive-search-bot/blob/main/bot/handlers/search.py) (Search handler), [`bot/models/search_result.py`](https://github.com/arseglaz/competetive-search-bot/blob/main/bot/models/search_result.py) (Search result)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and configuration"]
  node_settings["Settings<br/>[config.py]"]
  node_app["Polling application<br/>[__main__.py]"]
end

subgraph group_telegram["Telegram interaction"]
  node_search_handler["Search handler<br/>[search.py]"]
  node_start_help["Start and help handlers<br/>[start_help.py]"]
end

subgraph group_search["Search orchestration"]
  node_search_service["Concurrent search service<br/>[search_service.py]"]
end

subgraph group_providers["Search providers"]
  node_wikipedia["Wikipedia provider<br/>[wikipedia.py]"]
  node_github["GitHub provider<br/>[github.py]"]
  node_stackoverflow["Stack Overflow provider<br/>[stackoverflow.py]"]
  node_provider_error["Provider errors<br/>[errors.py]"]
end

subgraph group_models["Result models and logging"]
  node_search_result["Search result<br/>[search_result.py]"]
  node_search_response["Search response<br/>[search_response.py]"]
  node_request_logging["Request logging context<br/>[request_logging.py]"]
  node_logging_config["Logging configuration<br/>[logging_config.py]"]
end

node_telegram_user(("Telegram user"))
node_telegram_api["Telegram API"]
node_wikipedia_api["Wikipedia API"]
node_github_api["GitHub API"]
node_stackoverflow_api["Stack Exchange API"]

node_telegram_user -->|"sends query"| node_telegram_api
node_telegram_api -->|"delivers updates"| node_app
node_app -->|"loads"| node_settings
node_app -->|"configures"| node_logging_config
node_app -->|"constructs"| node_wikipedia
node_app -->|"constructs"| node_github
node_app -->|"constructs"| node_stackoverflow
node_app -->|"constructs"| node_search_service
node_app -->|"registers routers"| node_search_handler
node_search_handler -->|"searches query"| node_search_service
node_search_handler -->|"formats results"| node_search_result
node_search_handler -->|"formats response"| node_search_response
node_search_handler -->|"sends reply"| node_telegram_api
node_telegram_api -.->|"routes commands"| node_start_help
node_search_service -->|"dispatches search"| node_wikipedia
node_search_service -->|"dispatches search"| node_github
node_search_service -->|"dispatches search"| node_stackoverflow
node_search_service -->|"aggregates results"| node_search_result
node_search_service -->|"builds response"| node_search_response
node_search_service -->|"handles failures"| node_provider_error
node_search_service -->|"sets context"| node_request_logging
node_search_handler -->|"sets context"| node_request_logging
node_wikipedia -->|"requests search"| node_wikipedia_api
node_github -->|"requests search"| node_github_api
node_stackoverflow -->|"requests search"| node_stackoverflow_api
node_wikipedia -->|"maps results"| node_search_result
node_github -->|"maps results"| node_search_result
node_stackoverflow -->|"maps results"| node_search_result
node_wikipedia -->|"raises failures"| node_provider_error
node_github -->|"raises failures"| node_provider_error
node_stackoverflow -->|"raises failures"| node_provider_error
node_search_response -->|"contains results"| node_search_result
node_logging_config -->|"reads log settings"| node_settings

click node_settings "https://github.com/arseglaz/competetive-search-bot/blob/main/bot/config.py"
click node_app "https://github.com/arseglaz/competetive-search-bot/blob/main/bot/__main__.py"
click node_search_handler "https://github.com/arseglaz/competetive-search-bot/blob/main/bot/handlers/search.py"
click node_start_help "https://github.com/arseglaz/competetive-search-bot/blob/main/bot/handlers/start_help.py"
click node_search_service "https://github.com/arseglaz/competetive-search-bot/blob/main/bot/services/search_service.py"
click node_wikipedia "https://github.com/arseglaz/competetive-search-bot/blob/main/bot/providers/wikipedia.py"
click node_github "https://github.com/arseglaz/competetive-search-bot/blob/main/bot/providers/github.py"
click node_stackoverflow "https://github.com/arseglaz/competetive-search-bot/blob/main/bot/providers/stackoverflow.py"
click node_provider_error "https://github.com/arseglaz/competetive-search-bot/blob/main/bot/providers/errors.py"
click node_search_result "https://github.com/arseglaz/competetive-search-bot/blob/main/bot/models/search_result.py"
click node_search_response "https://github.com/arseglaz/competetive-search-bot/blob/main/bot/models/search_response.py"
click node_request_logging "https://github.com/arseglaz/competetive-search-bot/blob/main/bot/request_logging.py"
click node_logging_config "https://github.com/arseglaz/competetive-search-bot/blob/main/bot/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_settings,node_app,node_telegram_user toneBlue
class node_search_handler,node_start_help toneAmber
class node_search_service,node_telegram_api,node_wikipedia_api,node_github_api,node_stackoverflow_api toneMint
class node_wikipedia,node_github,node_stackoverflow,node_provider_error toneRose
class node_search_result,node_search_response,node_request_logging,node_logging_config toneIndigo
```

## Components

### Runtime and configuration

- [Settings](https://github.com/arseglaz/competetive-search-bot/blob/main/bot/config.py): `bot/config.py`
- [Polling application](https://github.com/arseglaz/competetive-search-bot/blob/main/bot/__main__.py): `bot/__main__.py`

### Telegram interaction

- [Search handler](https://github.com/arseglaz/competetive-search-bot/blob/main/bot/handlers/search.py): `bot/handlers/search.py`
- [Start and help handlers](https://github.com/arseglaz/competetive-search-bot/blob/main/bot/handlers/start_help.py): `bot/handlers/start_help.py`

### Search orchestration

- [Concurrent search service](https://github.com/arseglaz/competetive-search-bot/blob/main/bot/services/search_service.py): `bot/services/search_service.py`

### Search providers

- [Wikipedia provider](https://github.com/arseglaz/competetive-search-bot/blob/main/bot/providers/wikipedia.py): `bot/providers/wikipedia.py`
- [GitHub provider](https://github.com/arseglaz/competetive-search-bot/blob/main/bot/providers/github.py): `bot/providers/github.py`
- [Stack Overflow provider](https://github.com/arseglaz/competetive-search-bot/blob/main/bot/providers/stackoverflow.py): `bot/providers/stackoverflow.py`
- [Provider errors](https://github.com/arseglaz/competetive-search-bot/blob/main/bot/providers/errors.py): `bot/providers/errors.py`

### Result models and logging

- [Search result](https://github.com/arseglaz/competetive-search-bot/blob/main/bot/models/search_result.py): `bot/models/search_result.py`
- [Search response](https://github.com/arseglaz/competetive-search-bot/blob/main/bot/models/search_response.py): `bot/models/search_response.py`
- [Request logging context](https://github.com/arseglaz/competetive-search-bot/blob/main/bot/request_logging.py): `bot/request_logging.py`
- [Logging configuration](https://github.com/arseglaz/competetive-search-bot/blob/main/bot/logging_config.py): `bot/logging_config.py`

### Other components

- **Telegram user**
- **Telegram API**
- **Wikipedia API**
- **GitHub API**
- **Stack Exchange API**

## Connections

- Telegram user → Telegram API: sends query (evidence: `README.md`)
- Telegram API → Polling application: delivers updates (evidence: `README.md`)
- Polling application → Settings: loads (evidence: `bot/__main__.py`)
- Polling application → Logging configuration: configures (evidence: `bot/__main__.py`)
- Polling application → Wikipedia provider: constructs (evidence: `bot/__main__.py`)
- Polling application → GitHub provider: constructs (evidence: `bot/__main__.py`)
- Polling application → Stack Overflow provider: constructs (evidence: `bot/__main__.py`)
- Polling application → Concurrent search service: constructs (evidence: `bot/__main__.py`)
- Polling application → Search handler: registers routers (evidence: `bot/__main__.py`)
- Search handler → Concurrent search service: searches query (evidence: `bot/handlers/search.py`)
- Search handler → Search result: formats results (evidence: `bot/handlers/search.py`)
- Search handler → Search response: formats response (evidence: `bot/handlers/search.py`)
- Search handler → Telegram API: sends reply (evidence: `bot/handlers/search.py`)
- Telegram API → Start and help handlers: routes commands (evidence: `README.md`)
- Concurrent search service → Wikipedia provider: dispatches search (evidence: `bot/services/search_service.py`)
- Concurrent search service → GitHub provider: dispatches search (evidence: `bot/services/search_service.py`)
- Concurrent search service → Stack Overflow provider: dispatches search (evidence: `bot/services/search_service.py`)
- Concurrent search service → Search result: aggregates results (evidence: `bot/services/search_service.py`)
- Concurrent search service → Search response: builds response (evidence: `bot/services/search_service.py`)
- Concurrent search service → Provider errors: handles failures (evidence: `bot/services/search_service.py`)
- Concurrent search service → Request logging context: sets context (evidence: `bot/services/search_service.py`)
- Search handler → Request logging context: sets context (evidence: `bot/handlers/search.py`)
- Wikipedia provider → Wikipedia API: requests search (evidence: `bot/providers/wikipedia.py`)
- GitHub provider → GitHub API: requests search (evidence: `bot/providers/github.py`)
- Stack Overflow provider → Stack Exchange API: requests search (evidence: `bot/providers/stackoverflow.py`)
- Wikipedia provider → Search result: maps results (evidence: `bot/providers/wikipedia.py`)
- GitHub provider → Search result: maps results (evidence: `bot/providers/github.py`)
- Stack Overflow provider → Search result: maps results (evidence: `bot/providers/stackoverflow.py`)
- Wikipedia provider → Provider errors: raises failures (evidence: `bot/providers/wikipedia.py`)
- GitHub provider → Provider errors: raises failures (evidence: `bot/providers/github.py`)
- Stack Overflow provider → Provider errors: raises failures (evidence: `bot/providers/stackoverflow.py`)
- Search response → Search result: contains results (evidence: `bot/models/search_response.py`)
- Logging configuration → Settings: reads log settings (evidence: `bot/logging_config.py`)
