Update flow processing

Introduction#

Ingestion from SuperSet: multi-user auth, credential rotation, dedupe, and LLM notice matching. A callback enricher fills details only for new jobs so we do not re-hit the portal for records we already know.

Project structure#

The update flow spans several key modules within the application architecture:

Core components#

The update flow processing system consists of four primary components working in concert:

UpdateRunner#

The central orchestrator for the update lifecycle, with DI for tests and resource cleanup.

SupersetClientService#

Handles SuperSet portal authentication, data fetching, and job enrichment operations with detailed error handling and retry logic.

DatabaseService#

Provides MongoDB operations with deduplication strategies, efficient ID lookups, and transaction-safe operations for notices and jobs.

NoticeFormatterService#

Implements LLM-powered notice processing with callback-based job enrichment and structured content formatting.

Architecture overview#

The update flow follows a sequential processing pattern optimized for performance and reliability:

Detailed component analysis#

Authentication and credential management#

The system supports multi-user SuperSet authentication through secure credential handling:

Auth tries each configured user, keeps the sessions that work, and continues when one login fails.

Deduplication strategy#

The system implements efficient deduplication using database-backed ID lookups:

The deduplication strategy queries the database for all existing notice and job IDs, then filters incoming data to process only new records. This approach minimizes unnecessary API calls and reduces processing overhead.

Notice processing workflow#

The notice processing pipeline uses LLM-powered matching with callback-based enrichment:

The callback-based enricher pattern optimizes API usage by:

  1. Checking if a job is already enriched in memory
  2. Using existing enriched data when available
  3. Fetching details only for truly new jobs
  4. Persisting enriched data back to the database

Job enrichment strategy#

The system implements a tiered enrichment approach to minimize API calls:

The enrichment strategy processes only new jobs while reusing existing enriched data, significantly reducing API call volume and improving performance.

Error handling and logging#

The system implements detailed error handling across all processing stages:

Error handling follows a consistent pattern:

  • Authentication failures are logged but don’t halt processing
  • Individual notice processing errors are caught and logged
  • Job enrichment errors are handled gracefully
  • All operations use structured logging with context information

Dependency analysis#

Update flow keeps concerns separate via DI:

Performance considerations#

The update flow implements several optimization strategies:

API call minimization#

  • Batch Operations: Fetches all notices and jobs in single operations
  • Selective Enrichment: Processes only new jobs requiring API calls
  • Callback Caching: Reuses enriched data through callback mechanism

Memory management#

  • Lazy Loading: Jobs are enriched only when needed
  • Efficient Lookups: Uses sets for O(1) ID existence checks
  • Streaming Processing: Processes data sequentially to avoid memory pressure

Database optimization#

  • Index Utilization: Efficient ID lookups using database indexes
  • Upsert Operations: Atomic updates prevent race conditions
  • Connection Pooling: Reused database connections reduce overhead

Troubleshooting guide#

Common authentication issues#

  • Credential Format: Ensure SUPERSET_CREDENTIALS is properly formatted JSON array
  • Network Connectivity: Verify access to SuperSet portal from deployment environment
  • Rate Limiting: Monitor for API rate limiting during bulk authentication

Processing failures#

  • Notice Processing: Check individual notice IDs in logs for specific failure points
  • Job Enrichment: Verify that new job IDs are being properly identified
  • Database Connectivity: Confirm MongoDB connection and collection accessibility

Performance issues#

  • Memory Usage: Monitor memory consumption during large batch processing
  • API Throttling: Implement appropriate delays between API calls
  • Database Performance: Ensure proper indexing on frequently queried fields

Conclusion#

Update flow is multi-user auth, dedupe, and enrich-only-when-new. Failures stay local, credentials rotate, and SuperSet does not get hammered for jobs we already stored.