Controllers

Business logic coordination between routes and services. Controllers should:

  • Handle environment variables and configuration
  • Coordinate multiple service calls
  • Implement business rules and validation
  • Handle service business logic layer (result.success)

Available Controllers

  • emails.controller.ts - Handles email PDF attachment processing workflow
    • PDF Processing: Processes each PDF attachment as separate database page
    • Filename Parsing: Extracts interviewee names from filenames using parentheses pattern
    • Status Tracking: Manages upload status progression ("Uploading..." → "Uploaded" → "Upload error")
    • 3-Step Upload: Orchestrates Notion's file upload process (create → upload → attach)
  • tasks.controller.ts - Handles PDF extraction, blob storage, and page duplication workflows for Notion webhooks
    • PDF Text Extraction & Redaction: Extracts text from PDFs and redacts person names (from Notion Name property) with "Respondent" before blob storage
    • Page Duplication: Includes content filtering and H3-to-paragraph transformation for "Key findings" and "Notable disagreements"
    • Filtered Database Duplication: Duplicates pages with child databases while filtering out specific properties (Confidence Score, Consensus Level, Evidence Summary, Methodology)
  • health.controller.ts - System health checks
  • findings.controller.ts - Handles findings analysis workflow using ChatGPT and Notion integration
    • Question Tracking: Records "Total questions" count during initialization and "Completed questions" count upon finalization
    • Progress Monitoring: Enables completion rate analysis in Notion dashboards