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.

24 properties
Schema

Properties

PropertyTypeModeDescriptionRequired
titlestring
stored

Display name or title of the document

Example: "Service Agreement - Acme Corp"

Required
descriptionstring
stored

Detailed description of the document content and purpose

Optional
entityKernelModel
stored

Reference to the entity type this document is attached to

Required
entityIdstring
stored

Identifier of the specific entity record this document is attached to

Example: "org-12345"

Required
categoryDocumentCategory
stored

Reference to the category for classification and organization

Optional
statusstring
stored

Current status of the document

Values: draft, active, archived, deleted

Example: "active"

Required
storageDocumentStorage
stored

Reference to the storage backend where this document is stored

Required
storagePathstring
stored

Path to the file within the storage backend (relative to storage basePath)

Example: "contracts/2024/service-agreement-acme.pdf"

Required
mimeTypestring
stored

MIME type of the file

Example: "application/pdf"

Required
fileSizenumber
stored

File size in bytes

Example: 1453200

Required
checksumstring
stored

Hash checksum for integrity verification

Example: "e4d909c290d0fb1ca068ffaddf22cbd0"

Optional
checksumAlgorithmstring
stored

Algorithm used for checksum (MD5, SHA-256, etc.)

Example: "SHA-256"

Optional
ownerPerson
stored

Person who owns or uploaded this document

Required
organizationOrganization
stored

Organization that owns this document

Optional
tagsstring[]
stored

Tags for search and filtering

Example: ["contract","2024","signed"]

Optional
languagestring
stored

Document language (ISO 639-1 code)

Example: "en"

Optional
expirationDateDate
stored

Date when this document expires or becomes invalid

Optional
metadatajson
stored

Additional metadata for extensibility

Optional
isActiveboolean
calculated

Whether the document is active (status is active)

Optional
isArchivedboolean
calculated

Whether the document is archived

Optional
hasExpiredboolean
calculated

Whether the document has passed its expiration date

Optional
isImageboolean
calculated

Whether the document is an image file (based on mimeType)

Optional
isPdfboolean
calculated

Whether the document is a PDF file (based on mimeType)

Optional
fileExtensionstring
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"
  }
}