Document
Represents a digital document or file that can be attached to any entity in the system. Document provides a universal attachment mechanism through polymorphic references (entity + entityId), enabling documents to be linked to any record type - contracts attached to Organizations, invoices to Orders, medical records to Patients, maintenance logs to Vehicles, or certificates to Employees. This entity supports comprehensive document management including file metadata (MIME type, size), storage backend configuration, classification via categories and tags, and integrity verification via checksum. Documents track ownership and reference their storage location through DocumentStorage. Access control is handled by the permission domain. The entity is designed for enterprise content management, compliance documentation, digital asset management, and any scenario requiring file attachments across all industries and domains.
Properties
| Property | Type | Mode | Description | Required |
|---|---|---|---|---|
| title | string | stored | Display name or title of the document Example: | Required |
| description | string | stored | Detailed description of the document content and purpose | Optional |
| entity | KernelModel | stored | Reference to the entity type this document is attached to | Required |
| entityId | string | stored | Identifier of the specific entity record this document is attached to Example: | Required |
| category | DocumentCategory | stored | Reference to the category for classification and organization | Optional |
| status | string | stored | Current status of the document Values: Example: | Required |
| storage | DocumentStorage | stored | Reference to the storage backend where this document is stored | Required |
| storagePath | string | stored | Path to the file within the storage backend (relative to storage basePath) Example: | Required |
| mimeType | string | stored | MIME type of the file Example: | Required |
| fileSize | number | stored | File size in bytes Example: | Required |
| checksum | string | stored | Hash checksum for integrity verification Example: | Optional |
| checksumAlgorithm | string | stored | Algorithm used for checksum (MD5, SHA-256, etc.) Example: | Optional |
| owner | Person | stored | Person who owns or uploaded this document | Required |
| organization | Organization | stored | Organization that owns this document | Optional |
| tags | string[] | stored | Tags for search and filtering Example: | Optional |
| language | string | stored | Document language (ISO 639-1 code) Example: | Optional |
| expirationDate | Date | stored | Date when this document expires or becomes invalid | Optional |
| metadata | json | stored | Additional metadata for extensibility | Optional |
| isActive | boolean | calculated | Whether the document is active (status is active) | Optional |
| isArchived | boolean | calculated | Whether the document is archived | Optional |
| hasExpired | boolean | calculated | Whether the document has passed its expiration date | Optional |
| isImage | boolean | calculated | Whether the document is an image file (based on mimeType) | Optional |
| isPdf | boolean | calculated | Whether the document is a PDF file (based on mimeType) | Optional |
| fileExtension | string | calculated | File extension derived from storagePath | Optional |
Examples
Example 1
{
"@type": "Document",
"title": "Service Agreement - Acme Corp",
"description": "Annual service agreement for cloud infrastructure",
"entity": {
"@type": "KernelModel",
"name": "Organization"
},
"entityId": "org-acme-001",
"category": {
"@type": "DocumentCategory",
"name": "Contracts"
},
"status": "active",
"storage": {
"@type": "DocumentStorage",
"name": "Primary S3 Storage"
},
"storagePath": "contracts/2024/service-agreement-acme.pdf",
"mimeType": "application/pdf",
"fileSize": 1453200,
"checksum": "e4d909c290d0fb1ca068ffaddf22cbd0",
"checksumAlgorithm": "MD5",
"owner": {
"@type": "Person",
"givenName": "Sarah",
"familyName": "Johnson"
},
"organization": {
"@type": "Organization",
"name": "Acme Corporation"
},
"tags": [
"contract",
"acme",
"2024",
"signed"
],
"language": "en",
"expirationDate": "2025-12-31",
"metadata": {
"contractValue": 250000,
"signedDate": "2024-01-15"
}
}Example 2
{
"@type": "Document",
"title": "Employee ID Card",
"description": "Digital copy of employee identification card",
"entity": {
"@type": "KernelModel",
"name": "Employee"
},
"entityId": "emp-2024-001234",
"category": {
"@type": "DocumentCategory",
"name": "HR Documents"
},
"status": "active",
"storage": {
"@type": "DocumentStorage",
"name": "Primary S3 Storage"
},
"storagePath": "employees/id-cards/emp-001234.jpg",
"mimeType": "image/jpeg",
"fileSize": 245000,
"checksum": "a1b2c3d4e5f6a7b8c9d0e1f2",
"checksumAlgorithm": "SHA-256",
"owner": {
"@type": "Person",
"givenName": "Michael",
"familyName": "Chen"
},
"tags": [
"id-card",
"employee",
"identification"
],
"language": "en"
}Example 3
{
"@type": "Document",
"title": "Vehicle Inspection Report",
"description": "Annual safety inspection report for delivery truck",
"entity": {
"@type": "KernelModel",
"name": "Vehicle"
},
"entityId": "veh-truck-042",
"category": {
"@type": "DocumentCategory",
"name": "Fleet Documents"
},
"status": "active",
"storage": {
"@type": "DocumentStorage",
"name": "Primary S3 Storage"
},
"storagePath": "fleet/inspections/truck-042-2024.pdf",
"mimeType": "application/pdf",
"fileSize": 892000,
"checksum": "f3e2d1c0b9a8f7e6d5c4b3a2",
"checksumAlgorithm": "SHA-256",
"owner": {
"@type": "Person",
"givenName": "James",
"familyName": "Rodriguez"
},
"organization": {
"@type": "Organization",
"name": "Express Logistics Inc"
},
"tags": [
"inspection",
"safety",
"2024",
"truck"
],
"language": "en",
"expirationDate": "2025-11-15",
"metadata": {
"inspectionDate": "2024-11-15",
"inspector": "DOT Certified Inspector",
"result": "passed"
}
}Example 4
{
"@type": "Document",
"title": "Invoice #INV-2024-0042",
"description": "Monthly subscription invoice",
"entity": {
"@type": "KernelModel",
"name": "Order"
},
"entityId": "order-2024-0042",
"category": {
"@type": "DocumentCategory",
"name": "Invoices"
},
"status": "active",
"storage": {
"@type": "DocumentStorage",
"name": "Primary S3 Storage"
},
"storagePath": "invoices/2024/INV-2024-0042.pdf",
"mimeType": "application/pdf",
"fileSize": 324800,
"checksum": "b2a3f1c9d8e7f6a5b4c3d2e1",
"checksumAlgorithm": "MD5",
"owner": {
"@type": "Person",
"givenName": "Emily",
"familyName": "Davis"
},
"organization": {
"@type": "Organization",
"name": "TechStart SARL"
},
"tags": [
"invoice",
"november",
"2024"
],
"language": "fr",
"metadata": {
"invoiceNumber": "INV-2024-0042",
"amount": 4999.99,
"currency": "EUR"
}
}