Digest Generation Services
Last Updated: 2026-05-08
The digest services generate periodic knowledge summaries from categorized items.
Service Components
DigestOrchestrator
Main orchestrator for the 7-step digest generation pipeline:
- Resolve Category
- Parse Date Range
- Query Knowledge by category + date range
- Generate AI Highlights (lazy — skip if exists)
- Format as Dutch Markdown
- Create Digest entity with snapshot
- Persist to SQLite + sync to Notion
KnowledgeHighlightGenerator
Generates 2-3 sentence Dutch summaries for knowledge items during digest creation.
- Uses
DigestConstants::HIGHLIGHT_SUMMARY_PROMPT(hardcoded sprintf template) - Lazy generation — skips items that already have a
highlight - Fallback: truncate content to 200 chars on AI failure
DigestContentFormatter
Formats the digest as Dutch Markdown:
- Category title, date range, item count
- Per-item: title (linked to Notion), reading time, AI summary, tags
DigestDistributionService
Handles distribution of digests to category subscribers.
- Resolves recipients: active subscribers + initiator
- Converts Markdown → Slack mrkdwn
- Sends via
SlackMessageTransport→ Slack DM - Logs per-user delivery status
DigestSchedulerService
Processes scheduled digests for categories with digest settings enabled.
- Compares
lastDigestAt+ frequency against current time - Checks configured day of week and time
- Triggers the full 7-step pipeline when due
DigestDeliveryLogService
Tracks per-user delivery status via DigestDelivery entities.
- Status: pending → sent (or failed)
- Retry support: max 3 attempts via
canRetry()
Core Business Logic
Date Range Parsing
DateRangeParser::parse() converts natural language into concrete start/end dates:
- Supports Dutch ("laatste week") and English ("7 days")
- Presets: 7 days, 14 days, 30 days, 90 days, all time
- Custom date ranges
Immutable Snapshots
The Digest.knowledgeHighlights JSON captures a snapshot at generation time:
- Each entry:
{id, title, highlight, aiSummary, notionUrl, tags, createdAt} - Digests remain accurate even if source knowledge items change later