-
Notifications
You must be signed in to change notification settings - Fork 0
Domain Model
James Brucker edited this page Jul 21, 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?
}
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.
| Suggested Name | Rationale |
|---|---|
value_units |
Clear, concise. Maps "value name" → "unit". |
units_by_name |
Emphasizes that units are keyed by value name. |
measurement_units |
Semantically clear; aligns with concept of "measured values and their units". |
reading_units |
Suitable if each value is a readout from a device or sensor. |
value_definitions |
General but semantically appropriate if additional metadata might be added. |
named_units |
Highlights that each unit is tied to a named value. |
metrics |
Very concise; common in telemetry contexts, though slightly abstract. |
reading_format |
Suggests how readings are structured; suitable if used for validation. |
value_schema |
Indicates both the names and expected units, with potential extensibility. |
reading_schema |
Same intent as value_schema. |
schema |
If the dict defines the structure of readings, this is a semantically rich choice. |
Which to Choose?
-
Simplicity: If the dictionary will remain a simple mapping of name -> unit, then
value_unitsis ideal. -
Clarity & Extensibility:
value_unitsorvalue_schemastrike a good balance between conciseness and semantic clarity. - **Extensibility
:value_schema` if there's potential to include more metadata per value, e.g., description, valid range.