Data Model¶
Smart Estate uses PostgreSQL as the system of record.
Main Tables¶
users¶
- Stores tenant, technician, admin, manager, and operations accounts.
- Key fields:
idnameemailpassword_hashrolestatusbuilding_idlast_seen_at
tickets¶
- Stores each maintenance request and its lifecycle state.
- Key fields:
idtitledescriptioncreated_bybuilding_idapartment_idassigned_technician_idstatuspriorityai_resultresponse_due_atresolution_due_atsla_statusescalatedescalation_levelstarted_atdispatched_atcompleted_atduration_minutes
sla_rules¶
- Stores priority-based SLA windows.
- Key fields:
priorityresponse_time_minutesresolution_time_hoursescalation_time_hours
ai_logs¶
- Stores the AI decision trail for ticket classification.
- Key fields:
ticket_idpredicted_categoryactual_categoryconfidence_scoreauto_assignedmodel_version
Supporting Tables¶
buildingsstores property metadata.apartmentsstores unit-level occupancy and tenant assignment.messagesstores ticket chat messages.mediastores uploaded file references for tickets.audit_logsstores operational history.technician_profilesstores technician skills, status, workload, and location.system_settingsstores global configuration.manager_building_assignmentsstores manager access scope.
Relationships¶
users (tenant/technician/admin/manager/operations)
|\
| \-- creates --> tickets
| |\
| | \-- belongs to --> buildings
| | \-- belongs to --> apartments
| | \-- assigned to --> users (technician)
| | \-- has --> ai_logs
| | \-- has --> messages
| | \-- has --> media
|
\-- writes --> audit_logs
Key Field Behavior¶
sla_status¶
- Stored on
tickets. - Valid values:
on_track,at_risk,breached.
escalation_level¶
- Counts how many escalation windows have elapsed.
- Used by the dashboard and SLA views.
confidence_score¶
- Stored in
ai_logs. - Represents AI confidence for the predicted category.
- Feeds the dashboard AI confidence metric.
Data Flow Summary¶
Ticket creation
-> tickets row
-> ai_result JSON
-> ai_logs row
-> SLA timestamps
-> assignment / messages / audit logs as work continues