System Diagram

The Mine Lab CM data model, mapped — 51 models, 164 relationships

🔍 For serious exploration, open the Interactive Diagram Viewer — pan, mouse-wheel zoom, fit-to-screen, full-screen, per-module tabs, the full 164-relationship ERD, and a focus mode that draws one model and its neighbours at a chosen depth. Person (41 links) and Attachment (9) fan out to nearly everything, so the viewer hides those links by default — a toggle brings them back. The diagrams below are the readable, static summary of the principal links only.


Architecture Overview

Eight areas mirror the sidebar menu. Every arrow means "one row of the left model is referenced by many rows of the right model".

flowchart LR
    subgraph ORG["🏢 Organisation & people"]
        Organisation --> Site
        Person
    end

    subgraph REG["⛏️ Mine & asset register"]
        MineArea
        Asset --> Component
        SamplingPoint
    end

    subgraph LAB["🔬 Laboratory setup"]
        Laboratory --> LaboratorySection
        Laboratory --> LaboratoryEquipment --> CalibrationRecord
        Laboratory --> TestMethod
        TestSpecification --> TestSpecificationItem
    end

    subgraph SAM["🧪 Samples & custody"]
        SampleRequest --> Sample
        ChainOfCustody --> ChainOfCustodySample
        Sample --> SampleReceipt
        Sample --> SampleStorageRecord
    end

    subgraph TST["⚗️ Preparation & testing"]
        PreparationBatch --> PreparationBatchSample --> PreparationStep
        TestBatch --> TestBatchSample --> AnalyticalResult
    end

    subgraph QC["✅ QA/QC"]
        ReferenceMaterial --> ReferenceMaterialValue
        QualityControlSample --> QualityControlResult
        ControlChartPoint
        Nonconformance --> CorrectiveAction
        AuditRecord --> AuditFinding
    end

    subgraph CON["📈 Condition monitoring"]
        ConditionAssessment --> ConditionIndicator
        ConditionAssessment --> Recommendation
        Recommendation --> MaintenanceNotification --> WorkOrder
    end

    subgraph REP["📄 Reporting"]
        LaboratoryReport --> LaboratoryReportSample
    end

    Site --> Asset
    Site --> SamplingPoint
    Organisation --> Laboratory
    Sample --> TestBatchSample
    Sample --> QualityControlSample
    Sample --> ConditionAssessment
    Sample --> LaboratoryReportSample

The Sample Lifecycle Spine

Request → collect → custody → receipt → preparation → testing.

erDiagram
    SampleRequest ||--o{ Sample : "sample_request_id"
    Sample ||--o{ ChainOfCustodySample : "sample_id"
    ChainOfCustody ||--o{ ChainOfCustodySample : "chain_of_custody_id"
    Sample ||--o{ SampleReceipt : "sample_id"
    Sample ||--o{ PreparationBatchSample : "sample_id"
    PreparationBatch ||--o{ PreparationBatchSample : "preparation_batch_id"
    PreparationBatchSample ||--o{ PreparationStep : "preparation_batch_sample_id"
    Sample ||--o{ TestBatchSample : "sample_id"
    TestBatch ||--o{ TestBatchSample : "test_batch_id"
    TestBatchSample ||--o{ AnalyticalResult : "test_batch_sample_id"
    Sample ||--o{ SampleStorageRecord : "sample_id"

QA/QC: How Results Earn Their Status

erDiagram
    ReferenceMaterial ||--o{ ReferenceMaterialValue : "reference_material_id"
    Sample ||--o{ QualityControlSample : "sample_id"
    ReferenceMaterial ||--o{ QualityControlSample : "reference_material_id"
    TestBatch ||--o{ QualityControlSample : "test_batch_id"
    QualityControlSample ||--o{ QualityControlResult : "quality_control_sample_id"
    AnalyticalResult ||--o{ QualityControlResult : "analytical_result_id"
    TestMethod ||--o{ ControlChartPoint : "test_method_id"
    AnalyticalResult ||--o{ ControlChartPoint : "analytical_result_id"
    Nonconformance ||--o{ CorrectiveAction : "nonconformance_id"
    AuditRecord ||--o{ AuditFinding : "audit_record_id"

Condition Monitoring: ppm → Work Order

erDiagram
    Sample ||--o{ ConditionAssessment : "sample_id"
    Asset ||--o{ ConditionAssessment : "asset_id"
    Component ||--o{ ConditionAssessment : "component_id"
    ConditionAssessment ||--o{ ConditionIndicator : "condition_assessment_id"
    AnalyticalResult ||--o{ ConditionIndicator : "source_result_id"
    ConditionAssessment ||--o{ Recommendation : "condition_assessment_id"
    Recommendation ||--o{ MaintenanceNotification : "recommendation_id"
    Asset ||--o{ MaintenanceNotification : "asset_id"
    MaintenanceNotification ||--o{ WorkOrder : "maintenance_notification_id"
    Asset ||--o{ WorkOrder : "asset_id"

Laboratory Governance

erDiagram
    Organisation ||--o{ Laboratory : "organisation_id"
    Laboratory ||--o{ LaboratorySection : "laboratory_id"
    Laboratory ||--o{ LaboratoryEquipment : "laboratory_id"
    LaboratoryEquipment ||--o{ CalibrationRecord : "laboratory_equipment_id"
    LaboratoryEquipment ||--o{ EquipmentMaintenance : "laboratory_equipment_id"
    Laboratory ||--o{ TestMethod : "laboratory_id"
    ControlledDocument ||--o{ TestMethod : "procedure_document_id"
    TestSpecification ||--o{ TestSpecificationItem : "test_specification_id"
    TestMethod ||--o{ TestSpecificationItem : "test_method_id"
    Person ||--o{ PersonCompetency : "person_id"
    Competency ||--o{ PersonCompetency : "competency_id"
    Laboratory ||--o{ LaboratoryReport : "laboratory_id"
    LaboratoryReport ||--o{ LaboratoryReportSample : "laboratory_report_id"

Reading the Diagrams

  • A ||--o{ B means one row of A is referenced by many rows of B (the label is the foreign-key column on B).
  • These static diagrams show principal links only — cross-cutting references (person_id roles on almost every model, attachment_id evidence links, site_id/laboratory_id scoping) are omitted for readability. The interactive viewer's Full ERD shows all 164, with the people/attachment noise toggleable.
  • Sample is the hub of the domain — the viewer's Focus mode defaults to it.

Diagrams are derived from the generated schema metadata (apps/mine_labcm/generated/json/mine_labcm_relationship_metadata.json). If the DSL schema changes, regenerate the metadata (python -m codegen.cli all mine_labcm) and update this page and the viewer's embedded data.