Report History Service
Component Detail
Description
Business logic layer responsible for fetching, filtering, and managing the audit log of generated Bufdir reports. Enforces role-based access, ensuring only coordinators and admins can access the history.
report-history-service
Summaries
The Report History Service is the authoritative access control gate for all historical Bufdir report data within the platform. By centralising role enforcement — restricting access to coordinators and admins only — it protects sensitive submission records from unauthorised viewing, directly reducing compliance and data-governance risk. The service also resolves secure, time-limited download URLs, meaning report files are never exposed via permanent public links, further strengthening the organisation's data security posture. This centralised approach ensures that policy changes to access rules are applied consistently across every touchpoint without requiring UI-level changes.
Medium-priority backend component with two direct dependencies: the Report History Repository and the Report File Storage Client. Both must be available before integration testing can begin, making this a mid-sprint deliverable contingent on those components being scaffolded first. Development complexity is low — primarily thin orchestration over repository calls plus a role check. Key delivery risks are the signed URL expiry window (must be agreed with the storage infrastructure team) and ensuring pagination parameters are consistent with the frontend's page-size expectations.
Unit tests should cover role denial scenarios, empty result sets, and storage client failures with graceful error propagation.
Report History Service sits in the backend execution context and acts as the application-layer facade over the Report History Repository and Report File Storage Client. getReportHistory(orgId, {limit, offset}) delegates directly to the repository's getHistoryByOrg with pagination forwarded unchanged. validateRoleAccess(userRole) should throw an AuthorizationException for any role outside coordinator and admin before any database call is made. getSignedDownloadUrl(fileRef) calls the storage client to produce a short-lived pre-signed URL — cache the result per request but do not persist it.
filterByPeriod(from, to) applies date range constraints at the repository query level. Ensure all public methods are async and propagate repository errors with context-enriched messages for upstream error handlers.
Responsibilities
- Fetch paginated report history scoped to organization
- Enforce coordinator and admin role access
- Resolve signed download URLs for stored report files
- Support filtering by date range or reporting period
Interfaces
getReportHistory(orgId, {limit, offset})
getReportById(reportId)
getSignedDownloadUrl(fileRef)
filterByPeriod(from, to)
validateRoleAccess(userRole)
Relationships
Dependencies (2)
Components this component depends on
Related Data Entities (2)
Data entities managed by this component