Documentation

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

ModelPurpose
UserIdentity, credentials and profile
ActivityOne contiguous block of tracked time
FocusSessionA deliberate focus session
GoalA daily or weekly target in minutes
CategoryOverridePer-user reclassification of an app or domain
UserSettingsFocus durations and tracking preferences, one row per user
ExtensionStatusLast heartbeat and last known control state
ExtensionControlPending and acknowledged remote commands

The Activity model

prisma
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

prisma
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 categoryKind
Development, Work, Research, Learning, Productivity, AI / Research, Designfocus
Communication, Otherneutral
Entertainment, Social Media, News, Shoppingdistract

Schema changes

bash
cd server
npx prisma migrate dev --name add_focus_sessions
npx prisma generate