Skip to main content

Database Schema Documentation

This document provides comprehensive documentation for the KiraPilot database schema.

Generated on: 2025-08-24T14:14:12.213Z

Table of Contents

Overview

KiraPilot uses SQLite as its database engine with SeaORM as the ORM layer. The database is designed to support:

  • Task management with hierarchical relationships
  • Time tracking and session management
  • AI interaction history
  • User preferences and settings
  • Productivity analytics and patterns

Tables

ai_interactions

ColumnTypeNullableKeyDescription
idStringPKUnique identifier for the record
messageStringmessage field
responseStringresponse field
action_takenStringaction taken field
reasoningStringreasoning field
tools_usedStringtools used field
confidencef64confidence field
created_atDateTimeUtcTimestamp when the record was created

ai_suggestions

ColumnTypeNullableKeyDescription
idStringPKUnique identifier for the record
suggestion_typeStringsuggestion type field
titleStringTitle or name of the item
descriptionStringDetailed description
confidencef64confidence field
actionableboolactionable field
priorityi32Priority level
estimated_impactf64estimated impact field
reasoningStringreasoning field
actionsStringactions field
created_atDateTimeUtcTimestamp when the record was created
dismissed_atDateTimeUtcdismissed at field
applied_atDateTimeUtcapplied at field

focus_sessions

ColumnTypeNullableKeyDescription
idStringPKUnique identifier for the record
task_idStringFKReference to the associated task
planned_durationi32planned duration field
actual_durationi32actual duration field
focus_scoref64focus score field
distraction_counti32distraction count field
distraction_levelStringdistraction level field
background_audioStringbackground audio field
notesStringnotes field
breaksStringbreaks field
metricsStringmetrics field
created_atDateTimeUtcTimestamp when the record was created
completed_atDateTimeUtccompleted at field

productivity_patterns

ColumnTypeNullableKeyDescription
idStringPKUnique identifier for the record
user_idStringFKReference to the user
pattern_typeStringpattern type field
time_slotStringtime slot field
productivity_scoref64productivity score field
confidence_levelf64confidence level field
sample_sizei32sample size field
created_atDateTimeUtcTimestamp when the record was created
updated_atDateTimeUtcTimestamp when the record was last updated

task_dependencies

ColumnTypeNullableKeyDescription
idStringPKUnique identifier for the record
task_idStringFKReference to the associated task
depends_on_idStringFKdepends on id field
created_atDateTimeUtcTimestamp when the record was created

task_lists

ColumnTypeNullableKeyDescription
idStringPKUnique identifier for the record
nameStringname field
is_defaultboolis default field
created_atDateTimeUtcTimestamp when the record was created
updated_atDateTimeUtcTimestamp when the record was last updated

Relationships:

  • has many → tasks

tasks

ColumnTypeNullableKeyDescription
idStringPKUnique identifier for the record
titleStringTitle or name of the item
descriptionStringDetailed description
priorityi32Priority level
statusStringCurrent status of the item
dependenciesStringdependencies field
time_estimatei32time estimate field
actual_timei32actual time field
due_dateDateTimeUtcDue date for completion
scheduled_dateDateTimeUtcScheduled date for execution
tagsStringtags field
project_idStringFKproject id field
parent_task_idStringFKparent task id field
task_list_idStringFKReference to the task list
subtasksStringsubtasks field
completed_atDateTimeUtccompleted at field
created_atDateTimeUtcTimestamp when the record was created
updated_atDateTimeUtcTimestamp when the record was last updated

Relationships:

  • has many → task_dependencies
  • has many → time_sessions
  • has many → focus_sessions

time_sessions

ColumnTypeNullableKeyDescription
idStringPKUnique identifier for the record
task_idStringFKReference to the associated task
start_timeDateTimeUtcStart time of the session
end_timeDateTimeUtcEnd time of the session
paused_timei32paused time field
is_activeboolis active field
notesStringnotes field
breaksStringbreaks field
created_atDateTimeUtcTimestamp when the record was created

user_preferences

ColumnTypeNullableKeyDescription
idStringPKUnique identifier for the record
working_hoursStringworking hours field
break_preferencesStringbreak preferences field
focus_preferencesStringfocus preferences field
notificationsStringnotifications field
themeStringtheme field
languageStringlanguage field
created_atDateTimeUtcTimestamp when the record was created
updated_atDateTimeUtcTimestamp when the record was last updated

Relationships

The following diagram shows the relationships between tables:

erDiagram
AI_INTERACTIONS {
varchar id PK
varchar message
varchar response
varchar action_taken "nullable"
varchar reasoning "nullable"
varchar tools_used "nullable"
f64 confidence "nullable"
datetime created_at
}
AI_SUGGESTIONS {
varchar id PK
varchar suggestion_type
varchar title
varchar description
f64 confidence
boolean actionable
int priority
f64 estimated_impact
varchar reasoning "nullable"
varchar actions "nullable"
datetime created_at
datetime dismissed_at "nullable"
datetime applied_at "nullable"
}
FOCUS_SESSIONS {
varchar id PK
varchar task_id FK
int planned_duration
int actual_duration "nullable"
f64 focus_score "nullable"
int distraction_count
varchar distraction_level
varchar background_audio "nullable"
varchar notes "nullable"
varchar breaks "nullable"
varchar metrics "nullable"
datetime created_at
datetime completed_at "nullable"
}
PRODUCTIVITY_PATTERNS {
varchar id PK
varchar user_id FK
varchar pattern_type
varchar time_slot
f64 productivity_score
f64 confidence_level
int sample_size
datetime created_at
datetime updated_at
}
TASK_DEPENDENCIES {
varchar id PK
varchar task_id FK
varchar depends_on_id FK
datetime created_at
}
TASK_LISTS {
varchar id PK
varchar name
boolean is_default
datetime created_at
datetime updated_at
}
TASKS {
varchar id PK
varchar title
varchar description "nullable"
int priority
varchar status
varchar dependencies "nullable"
int time_estimate
int actual_time
datetime due_date "nullable"
datetime scheduled_date "nullable"
varchar tags "nullable"
varchar project_id FK "nullable"
varchar parent_task_id FK "nullable"
varchar task_list_id FK "nullable"
varchar subtasks "nullable"
datetime completed_at "nullable"
datetime created_at
datetime updated_at
}
TIME_SESSIONS {
varchar id PK
varchar task_id FK
datetime start_time
datetime end_time "nullable"
int paused_time
boolean is_active
varchar notes "nullable"
varchar breaks "nullable"
datetime created_at
}
USER_PREFERENCES {
varchar id PK
varchar working_hours
varchar break_preferences
varchar focus_preferences
varchar notifications
varchar theme "nullable"
varchar language "nullable"
datetime created_at
datetime updated_at
}
TASK_LISTS ||--o{ TASKS : "has_many"
TASKS ||--o{ TASK_DEPENDENCIES : "has_many"
TASKS ||--o{ TIME_SESSIONS : "has_many"
TASKS ||--o{ FOCUS_SESSIONS : "has_many"

Migration History

TimestampDescriptionOperations
20240101_000001create tasks tablecreate_table
20240101_000002create task dependencies tablecreate_table, create_index
20240101_000003create time sessions tablecreate_table
20240101_000004create ai interactions tablecreate_table
20240101_000005create focus sessions tablecreate_table
20240101_000006create productivity patterns tablecreate_table
20240101_000007create user preferences tablecreate_table
20240101_000008create ai suggestions tablecreate_table
20240101_000009create indexescreate_index, create_index, create_index, create_index, create_index, create_index, create_index, create_index, create_index, create_index, create_index, create_index, create_index, create_index, create_index, create_index, create_index
20240101_000010create task lists tablecreate_table, create_index
20240101_000011add task list id to taskscreate_index
20240101_000012fix task lists unique index

Migration Details

create tasks table (20240101_000001)

Operations:

  • Create table

create task dependencies table (20240101_000002)

Operations:

  • Create table
  • Create index

create time sessions table (20240101_000003)

Operations:

  • Create table

create ai interactions table (20240101_000004)

Operations:

  • Create table

create focus sessions table (20240101_000005)

Operations:

  • Create table

create productivity patterns table (20240101_000006)

Operations:

  • Create table

create user preferences table (20240101_000007)

Operations:

  • Create table

create ai suggestions table (20240101_000008)

Operations:

  • Create table

create indexes (20240101_000009)

Operations:

  • Create index
  • Create index
  • Create index
  • Create index
  • Create index
  • Create index
  • Create index
  • Create index
  • Create index
  • Create index
  • Create index
  • Create index
  • Create index
  • Create index
  • Create index
  • Create index
  • Create index

create task lists table (20240101_000010)

Operations:

  • Create table
  • Create index

add task list id to tasks (20240101_000011)

Operations:

  • Create index

fix task lists unique index (20240101_000012)