Skip to main content
The CharleOS database schema is defined in lib/db/schema.ts with 47 tables organized into functional groups. This page provides a comprehensive reference.

Schema Overview

Entity Relationships

Core Tables

Authentication & Users

user - Team Members

Internal team members who use CharleOS. Access Levels:
  • Admin: Full system access (Luke)
  • Manager: Management access (Simon, Andre, Ben, Nic)
  • Staff: Standard access (developers, designers, PMs, CSMs)
Work Types:
  • development, design, qa: Individual Contributors (ICs)
  • pm: Project Managers
  • csm: Client Success Managers
  • sdr: Sales Development Representatives

session & account

Better Auth tables for session management and OAuth accounts.
  • session: Active login sessions (expires after 7 days)
  • account: OAuth provider connections (Google)

user_preference

User UI preferences (key-value store).

Client Management

client - Client Companies

Companies that hire Charle for work.

client_period - Billing Periods

Tracks budget usage per billing period (monthly).

client_deliverability_score - Scoring

Tracks how actual task times compare to quoted estimates per client. Score interpretation:
  • 1.00 = Tasks match estimates exactly
  • 1.15 = Tasks take 15% longer than quoted
  • 0.90 = Tasks complete 10% faster than quoted
Confidence levels:
  • low (< 5 tasks): Don’t use for scheduling
  • medium (5-15 tasks): Use with caution
  • high (15+ tasks): Reliable for scheduling

client_score_history - Score Audit

Audit trail for score changes.

client_user - Client Portal Users

Client employees who access the client portal. Separate Auth System:
  • Client portal uses Better Auth with separate tables
  • client_session for sessions
  • client_account for credentials
  • Completely isolated from team auth

plan - Pricing Tiers

Retainer plan configurations.

Quote System

quote - Work Requests

Requests for work that go through approval workflow. Quote Workflow:
  1. awaiting_quote - Created, needs scoping
  2. in_progress - Being scoped by team
  3. quoted - Ready for internal review
  4. awaiting_client_approval - Sent to client
  5. approved - Client approved (converts to task)
  6. cancelled - Client cancelled

quote_requirement - Requirement Blocks

Individual work items within a quote. AI Suggestions: When a quote requirement is created, Alan automatically generates a t-shirt size suggestion based on the brief and client history. The suggestion is stored against the requirement for team review. T-shirt Sizing:
  • XS: 15-30 min
  • S: 30-60 min
  • M: 1-4 hours
  • L: 4-8 hours
  • XL: 8-16 hours
  • XXL: 16-32 hours
80/20 Split:
  • Core work (80%) rounded down
  • QA/feedback budget (20%) rounded up to nearest 15 min

Task System

task - Approved Work

Work items created from approved quotes or directly. Outlier Tasks: Tasks that deviate significantly (>130%) from quoted can be flagged as outliers. Outliers are excluded from client deliverability score calculations to prevent anomalous tasks from skewing the data.

subtask - Task Phases

Individual work phases within a task. Subtask Types: Design Phase:
  • design - Initial design work
  • client_design_feedback - Feedback round
Development Phase:
  • development - Build work
  • internal_qa_fixes - Internal QA fixes
  • external_qa_fixes - Client QA fixes
QA Phase:
  • internal_qa_review - Internal review
  • external_qa_review - Client review
Deployment:
  • deployment - Deploy to production

Time Tracking

time_entry - Logged Time

Time logged against clients, tasks, and subtasks.

Projects

project - Multi-Phase Projects

Long-running projects with budgeted phases.

project_phase - Budgeted Phases

Budget allocations within a project.

Scheduling

client_block - Scheduled Work

Blocks of scheduled time on the calendar.

Metrics & Reporting

metric_snapshot - Daily Metrics

Daily snapshots of utilization, day rates, and efficiency.

Help Desk

help_desk_ticket - Support Tickets

Client support requests (converted to subtasks). AI Suggestions: When a support ticket is created, Alan automatically generates a time estimate suggestion based on ticket content and client history. The suggestion is stored against the ticket for PM review.

help_desk_deliverability_score - Help Desk Scoring

Tracks how actual help desk ticket times compare to estimated times. Similar to client_deliverability_score but specifically for help desk tickets.

help_desk_score_history - Score Audit

Records changes to help desk scoring for audit purposes.

Annual Leave

annual_leave - Leave Requests

Team member leave requests and approvals.

RAG Reports

rag_report - Client Status Reports

Weekly Red/Amber/Green client health reports.

Enums Reference

User & Access

Task & Subtask

Quote

Type Inference

Drizzle automatically generates TypeScript types from the schema:

Relationships

Foreign Keys

All relationships use foreign keys with appropriate cascade rules:
  • onDelete: "cascade" - Delete children when parent is deleted
  • onDelete: "set null" - Set to null when parent is deleted
  • Default: Restrict deletion if children exist

Common Joins

Modifying the Schema

1

Edit Schema File

Modify lib/db/schema.ts to add/change tables or columns
2

Test Locally

Applies changes to local dev database instantly
3

Verify in Studio

Browse updated schema visually
4

Generate Migration

Creates SQL migration file for production
5

Commit & Deploy

Commit schema + migration files. Migrations run automatically on deployment.

Database Overview

Database architecture and tools

Drizzle ORM

Query syntax and patterns

Migrations

Managing schema changes