SmartFall Docs

Database Models

Detailed model definitions for all 12 database entities.

User Model

Represents user accounts with authentication and role information.

FieldTypeDescription
idUUIDPrimary key
emailStringUnique email address
passwordHashStringbcrypt hashed password
firstNameStringUser's first name
lastNameStringUser's last name
roleEnumPATIENT, CAREGIVER, or ADMIN
createdAtDateTimeAccount creation time
updatedAtDateTimeLast modification time

Prisma Schema

model User {
  id            String   @id @default(cuid())
  email         String   @unique
  passwordHash  String
  firstName     String
  lastName      String
  role          Role     @default(PATIENT)
  createdAt     DateTime @default(now())
  updatedAt     DateTime @updatedAt

  sessions      Session[]
  patient       Patient?
  caregiver     Caregiver?
}

enum Role {
  PATIENT
  CAREGIVER
  ADMIN
}

Session Model

Stores user authentication sessions.

FieldTypeDescription
idUUIDPrimary key
userIdUUIDReference to User
tokenStringJWT token
expiresAtDateTimeSession expiration
ipAddressStringClient IP
userAgentStringBrowser/device info
createdAtDateTimeSession start

Patient Model

Patient profile for fall detection system users.

FieldTypeDescription
idUUIDPrimary key
userIdUUIDReference to User
dateOfBirthDateTimeDate of birth
emergencyContactStringPhone number
healthScoreIntCurrent health score (0-100)
riskScoreIntCurrent risk score (100 - healthScore)
isHighRiskBooleanRisk score >= 75
createdAtDateTimeProfile creation
updatedAtDateTimeLast update

Caregiver Model

Caregiver profile for monitoring users.

FieldTypeDescription
idUUIDPrimary key
userIdUUIDReference to User
phoneStringContact phone
specializationStringCare specialty
organizationStringEmployer/org
createdAtDateTimeProfile creation
updatedAtDateTimeLast update

CaregiverPatient Model

Junction table for caregiver-patient relationships.

FieldTypeDescription
idUUIDPrimary key
caregiverIdUUIDCaregiver reference
patientIdUUIDPatient reference
relationshipStringSon, Daughter, Nurse, etc.
assignedAtDateTimeAssignment date

Fall Model

Records fall events detected by the system.

FieldTypeDescription
idUUIDPrimary key
userIdUUIDPatient reference
deviceIdUUIDDevice that detected fall
confidenceFloatConfidence level (0-1)
statusEnumNO_FALL, SUSPICIOUS, POTENTIAL, HIGH, CONFIRMED
locationStringWhere fall occurred
witnessedBooleanWas it witnessed
injuriesStringInjury description
createdAtDateTimeEvent time

Status Values

StatusConfidenceAction
NO_FALL0.00-0.30None
SUSPICIOUS0.31-0.50Log event
POTENTIAL0.51-0.70Alert caregiver
HIGH0.71-0.89Notify + alert
CONFIRMED0.90-1.00Emergency protocol

Device Model

IoT wearable device information.

FieldTypeDescription
idUUIDPrimary key
userIdUUIDDevice owner
macAddressStringUnique MAC address
nameStringDevice name
statusEnumACTIVE, INACTIVE, OFFLINE, DISABLED
batteryLevelFloatBattery percentage (0-100)
firmwareVersionStringFirmware version
lastSeenDateTimeLast data received
createdAtDateTimeDevice registered
updatedAtDateTimeLast updated

SensorData Model

Time-series sensor readings from devices.

FieldTypeDescription
idUUIDPrimary key
deviceIdUUIDSource device
userIdUUIDDevice owner
accelX, Y, ZFloatAcceleration (m/s²)
gyroX, Y, ZFloatGyroscope (°/s)
pressureFloatAtmospheric (hPa)
fsrFloatFoot pressure (0-1)
heartRateIntHeart rate (bpm)
spo2IntOxygen level (%)
batteryFloatBattery level (%)
timestampDateTimeReading time
createdAtDateTimeRecord time

DeviceStatus Model

Current status snapshot of devices.

FieldTypeDescription
idUUIDPrimary key
deviceIdUUIDDevice reference
statusStringACTIVE, INACTIVE, OFFLINE, DISABLED
batteryLevelFloatCurrent battery (%)
signalStrengthIntWiFi/BLE signal (-120 to 0 dBm)
lastDataPointDateTimeLast reading timestamp
sensorsInitializedBooleanAll sensors ready
wifiConnectedBooleanWiFi connection status
bluetoothConnectedBooleanBLE connection status
uptimeIntMilliseconds online
updatedAtDateTimeLast status update

DeviceLog Model

Device activity and error logs.

FieldTypeDescription
idUUIDPrimary key
deviceIdUUIDDevice reference
typeEnumINFO, WARNING, ERROR
messageStringLog message
timestampDateTimeEvent time
createdAtDateTimeRecord time

HealthLog Model

Patient vital monitoring records.

FieldTypeDescription
idUUIDPrimary key
userIdUUIDPatient reference
heartRateIntHeart rate (bpm)
bloodPressureStringFormat: "SYS/DIA"
oxygenSaturationIntSpO2 (%)
healthScoreIntCalculated score (0-100)
riskScoreInt100 - healthScore
timestampDateTimeReading time
createdAtDateTimeRecord time

Message Model

User-to-user messaging.

FieldTypeDescription
idUUIDPrimary key
senderIdUUIDSender user
recipientIdUUIDRecipient user
contentStringMessage text
typeEnumTEXT, ALERT, NOTIFICATION
readBooleanRead status
createdAtDateTimeSend time
readAtDateTimeWhen read

Field Validation Rules

User

  • Email: Valid format, unique
  • Password Hash: Min 60 characters (bcrypt)
  • Names: Non-empty strings

Patient

  • Health Score: 0-100 integer
  • Risk Score: Calculated (100 - healthScore)
  • High Risk: Automatic (riskScore >= 75)

Fall

  • Confidence: 0.0 to 1.0 float
  • Status: Auto-determined from confidence

Device

  • MAC Address: Format AA:BB:CC:DD:EE:FF
  • Battery Level: 0.0 to 100.0
  • Status: One of defined enum values

SensorData

  • Acceleration: Typical -50 to +50 m/s²
  • Gyroscope: Typical -1000 to +1000 °/s
  • Heart Rate: 40-200 bpm
  • SpO2: 70-100%