Document Attachment Bundler
Component Detail
Description
Collects document attachments (invitations, screenshots) linked to activities in the export period and bundles them alongside the export file. Supports both embedded linking in Excel and physical file bundling in a ZIP archive as required by NHF for Bufdir verification.
bufdir-attachment-bundler
Summaries
The Document Attachment Bundler ensures that every Bufdir compliance export submitted to the Norwegian Housing Bank (NHF) includes the full supporting documentation required for verification — invitations, screenshots, and activity records — bundled alongside the financial report. Without this capability, staff would manually gather and attach evidence files before each submission, creating delays, inconsistency, and audit risk. By automating document packaging, the organisation demonstrates accountability to Bufdir, reduces the likelihood of rejected submissions, and protects grant funding. This directly safeguards revenue streams dependent on NHF reimbursements and strengthens the organisation's reputation as a compliant, well-governed partner.
This backend component sits within the Bufdir export pipeline and has a medium complexity rating. Development requires access to the document attachment data model and the activity records store, so it must be sequenced after the core activity and document modules are stable. The ZIP archive generation feature adds a file I/O concern that should be tested with realistic payload sizes to avoid memory or timeout issues in production. Integration testing must cover both Excel-embedded linking and physical ZIP bundling paths.
A key delivery risk is the dependency on Bufdir's current specification for how attachments should be packaged; any late-breaking requirement changes from NHF could require rework. Allow buffer time for format validation with a real Bufdir submission cycle.
The attachment bundler is a backend service component that operates within the export orchestration pipeline. It queries document attachments linked to a provided list of activity IDs for a given export period, then supports two output modes: embedded Excel linking (attachment URLs referenced inside the spreadsheet cells) and physical bundling via a ZIP archive. The `bundleAttachments` method drives the main workflow, delegating to `generateZipArchive` for physical packaging and `getAttachmentManifest` for producing a structured reference map. `validateAttachmentIntegrity` should perform checksum or presence checks before finalising the bundle.
Internally, this component will interact with the document_attachment data model via its repository layer. Ensure streaming ZIP writes (e.g., using archiver or jszip in streaming mode) to handle large exports without heap exhaustion. The manifest should be serialisable as JSON for audit log attachment.
Responsibilities
- Retrieve document attachments linked to activity records in the export period
- Bundle physical attachment files into a ZIP archive
- Generate an attachment reference manifest for the export
- Embed or link attachment references in the export spreadsheet
Interfaces
bundleAttachments(List<String> activityIds, String exportId)
getAttachmentManifest(String exportId)
generateZipArchive(String exportId)
validateAttachmentIntegrity(String exportId)
Relationships
Related Data Entities (1)
Data entities managed by this component
Used Integrations (1)
External integrations and APIs this component relies on