# cobanov/websum architecture

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

- Interactive diagram: https://gitdiagram.com/cobanov/websum
- Repository: https://github.com/cobanov/websum

## Overview

websum is a Python library for summarizing web pages and YouTube videos, with translation, pluggable model backends, a CLI, and a Gradio UI. The main flow accepts a URL, detects its source, loads page content or a video transcript, then summarizes it; long transcripts are chunked before map-reduce summarization. The same Summarizer API powers the CLI and UI. Edges reflect calls visible in sampled source or capabilities explicitly documented in the README; no storage layer is present.

Main entry points: [`src/websum/summarizer.py`](https://github.com/cobanov/websum/blob/main/src/websum/summarizer.py) (Summarizer), [`src/websum/cli.py`](https://github.com/cobanov/websum/blob/main/src/websum/cli.py) (CLI), [`src/websum/backends.py`](https://github.com/cobanov/websum/blob/main/src/websum/backends.py) (Backend protocol), [`src/websum/__init__.py`](https://github.com/cobanov/websum/blob/main/src/websum/__init__.py) (Public API exports)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_cli["CLI<br/>[cli.py]"]
  node_ui["Gradio UI<br/>[webui.py]"]
end

subgraph group_core["Summarization core"]
  node_summarizer["Summarizer<br/>[summarizer.py]"]
  node_prompts["Prompt templates<br/>[prompts.py]"]
  node_exceptions["Domain errors<br/>[exceptions.py]"]
  node_version["Version metadata<br/>[__version__.py]"]
  node_api_exports["Public API exports<br/>[__init__.py]"]
end

subgraph group_ingest["Content ingestion"]
  node_url_detect["YouTube detection<br/>[loaders.py]"]
  node_web_loader["Web page loader<br/>[loaders.py]"]
  node_transcript_loader["Transcript loader<br/>[loaders.py]"]
end

subgraph group_models["Model backends"]
  node_backend_protocol["Backend protocol<br/>[backends.py]"]
  node_ollama["Ollama backend<br/>[backends.py]"]
  node_openai["OpenAI backend<br/>[backends.py]"]
end

node_user(("User"))
node_web_source(("Web pages"))
node_youtube_source(("YouTube transcripts"))
node_custom_backend["Custom backend"]
node_local_model(("Ollama service"))
node_openai_service(("OpenAI service"))

node_user -->|"runs commands"| node_cli
node_user -->|"uses browser UI"| node_ui
node_user -->|"calls API"| node_summarizer
node_cli -->|"creates and calls"| node_summarizer
node_cli -->|"selects backend"| node_ollama
node_cli -->|"selects backend"| node_openai
node_cli -->|"launches"| node_ui
node_ui -->|"calls summarize and translate"| node_summarizer
node_summarizer -->|"detects source"| node_url_detect
node_summarizer -->|"loads page"| node_web_loader
node_summarizer -->|"loads transcript"| node_transcript_loader
node_web_source -->|"provides page"| node_web_loader
node_youtube_source -->|"provides transcript"| node_transcript_loader
node_summarizer -->|"uses templates"| node_prompts
node_summarizer -->|"builds model"| node_backend_protocol
node_ollama -->|"implements"| node_backend_protocol
node_openai -->|"implements"| node_backend_protocol
node_custom_backend -->|"satisfies protocol"| node_backend_protocol
node_ollama -->|"connects to"| node_local_model
node_openai -->|"calls model service"| node_openai_service
node_api_exports -->|"re-exports API"| node_summarizer
node_api_exports -->|"re-exports API"| node_backend_protocol
node_api_exports -->|"re-exports version"| node_version

click node_cli "https://github.com/cobanov/websum/blob/main/src/websum/cli.py"
click node_ui "https://github.com/cobanov/websum/blob/main/src/websum/webui.py"
click node_summarizer "https://github.com/cobanov/websum/blob/main/src/websum/summarizer.py"
click node_prompts "https://github.com/cobanov/websum/blob/main/src/websum/prompts.py"
click node_exceptions "https://github.com/cobanov/websum/blob/main/src/websum/exceptions.py"
click node_url_detect "https://github.com/cobanov/websum/blob/main/src/websum/loaders.py"
click node_web_loader "https://github.com/cobanov/websum/blob/main/src/websum/loaders.py"
click node_transcript_loader "https://github.com/cobanov/websum/blob/main/src/websum/loaders.py"
click node_backend_protocol "https://github.com/cobanov/websum/blob/main/src/websum/backends.py"
click node_ollama "https://github.com/cobanov/websum/blob/main/src/websum/backends.py"
click node_openai "https://github.com/cobanov/websum/blob/main/src/websum/backends.py"
click node_version "https://github.com/cobanov/websum/blob/main/src/websum/__version__.py"
click node_api_exports "https://github.com/cobanov/websum/blob/main/src/websum/__init__.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_cli,node_ui,node_user toneBlue
class node_summarizer,node_prompts,node_exceptions,node_version,node_api_exports toneAmber
class node_url_detect,node_web_loader,node_transcript_loader toneMint
class node_backend_protocol,node_ollama,node_openai toneRose
class node_web_source,node_youtube_source,node_custom_backend,node_local_model,node_openai_service toneIndigo
```

## Components

### User interfaces

- [CLI](https://github.com/cobanov/websum/blob/main/src/websum/cli.py): `src/websum/cli.py`
- [Gradio UI](https://github.com/cobanov/websum/blob/main/src/websum/webui.py): `src/websum/webui.py`

### Summarization core

- [Summarizer](https://github.com/cobanov/websum/blob/main/src/websum/summarizer.py): `src/websum/summarizer.py`
- [Prompt templates](https://github.com/cobanov/websum/blob/main/src/websum/prompts.py): `src/websum/prompts.py`
- [Domain errors](https://github.com/cobanov/websum/blob/main/src/websum/exceptions.py): `src/websum/exceptions.py`
- [Version metadata](https://github.com/cobanov/websum/blob/main/src/websum/__version__.py): `src/websum/__version__.py`
- [Public API exports](https://github.com/cobanov/websum/blob/main/src/websum/__init__.py): `src/websum/__init__.py`

### Content ingestion

- [YouTube detection](https://github.com/cobanov/websum/blob/main/src/websum/loaders.py): `src/websum/loaders.py`
- [Web page loader](https://github.com/cobanov/websum/blob/main/src/websum/loaders.py): `src/websum/loaders.py`
- [Transcript loader](https://github.com/cobanov/websum/blob/main/src/websum/loaders.py): `src/websum/loaders.py`

### Model backends

- [Backend protocol](https://github.com/cobanov/websum/blob/main/src/websum/backends.py): `src/websum/backends.py`
- [Ollama backend](https://github.com/cobanov/websum/blob/main/src/websum/backends.py): `src/websum/backends.py`
- [OpenAI backend](https://github.com/cobanov/websum/blob/main/src/websum/backends.py): `src/websum/backends.py`

### Other components

- **User**
- **Web pages**
- **YouTube transcripts**
- **Custom backend**
- **Ollama service**
- **OpenAI service**

## Connections

- User → CLI: runs commands (evidence: `README.md`)
- User → Gradio UI: uses browser UI (evidence: `README.md`)
- User → Summarizer: calls API (evidence: `README.md`)
- CLI → Summarizer: creates and calls (evidence: `src/websum/cli.py`)
- CLI → Ollama backend: selects backend (evidence: `src/websum/cli.py`)
- CLI → OpenAI backend: selects backend (evidence: `src/websum/cli.py`)
- CLI → Gradio UI: launches (evidence: `src/websum/cli.py`)
- Gradio UI → Summarizer: calls summarize and translate (evidence: `src/websum/webui.py`)
- Summarizer → YouTube detection: detects source (evidence: `src/websum/summarizer.py`)
- Summarizer → Web page loader: loads page (evidence: `src/websum/summarizer.py`)
- Summarizer → Transcript loader: loads transcript (evidence: `src/websum/summarizer.py`)
- Web pages → Web page loader: provides page (evidence: `README.md`)
- YouTube transcripts → Transcript loader: provides transcript (evidence: `README.md`)
- Summarizer → Prompt templates: uses templates (evidence: `src/websum/summarizer.py`)
- Summarizer → Backend protocol: builds model (evidence: `src/websum/summarizer.py`)
- Ollama backend → Backend protocol: implements (evidence: `src/websum/backends.py`)
- OpenAI backend → Backend protocol: implements (evidence: `src/websum/backends.py`)
- Custom backend → Backend protocol: satisfies protocol (evidence: `README.md`)
- Ollama backend → Ollama service: connects to (evidence: `src/websum/backends.py`)
- OpenAI backend → OpenAI service: calls model service (evidence: `README.md`)
- Public API exports → Summarizer: re-exports API (evidence: `src/websum/__init__.py`)
- Public API exports → Backend protocol: re-exports API (evidence: `src/websum/__init__.py`)
- Public API exports → Version metadata: re-exports version (evidence: `src/websum/__init__.py`)
