How yz302/radar works
Purpose and entry points
TrendRadar is a Python news-hotspot aggregation and monitoring system. It fetches configured platform hot lists plus RSS/Atom feeds, filters and ranks items, persists history, generates reports, and distributes notifications. It also exposes stored news to AI clients through MCP.
Primary runtime entry points:
• Main crawler/report pipeline: trendradar/__main__.py
• MCP server, usable over STDIO or HTTP: mcp_server/server.py
• Container operational wrapper/web-server manager: docker/manage.py
Application orchestration and configuration
The application package is organized around a central execution context and configuration/data-loading layer. Configuration controls enabled sources, reporting mode, storage backend, notification channels, AI, and environment-variable overrides. Keyword groups and global filters are separate text configuration.
Paths: trendradar/context.py, trendradar/core/config.py, trendradar/core/loader.py, config/config.yaml, config/frequency_words.txt.
Control boundary: configuration is loaded before collection and is shared by crawling, storage, reporting, notification, and optional AI stages.
Collection and normalization
Platform collection is an HTTP-fetching crawler that obtains hot-list data from the external newsnow API/service. RSS/Atom has a parallel fetch/parse path. Collected items become normalized internal news records for subsequent history-aware processing.
Paths: trendradar/crawler/fetcher.py, trendradar/crawler/rss/fetcher.py, trendradar/crawler/rss/parser.py.
External boundary: newsnow supplies multi-platform trending data; configured RSS/Atom endpoints are independently fetched. Network failures and source-specific formats are isolated in this layer.
Analysis, filtering, and trend state
Core analysis applies keyword groups, required/excluded terms, regex matching, frequency-based scoring, ranking, URL normalization, and detection of new versus previously seen items. Historical records support daily, current-list, and incremental reporting semantics.
Paths: trendradar/core/analyzer.py, trendradar/core/frequency.py, trendradar/core/data.py, trendradar/utils/url.py.
The resulting categorized data is the main contract between ingestion/storage and presentation/delivery.
Storage and retention
Storage is abstracted behind a manager and supports local SQLite by default plus remote S3-compatible object storage for stateless environments. SQLite schemas include separate hot-list and RSS structures; daily databases are represented under output/news/.
Paths: trendradar/storage/manager.py, trendradar/storage/local.py, trendradar/storage/remote.py, trendradar/storage/schema.sql, trendradar/storage/rss_schema.sql.
Infrastructure boundary: Docker/local runs persist mounted local output; GitHub Actions can use S3-compatible providers such as Cloudflare R2, OSS, or COS. Retention and synchronization are storage concerns rather than crawler concerns.
Report, AI enrichment, and notification delivery
Report generation converts analyzed records into text/HTML/RSS-oriented presentation. Optional AI analysis and translation call models through LiteLLM using configurable prompts, then embed results into the report. Notification dispatch formats, splits, and sends payloads to channel adapters.
Paths: trendradar/report/generator.py, trendradar/report/html.py, trendradar/ai/client.py, trendradar/ai/analyzer.py, trendradar/notification/dispatcher.py, trendradar/notification/senders.py.
External services include LiteLLM-supported LLM providers and webhook/SMTP-based channels: WeCom, Feishu, DingTalk, Telegram, ntfy, Bark, Slack, generic webhooks, and email. HTML output is also published as static index.html.
MCP analytics service
The MCP subsystem is a separate read-oriented interface over persisted TrendRadar data. Its server registers query, search, analytics, configuration, synchronization, and system tools. Services parse arguments, access/caches stored databases, and return a consistent result structure.
Paths: mcp_server/server.py, mcp_server/services/data_service.py, mcp_server/services/parser_service.py, mcp_server/services/cache_service.py, mcp_server/tools/analytics.py, mcp_server/tools/data_query.py.
It requires existing output/ data; it does not itself crawl live news. Docker can run it separately with read-only config/output volumes, typically HTTP on localhost port 3333.
Deployment and automation
The same Python code supports local execution, Docker Compose, and scheduled GitHub Actions. Docker separates crawler/notification and MCP images; Actions schedule collection and provide a stateless runtime, making remote storage architecturally important.
Paths: docker/Dockerfile, docker/Dockerfile.mcp, docker/docker-compose.yml, .github/workflows/crawler.yml, .github/workflows/clean-crawler.yml.
Components 23
Crawler Pipeline
- Crawler entry point
trendradar/__main__.py - Execution context · Shares configuration and runtime services across pipeline stages.
trendradar/context.py - Configuration loader
trendradar/core/config.py - Config and keyword rules
config/config.yaml - newsnow API · Multi-platform trending source.
- Hot-list fetcher
trendradar/crawler/fetcher.py - RSS/Atom endpoints
- RSS fetch and parse
trendradar/crawler/rss/fetcher.py
Analysis & Storage
- Filtering and ranking · Normalizes records, applies rules and identifies new items.
trendradar/core/analyzer.py - Storage manager · Selects local or remote persistence and handles retention/sync.
trendradar/storage/manager.py - SQLite history · Daily hot-list and RSS databases under output/news/.
trendradar/storage/local.py - S3-compatible storage · Supports stateless scheduled environments.
trendradar/storage/remote.py
Reporting & Delivery
- Report generator · Produces text, HTML, and RSS-oriented output.
trendradar/report/generator.py - AI enrichment · Optional analysis and translation applied to reports.
trendradar/ai/analyzer.py - LiteLLM providers
- Notification dispatch · Formats, splits, and routes report payloads.
trendradar/notification/dispatcher.py - Webhooks and email · Includes chat webhooks, ntfy/Bark, Slack, and SMTP.
- Static HTML output · Published as index.html.
MCP Analytics
- MCP server · Serves persisted news over STDIO or HTTP.
mcp_server/server.py - MCP data services · Parses requests and accesses cached stored databases.
mcp_server/services/data_service.py - MCP tools · Provides query, search, analytics, configuration, sync, and system tools.
mcp_server/tools/analytics.py
Operations
- Docker Compose · Runs separate crawler/notification and MCP images.
docker/docker-compose.yml - Scheduled Actions · Runs collection in a stateless scheduled environment.
.github/workflows/crawler.yml
Connections 28
- Crawler entry point → Execution context: initializes
- Execution context → Configuration loader: loads
- Configuration loader → Config and keyword rules: reads
- Execution context → Hot-list fetcher: runs
- Execution context → RSS fetch and parse: runs
- Hot-list fetcher → newsnow API: fetches
- RSS fetch and parse → RSS/Atom endpoints: fetches
- Hot-list fetcher → Filtering and ranking: normalized records
- RSS fetch and parse → Filtering and ranking: parsed records
- Filtering and ranking → Storage manager: history-aware records
- Storage manager → SQLite history: local backend
- Storage manager → S3-compatible storage: remote backend
- Filtering and ranking → Report generator: categorized data
- Storage manager → Report generator: historical data
- Report generator → AI enrichment: optional enrichment
- AI enrichment → LiteLLM providers: LiteLLM calls
- AI enrichment → Notification dispatch: enriched report
- Report generator → Notification dispatch: report payload
- Report generator → Static HTML output: publishes
- Notification dispatch → Webhooks and email: sends
- MCP server → MCP tools: registers
- MCP tools → MCP data services: queries through
- MCP data services → SQLite history: reads persisted data
- MCP data services → S3-compatible storage: syncs/reads remotely
- Docker Compose → Crawler entry point: runs crawler image
- Docker Compose → MCP server: runs MCP image
- Scheduled Actions → Crawler entry point: scheduled execution
- Scheduled Actions → S3-compatible storage: stateless persistence