Skip to content

Data Model: Document

Purpose: The Document entity represents a single file stored by the platform. It acts as a central record, linking the physical file in cloud storage to its business context (e.g., an Offer's legal agreement) and managing its metadata and access permissions.

Fields/Attributes

NameTypeDescriptionValidation Rules
idUnique IdentifierThe primary internal system ID for the document record.• Required • System-generated
nameTextThe human-readable name of the file (e.g., "Subscription Agreement.pdf").• Required
urlURLA secure, time-limited URL to access and download the file.• Read-only • System-generated
filenameTextThe unique, system-generated filename in the cloud storage bucket.• Required, Unique • System-generated
bucket_nameTextThe name of the cloud storage bucket where the file is stored.• Required
bucket_pathTextThe folder path within the bucket where the file is located.• Optional
mime_typeTextThe file's format identifier (e.g., application/pdf, image/jpeg).• Required
file_sizeIntegerThe size of the file in bytes.• Required
owner_user_idForeign KeyA reference to the User who owns or uploaded the file.• Nullable
group_idForeign KeyA reference to a Group to control permissions and visibility.• Nullable
metadataJSONA flexible field for storing any additional, custom metadata about the file.• Optional
created_atTimestampThe date and time the document record was created.• Read-only

Global Business Rules

  • Secure Access: The url for accessing a file must be a secure, time-limited signed URL. Direct public links to storage objects must not be used.

  • Upload Validation: The system must validate all file uploads against a list of allowed mime_type values and enforce a maximum file_size limit.

Auditing & Event History

Every significant action or change made to an Document is recorded as an immutable entry in a system-wide EventLog. This creates a complete and tamper-proof audit trail for compliance and operational tracking.