# kaguya2021/project-ttnews- architecture

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

- Interactive diagram: https://gitdiagram.com/kaguya2021/project-ttnews-
- Repository: https://github.com/kaguya2021/project-ttnews-

## Overview

TikTokPulse collects recent RSS articles, scores and stores them, then exposes them through a Telegram bot and scheduled digests. Users can browse by category or date, save favorites, manage subscriptions, and generate short-video scripts from articles. The runtime entry point runs migrations, performs an initial collection, and starts the scheduler, bot, and health-check server. Relationships are based on the shown source excerpts and README; unsampled capabilities are not given speculative implementation links.

Main entry points: [`src/db/pool.js`](https://github.com/kaguya2021/project-ttnews-/blob/main/src/db/pool.js) (Database pool), [`src/index.js`](https://github.com/kaguya2021/project-ttnews-/blob/main/src/index.js) (Application startup), [`src/bot/handlers.js`](https://github.com/kaguya2021/project-ttnews-/blob/main/src/bot/handlers.js) (Commands and callbacks), [`src/services/rssFetcher.js`](https://github.com/kaguya2021/project-ttnews-/blob/main/src/services/rssFetcher.js) (RSS fetch and storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and interfaces"]
  node_entry["Application startup<br/>[index.js]"]
  node_health["Health check<br/>[index.js]"]
  node_config["Environment config<br/>[config.js]"]
  node_pool["Database pool<br/>[pool.js]"]
  node_migrations["Schema and seed data<br/>[migrate.js]"]
end

subgraph group_ingestion["News ingestion"]
  node_scheduler["Collection and digest schedule<br/>[scheduler.js]"]
  node_fetcher["RSS fetch and storage<br/>[rssFetcher.js]"]
end

subgraph group_bot["Telegram experience"]
  node_bot_runtime["Bot runtime<br/>[index.js]"]
  node_handlers["Commands and callbacks<br/>[handlers.js]"]
  node_keyboards["Inline keyboards<br/>[keyboards.js]"]
end

subgraph group_content["Content tools"]
  node_scorer["Virality scoring<br/>[newsScorer.js]"]
  node_scriptgen["Video script generation<br/>[scriptGen.js]"]
end

node_user(("Telegram user"))
node_telegram["Telegram API"]
node_rss_sources["RSS sources"]
node_postgres[("PostgreSQL")]

node_user -->|"sends updates"| node_telegram
node_telegram -->|"delivers updates"| node_bot_runtime
node_bot_runtime -->|"registers handlers"| node_handlers
node_handlers -->|"replies and sends"| node_telegram
node_handlers -->|"queries and updates"| node_pool
node_handlers -->|"uses menus"| node_keyboards
node_handlers -->|"generates scripts"| node_scriptgen
node_entry -->|"reads settings"| node_config
node_entry -->|"runs migrations"| node_migrations
node_entry -->|"collects initially"| node_fetcher
node_entry -->|"starts schedule"| node_scheduler
node_entry -->|"starts bot"| node_bot_runtime
node_migrations -->|"creates schema"| node_pool
node_pool -->|"uses database URL"| node_config
node_pool -->|"connects to"| node_postgres
node_scheduler -->|"schedules collection"| node_fetcher
node_scheduler -->|"queries and records deliveries"| node_pool
node_scheduler -->|"sends digests"| node_telegram
node_fetcher -->|"parses feeds"| node_rss_sources
node_fetcher -->|"scores articles"| node_scorer
node_fetcher -->|"reads sources and stores news"| node_pool
node_health -.->|"serves health response"| node_user

click node_entry "https://github.com/kaguya2021/project-ttnews-/blob/main/src/index.js"
click node_health "https://github.com/kaguya2021/project-ttnews-/blob/main/src/index.js"
click node_config "https://github.com/kaguya2021/project-ttnews-/blob/main/src/config.js"
click node_pool "https://github.com/kaguya2021/project-ttnews-/blob/main/src/db/pool.js"
click node_migrations "https://github.com/kaguya2021/project-ttnews-/blob/main/src/db/migrate.js"
click node_bot_runtime "https://github.com/kaguya2021/project-ttnews-/blob/main/src/bot/index.js"
click node_handlers "https://github.com/kaguya2021/project-ttnews-/blob/main/src/bot/handlers.js"
click node_keyboards "https://github.com/kaguya2021/project-ttnews-/blob/main/src/bot/keyboards.js"
click node_scheduler "https://github.com/kaguya2021/project-ttnews-/blob/main/src/services/scheduler.js"
click node_fetcher "https://github.com/kaguya2021/project-ttnews-/blob/main/src/services/rssFetcher.js"
click node_scorer "https://github.com/kaguya2021/project-ttnews-/blob/main/src/services/newsScorer.js"
click node_scriptgen "https://github.com/kaguya2021/project-ttnews-/blob/main/src/services/scriptGen.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_entry,node_health,node_config,node_pool,node_migrations,node_user toneBlue
class node_scheduler,node_fetcher,node_postgres toneAmber
class node_bot_runtime,node_handlers,node_keyboards,node_telegram toneMint
class node_scorer,node_scriptgen toneRose
class node_rss_sources toneIndigo
```

## Components

### Runtime and interfaces

- [Application startup](https://github.com/kaguya2021/project-ttnews-/blob/main/src/index.js): `src/index.js`
- [Health check](https://github.com/kaguya2021/project-ttnews-/blob/main/src/index.js): `src/index.js`
- [Environment config](https://github.com/kaguya2021/project-ttnews-/blob/main/src/config.js): `src/config.js`
- [Database pool](https://github.com/kaguya2021/project-ttnews-/blob/main/src/db/pool.js): `src/db/pool.js`
- [Schema and seed data](https://github.com/kaguya2021/project-ttnews-/blob/main/src/db/migrate.js): `src/db/migrate.js`

### News ingestion

- [Collection and digest schedule](https://github.com/kaguya2021/project-ttnews-/blob/main/src/services/scheduler.js): `src/services/scheduler.js`
- [RSS fetch and storage](https://github.com/kaguya2021/project-ttnews-/blob/main/src/services/rssFetcher.js): `src/services/rssFetcher.js`

### Telegram experience

- [Bot runtime](https://github.com/kaguya2021/project-ttnews-/blob/main/src/bot/index.js): `src/bot/index.js`
- [Commands and callbacks](https://github.com/kaguya2021/project-ttnews-/blob/main/src/bot/handlers.js): `src/bot/handlers.js`
- [Inline keyboards](https://github.com/kaguya2021/project-ttnews-/blob/main/src/bot/keyboards.js): `src/bot/keyboards.js`

### Content tools

- [Virality scoring](https://github.com/kaguya2021/project-ttnews-/blob/main/src/services/newsScorer.js): `src/services/newsScorer.js`
- [Video script generation](https://github.com/kaguya2021/project-ttnews-/blob/main/src/services/scriptGen.js): `src/services/scriptGen.js`

### Other components

- **Telegram user**
- **Telegram API**
- **RSS sources**
- **PostgreSQL**

## Connections

- Telegram user → Telegram API: sends updates
- Telegram API → Bot runtime: delivers updates (evidence: `src/bot/index.js`)
- Bot runtime → Commands and callbacks: registers handlers (evidence: `src/bot/index.js`)
- Commands and callbacks → Telegram API: replies and sends (evidence: `src/bot/handlers.js`)
- Commands and callbacks → Database pool: queries and updates (evidence: `src/bot/handlers.js`)
- Commands and callbacks → Inline keyboards: uses menus (evidence: `src/bot/handlers.js`)
- Commands and callbacks → Video script generation: generates scripts (evidence: `src/bot/handlers.js`)
- Application startup → Environment config: reads settings (evidence: `src/index.js`)
- Application startup → Schema and seed data: runs migrations (evidence: `src/index.js`)
- Application startup → RSS fetch and storage: collects initially (evidence: `src/index.js`)
- Application startup → Collection and digest schedule: starts schedule (evidence: `src/index.js`)
- Application startup → Bot runtime: starts bot (evidence: `src/index.js`)
- Schema and seed data → Database pool: creates schema (evidence: `src/db/migrate.js`)
- Database pool → Environment config: uses database URL (evidence: `src/db/pool.js`)
- Database pool → PostgreSQL: connects to (evidence: `src/db/pool.js`)
- Collection and digest schedule → RSS fetch and storage: schedules collection (evidence: `src/services/scheduler.js`)
- Collection and digest schedule → Database pool: queries and records deliveries (evidence: `src/services/scheduler.js`)
- Collection and digest schedule → Telegram API: sends digests (evidence: `src/services/scheduler.js`)
- RSS fetch and storage → RSS sources: parses feeds (evidence: `src/services/rssFetcher.js`)
- RSS fetch and storage → Virality scoring: scores articles (evidence: `src/services/rssFetcher.js`)
- RSS fetch and storage → Database pool: reads sources and stores news (evidence: `src/services/rssFetcher.js`)
- Health check → Telegram user: serves health response
