Skip to content

Domain Model

James Brucker edited this page Jul 18, 2025 · 14 revisions

Initial domain model

classDiagram
    User --> "*" DataSource: owns
    DataSource <-- "*" Reading: values from
    DataSource --> "0..1" Location

    class User {
        email: EmailStr
        username: string
        created_at: Datetime
        updated_at: Datetime

    }
    class DataSource {
        name: string
        description: string
        owner: User
        data: Map[string,string]
        units: string[*]
    }
    class Reading {
        timestamp: Datetime
        created_by: User
        values: Map[string,Any]
    }
    class Location {
        name
        address
        coordinates?
    }
Loading

The id attribute of model classes is not part of the domain model, hence not shown.

In DataSource the data is a dict of measurement_name: unit_name for values read from the data source. Use a dict even if there is only one value per reading, e.g. electric meter.

In Reading the values is a dict of measurement_name: value, where value is the actual (numeric) value of some measurement, and measurement_name matches one of the keys defined in the corresponding DataSource data dict.

The timestamp is the date/time of the reading value, which may not be same as when the values were entered (created_at).

Reading.values may be implemented as a dict (Map), with value names as keys.

Clone this wiki locally