Data Model
Eight Prisma models, every activity scoped to a user, and classification applied at read time.
Every row that matters is scoped to a user. There are no shared tables and no global mutable state.
The eight models
| Model | Purpose |
|---|---|
| User | Identity, credentials and profile |
| Activity | One contiguous block of tracked time |
| FocusSession | A deliberate focus session |
| Goal | A daily or weekly target in minutes |
| CategoryOverride | Per-user reclassification of an app or domain |
| UserSettings | Focus durations and tracking preferences, one row per user |
| ExtensionStatus | Last heartbeat and last known control state |
| ExtensionControl | Pending and acknowledged remote commands |
The Activity model
model Activity {
id String @id @default(cuid())
userId String
source String // "desktop" | "browser"
appName String?
domain String?
title String? // browser only
category String
startedAt DateTime
endedAt DateTime
durationMinutes Int
user User @relation(fields: [userId], references: [id])
@@index([userId, startedAt])
}A row is a contiguous block, not an aggregate. Two visits to the same application separated by lunch are two rows.
Focus sessions
FocusSession is deliberately small: mode, planned and elapsed duration, completion timestamp. It stores nothing about what you did during the session because Activity already describes that.
Goals
model Goal {
id String @id @default(cuid())
userId String
type String // "productive" | "focus"
category String?
targetMinutes Int
period String // "daily" | "weekly" | "monthly"
}Overrides and classification
Default rules live in code. CategoryOverride layers one user's correction on top, keyed by appName or domain. Overrides are read at query time, so correcting a classification rewrites history without a migration.
Two category sets exist
| Activity category | Kind |
|---|---|
| Development, Work, Research, Learning, Productivity, AI / Research, Design | focus |
| Communication, Other | neutral |
| Entertainment, Social Media, News, Shopping | distract |
Schema changes
cd server
npx prisma migrate dev --name add_focus_sessions
npx prisma generate