Service Layer high complexity backend
3
Dependencies
4
Dependents
4
Entities
0
Integrations

Description

Core backend service that orchestrates Bufdir report generation by querying PostgreSQL for activity records within the specified period and organization scope. Applies role-based tenant isolation at the query layer, validates output against the versioned Bufdir specification template, and exposes a single REST endpoint consumed by both the mobile app and admin portal.

Feature: Bufdir Report Generation

bufdir-report-service

Responsibilities

  • Accept report generation requests with organization scope and period from REST API
  • Delegate data aggregation to Report Data Aggregation Service with tenant-isolated queries
  • Validate the generated report structure against the active versioned Bufdir spec template
  • Persist completed reports to the Bufdir Reports Table with status tracking
  • Support bulk multi-organization generation for Global Admin role
  • Cache report previews for mobile offline access

Interfaces

POST /api/v1/bufdir-reports/generate
POST /api/v1/bufdir-reports/generate-bulk
GET /api/v1/bufdir-reports/:reportId
GET /api/v1/bufdir-reports/:reportId/preview
GET /api/v1/bufdir-reports?organizationId=&period=
generateReport(organizationId: string, period: ReportPeriod) -> BufdirReport
generateBulkReports(organizationIds: string[], period: ReportPeriod) -> BufdirReport[]
validateReportAgainstSpec(report: BufdirReport, specVersion: string) -> ValidationResult