@startuml
hide circle
skinparam linetype ortho

entity users {
  * id : BIGSERIAL <<PK>>
  --
  email : VARCHAR
  password : VARCHAR
  role : VARCHAR
  unique_user_id : CHAR(12)
  display_name : VARCHAR
  fcm_token : VARCHAR
  created_at : TIMESTAMP
}

entity pairing_relations {
  * id : BIGSERIAL <<PK>>
  --
  guardian_id : BIGINT <<FK>>
  user_id : BIGINT <<FK>>
  status : VARCHAR
  invited_at : TIMESTAMP
  responded_at : TIMESTAMP
}

entity activity_logs {
  * id : BIGSERIAL <<PK>>
  --
  user_id : BIGINT <<FK>>
  log_type : VARCHAR
  description : TEXT
  metadata : JSONB
  created_at : TIMESTAMP
}

entity obstacle_logs {
  * id : BIGSERIAL <<PK>>
  --
  user_id : BIGINT <<FK>>
  label : VARCHAR
  confidence : FLOAT
  direction : VARCHAR
  estimated_dist : VARCHAR
  lat : DOUBLE
  lng : DOUBLE
}

entity location_history {
  * id : BIGSERIAL <<PK>>
  --
  user_id : BIGINT <<FK>>
  lat : DOUBLE
  lng : DOUBLE
  accuracy : FLOAT
  speed : FLOAT
  heading : FLOAT
}

entity guardian_notifications {
  * id : BIGSERIAL <<PK>>
  --
  guardian_id : BIGINT <<FK>>
  user_id : BIGINT <<FK>>
  notif_type : VARCHAR
  content : TEXT
  is_read : BOOLEAN
}

entity sos_events {
  * id : BIGSERIAL <<PK>>
  --
  user_id : BIGINT <<FK>>
  trigger_type : VARCHAR
  lat : DOUBLE
  lng : DOUBLE
  status : VARCHAR
}

entity user_settings
entity ai_configs
entity voice_command_configs
entity hardware_shortcuts
entity geofence_configs
entity refresh_tokens

users ||--o{ pairing_relations : guardian_id
users ||--o{ pairing_relations : user_id
users ||--o{ activity_logs
users ||--o{ obstacle_logs
users ||--o{ location_history
users ||--o{ guardian_notifications : guardian_id
users ||--o{ guardian_notifications : user_id
users ||--o{ sos_events
users ||--o| user_settings
users ||--o{ refresh_tokens
pairing_relations ||--o| ai_configs
pairing_relations ||--o{ voice_command_configs
pairing_relations ||--o{ hardware_shortcuts
pairing_relations ||--o| geofence_configs
@enduml
