Data flow & processing pipeline

Introduction#

End-to-end path from SuperSet and Gmail into MongoDB, then out to Telegram and Web Push. Placement offers jump the queue over general notices. Emails stay unread until processing finishes so a crash does not eat mail.

Project structure#

The system is organized into modular components:

  • CLI entry point and orchestration commands
  • Runners for update and notification tasks
  • Services for processing notices, placement offers, and formatting
  • Clients for external systems (Google Groups, Telegram, MongoDB)
  • Servers for bot and scheduler operations
  • Configuration and logging utilities

Core components#

  • CLI and Orchestration: Central CLI dispatches commands for updates, notifications, and administrative tasks. It coordinates SuperSet and email processing, and triggers notification delivery.
  • Runners: Encapsulate update and notification workflows for testability and reuse.
  • Processing Services:
  • EmailNoticeService: LLM-driven classification and extraction of general notices from emails.
  • PlacementService: Keyword-based classification and LLM extraction/validation for placement offers.
  • Formatters: Transform structured data into human-friendly messages for Telegram and Web Push.
  • External Clients:
  • GoogleGroupsClient: IMAP-based email retrieval and marking.
  • DBClient: MongoDB connectivity and collection access.
  • Delivery Channels:
  • TelegramService: Message formatting and broadcasting.
  • WebPushService: VAPID-authenticated push notifications.
  • NotificationService: Aggregates channels and orchestrates unsent notice delivery.

Architecture overview#

The pipeline follows a sequential, resilient pattern:

  • Data ingestion from SuperSet and Gmail/emails
  • Structured extraction and validation
  • Database persistence and event generation
  • Notice formatting and channel-specific delivery
  • Idempotent marking of processed emails

Detailed component analysis#

SuperSet update pipeline#

  • Login and credential management are centralized via configuration.
  • Efficient pre-filtering avoids redundant API calls by checking existing IDs in the database.
  • Job enrichment is deferred to only newly discovered listings to reduce cost.
  • Notice-to-job matching uses fuzzy company name extraction and optional enricher callback to fetch detailed job data before formatting.

Email processing orchestration (placement vs general notices)#

  • Sequential processing: fetch without marking read, process, save, then mark read only after success or rejection.
  • Priority order:
  1. Try PlacementService (keyword-based classification + LLM extraction/validation)
  2. If not a placement offer, try EmailNoticeService (LLM-based classification and extraction)
  3. Mark as read if processed (either as placement offer or as irrelevant/general notice)
  • Retry and validation:
  • PlacementService supports retries for extraction/validation failures.
  • EmailNoticeService applies LLM extraction with retry up to a configured limit, then validates minimum requirements.

Notification delivery pipeline#

  • NotificationService aggregates channels and broadcasts unsent notices.
  • TelegramService handles message formatting (HTML/markdown conversion), chunking for long messages, and user broadcasting.
  • WebPushService conditionally enables/disables itself based on VAPID configuration and gracefully degrades when dependencies are missing.
  • Delivery is idempotent: notices are marked as sent only after successful delivery to at least one channel.

Servers and scheduling#

  • BotServer: Telegram bot with command handlers and DI for services.
  • SchedulerServer: APScheduler-based automation that mirrors the legacy update flow, scheduling frequent intervals and a daily official placement scrape.

Dependency analysis#

  • Configuration-driven design: Settings are loaded centrally and cached, so modules see the same settings.
  • Decoupled clients: GoogleGroupsClient and DBClient isolate external integrations for testability.
  • Dependency Injection: Runners and services accept optional injected dependencies, supporting both CLI and server modes.
  • Channel abstraction: NotificationService encapsulates channel differences behind a uniform interface.

Performance considerations#

  • Cost-aware job enrichment: Only newly discovered jobs are enriched to minimize API calls.
  • Early filtering: Existing IDs are pre-fetched to avoid redundant processing.
  • Chunked message delivery: TelegramService splits long messages and retries without formatting to improve reliability.
  • Conditional web push: WebPushService gracefully disables itself when VAPID keys are missing, preventing unnecessary overhead.
  • Retry limits: Both placement and notice extraction include bounded retry logic to handle transient LLM errors.

[No sources needed since this section provides general guidance]

Troubleshooting guide#

Common issues and remedies:

  • Authentication failures:
  • SuperSet login errors: Verify credentials and network connectivity; check logs for detailed error messages.
  • Telegram/VAPID misconfiguration: Ensure tokens and keys are set; WebPushService logs warnings when disabled.
  • Email processing stalls:
  • If an email fails to process, it remains unread to allow retry on next run; confirm network and IMAP availability.
  • Large messages: TelegramService automatically splits and retries; monitor chunk delivery.
  • Delivery failures:
  • NotificationService marks a notice as sent only after successful delivery to at least one channel; inspect per-channel results for granular diagnostics.
  • Database connectivity:
  • Confirm MongoDB connection string and collection initialization; DBClient raises explicit errors on connection failures.

Conclusion#

Sequential pipeline: SuperSet and Gmail in, placement offers first, then notices, then Telegram/Web Push out. Retries and idempotent sent flags absorb blips. DI keeps the stages replaceable.