# pratyushwinorlearn/news-telegram-bot architecture

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

- Interactive diagram: https://gitdiagram.com/pratyushwinorlearn/news-telegram-bot
- Repository: https://github.com/pratyushwinorlearn/news-telegram-bot

## Overview

OSINT Desk is an India-focused news board with two user-facing routes to headlines: a browser dashboard and Telegram. The dashboard selects a category, fetches paginated results through the backend, and renders articles; the backend holds the NewsData.io key and caches upstream pages. Telegram users can request category headlines interactively, while a scheduled or manually triggered digest fetches categories and sends formatted messages to a configured group. The README documents these capabilities; omitted portions of server/index.js limit certainty about some handler wiring.

Main entry points: [`server/index.js`](https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js) (Category fetch), [`server/telegram.js`](https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/telegram.js) (Digest builder), [`client/src/main.js`](https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/client/src/main.js) (Dashboard UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["News dashboard"]
  node_dashboard_ui["Dashboard UI<br/>[main.js]"]
  node_client_api["News API client<br/>[main.js]"]
end

subgraph group_backend["News backend"]
  node_server_api["HTTP API<br/>[index.js]"]
  node_news_fetch["Category fetch<br/>[index.js]"]
  node_page_cache[("Page cache<br/>[index.js]")]
  node_chat_state[("Chat pagination<br/>[index.js]")]
end

subgraph group_telegram["Telegram delivery"]
  node_webhook["Bot webhook<br/>[index.js]"]
  node_genre_menu["Genre menu<br/>[index.js]"]
  node_category_delivery["Category headlines<br/>[index.js]"]
  node_digest_route["Manual digest route<br/>[index.js]"]
  node_scheduler["Digest scheduler<br/>[index.js]"]
  node_digest_builder["Digest builder<br/>[telegram.js]"]
end

node_desk_user(("Desk user"))
node_newsdata["NewsData.io"]
node_telegram_user(("Telegram user"))
node_telegram_platform["Telegram Bot API"]
node_digest_group(("Configured digest group"))

node_desk_user -->|"uses"| node_dashboard_ui
node_dashboard_ui -->|"requests pages"| node_client_api
node_client_api -->|"calls API"| node_server_api
node_server_api -->|"requests category"| node_news_fetch
node_news_fetch -->|"reads and writes"| node_page_cache
node_news_fetch -->|"fetches articles"| node_newsdata
node_news_fetch -->|"returns results"| node_server_api
node_telegram_user -->|"messages bot"| node_telegram_platform
node_telegram_platform -->|"posts updates"| node_webhook
node_webhook -->|"dispatches greeting"| node_genre_menu
node_genre_menu -->|"sends menu"| node_telegram_platform
node_webhook -->|"dispatches selection"| node_category_delivery
node_category_delivery -->|"reads and updates"| node_chat_state
node_category_delivery -->|"fetches pages"| node_news_fetch
node_category_delivery -->|"sends headlines"| node_telegram_platform
node_server_api -->|"handles send-now"| node_digest_route
node_digest_route -->|"invokes digest"| node_digest_builder
node_scheduler -->|"runs on schedule"| node_digest_builder
node_digest_builder -->|"fetches categories"| node_news_fetch
node_digest_builder -->|"sends digest"| node_telegram_platform
node_telegram_platform -->|"delivers messages"| node_digest_group

click node_dashboard_ui "https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/client/src/main.js"
click node_client_api "https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/client/src/main.js"
click node_server_api "https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js"
click node_news_fetch "https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js"
click node_page_cache "https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js"
click node_chat_state "https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js"
click node_webhook "https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js"
click node_genre_menu "https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js"
click node_category_delivery "https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js"
click node_digest_route "https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js"
click node_scheduler "https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js"
click node_digest_builder "https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/telegram.js"

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_dashboard_ui,node_client_api,node_desk_user,node_telegram_user toneBlue
class node_server_api,node_news_fetch,node_page_cache,node_chat_state toneAmber
class node_webhook,node_genre_menu,node_category_delivery,node_digest_route,node_scheduler,node_digest_builder,node_telegram_platform toneMint
class node_newsdata,node_digest_group toneIndigo
```

## Components

### News dashboard

- [Dashboard UI](https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/client/src/main.js): `client/src/main.js`
- [News API client](https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/client/src/main.js): `client/src/main.js`

### News backend

- [HTTP API](https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js): `server/index.js`
- [Category fetch](https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js): `server/index.js`
- [Page cache](https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js): `server/index.js`
- [Chat pagination](https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js): `server/index.js`

### Telegram delivery

- [Bot webhook](https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js): `server/index.js`
- [Genre menu](https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js): `server/index.js`
- [Category headlines](https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js): `server/index.js`
- [Manual digest route](https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js): `server/index.js`
- [Digest scheduler](https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/index.js): `server/index.js`
- [Digest builder](https://github.com/pratyushwinorlearn/news-telegram-bot/blob/main/server/telegram.js): `server/telegram.js`

### Other components

- **Desk user**
- **NewsData.io**
- **Telegram user**
- **Telegram Bot API**
- **Configured digest group**

## Connections

- Desk user → Dashboard UI: uses
- Dashboard UI → News API client: requests pages
- News API client → HTTP API: calls API
- HTTP API → Category fetch: requests category
- Category fetch → Page cache: reads and writes
- Category fetch → NewsData.io: fetches articles
- Category fetch → HTTP API: returns results
- Telegram user → Telegram Bot API: messages bot
- Telegram Bot API → Bot webhook: posts updates
- Bot webhook → Genre menu: dispatches greeting
- Genre menu → Telegram Bot API: sends menu
- Bot webhook → Category headlines: dispatches selection
- Category headlines → Chat pagination: reads and updates
- Category headlines → Category fetch: fetches pages
- Category headlines → Telegram Bot API: sends headlines
- HTTP API → Manual digest route: handles send-now
- Manual digest route → Digest builder: invokes digest
- Digest scheduler → Digest builder: runs on schedule
- Digest builder → Category fetch: fetches categories
- Digest builder → Telegram Bot API: sends digest
- Telegram Bot API → Configured digest group: delivers messages
