Skip to content

amanyrath/daybreak

Repository files navigation

Daybreak Health Intake System

An AI-powered mental health intake assessment system that streamlines patient onboarding through intelligent conversation, automated insurance verification, and data-driven therapist matching.

Overview

This Next.js application provides a complete patient intake experience combining:

  • Conversational AI for empathetic assessment
  • OCR Technology for insurance card scanning
  • Smart Matching for optimal therapist selection
  • Automated Scheduling with availability matching
  • PDF Summaries for patient records

Target Completion Time: 15-20 minutes

Features

1. Patient Information Collection

  • Demographics form with validation
  • Guardian information for minors
  • Insurance information with OCR scanning
  • HEIC image format support (iOS photos)
  • Manual data correction capability

2. AI-Powered Assessment

  • Natural conversation flow with GPT-4 Turbo
  • Crisis detection with immediate resources
  • Section-based progression (welcome, assessment, demographics, insurance, scheduling)
  • Voice input capability for accessibility
  • Chat history and context awareness

3. Insurance & Cost Estimation

  • Insurance card photo upload (front/back)
  • Automatic OCR text extraction
  • Real-time plan lookup
  • Clear cost breakdown:
    • Per-session cost
    • Deductible information
    • Coverage percentage
    • Network status

4. Therapist Matching

  • CSV-based algorithm using real clinician data
  • Multi-factor scoring:
    • Insurance compatibility (50 points)
    • Schedule availability match (40 points)
    • Availability presence (10 points)
  • Top 10 recommendations with match explanations
  • Age-appropriate therapist selection

5. Appointment Scheduling

  • Weekly availability selector
  • Time block preferences (morning/afternoon/evening)
  • Timezone-aware scheduling
  • Available slot display from matched therapist
  • One-click appointment confirmation

6. Session Management

  • Visual progress tracking (0%, 33%, 66%, 100%)
  • Save & Exit with 6-digit PIN code
  • Resume session capability (7-day expiration)
  • Time estimation and elapsed time tracking
  • localStorage persistence for data recovery

7. Summary & PDF Generation

  • Comprehensive intake summary
  • Patient information display
  • Chat statistics and key topics
  • Cost estimate details
  • Therapist match information
  • Session timeline
  • Professional PDF download

Quick Start

Prerequisites

Installation

# Clone the repository
git clone [repository-url]
cd db_onboard

# Install dependencies
npm install

# Set up environment variables
cp .env.local.example .env.local
# Edit .env.local and add your OpenAI API key:
# NEXT_PUBLIC_OPENAI_API_KEY=sk-your-actual-api-key-here

# Run development server
npm run dev

Open http://localhost:3000 to start using the application.

Available Scripts

npm run dev        # Start development server
npm run build      # Create production build
npm run start      # Run production server
npm run lint       # Run ESLint
npm run proxy      # Start WebSocket proxy (for voice features)
npm run dev:full   # Run dev server + proxy concurrently

Project Structure

db_onboard/
β”œβ”€β”€ docs/                          # Documentation
β”‚   β”œβ”€β”€ architecture/             # System design documents
β”‚   β”œβ”€β”€ features/                 # Feature-specific docs
β”‚   └── implementation/           # Implementation tracking
β”œβ”€β”€ memory-bank/                   # Project memory
β”‚   β”œβ”€β”€ projectbrief.md           # Project overview
β”‚   β”œβ”€β”€ productContext.md         # Product goals and UX
β”‚   β”œβ”€β”€ activeContext.md          # Current work focus
β”‚   β”œβ”€β”€ systemPatterns.md         # Architecture patterns
β”‚   β”œβ”€β”€ techContext.md            # Technology stack
β”‚   └── progress.md               # Status and roadmap
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                      # Next.js app router
β”‚   β”‚   β”œβ”€β”€ api/                  # API routes
β”‚   β”‚   β”œβ”€β”€ intake/               # Intake flow pages
β”‚   β”‚   └── test-*/               # Feature test pages
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ chat/                 # Chat interface
β”‚   β”‚   β”œβ”€β”€ forms/                # Form components
β”‚   β”‚   β”œβ”€β”€ insurance/            # Insurance features
β”‚   β”‚   β”œβ”€β”€ layout/               # Layout components
β”‚   β”‚   β”œβ”€β”€ matching/             # Therapist matching
β”‚   β”‚   β”œβ”€β”€ scheduling/           # Scheduling UI
β”‚   β”‚   β”œβ”€β”€ summary/              # Summary & PDF
β”‚   β”‚   └── voice/                # Voice input
β”‚   β”œβ”€β”€ data/                     # Static data (JSON)
β”‚   └── lib/
β”‚       β”œβ”€β”€ api/                  # OpenAI integration
β”‚       β”œβ”€β”€ stores/               # Zustand state management
β”‚       β”œβ”€β”€ types/                # TypeScript types
β”‚       β”œβ”€β”€ utils/                # Utility functions
β”‚       └── voice/                # Voice processing
β”œβ”€β”€ data/                          # Test data and CSV files
β”‚   └── Daybreak Health Test Cases/  # Real clinician data
β”œβ”€β”€ public/                        # Static assets
β”œβ”€β”€ .env.local                     # Environment variables (create this)
β”œβ”€β”€ package.json                   # Dependencies
β”œβ”€β”€ README.md                      # This file
└── SETUP.md                       # Detailed setup guide

Documentation

Getting Started

Project Context (Memory Bank)

The memory-bank directory contains the complete project knowledge base:

Technical Documentation

Architecture (docs/architecture/)

Features (docs/features/)

Implementation Status (docs/implementation/)

Data Schema

Component Documentation

Component-specific READMEs are co-located with components:

Technology Stack

Core

  • Next.js 15.1.3 - React framework with App Router
  • React 19 - UI library
  • TypeScript 5 - Type safety
  • Tailwind CSS 3.4 - Styling

AI & Processing

  • OpenAI GPT-4 Turbo - Conversational AI
  • Tesseract.js - OCR for insurance cards
  • Whisper API - Voice transcription

State & Data

  • Zustand 5.0 - State management with persistence
  • date-fns - Date manipulation
  • CSV parsing - Client-side data processing

UI & UX

  • Framer Motion - Animations
  • Lucide React - Icons
  • jsPDF - PDF generation
  • html2canvas - Screenshot capability

Utilities

  • heic2any - iOS image format support
  • WebSocket - Real-time voice communication

Key Workflows

1. Patient Intake Flow

Welcome β†’ Demographics β†’ Insurance β†’ Assessment β†’ Scheduling β†’ Confirmation β†’ Summary

2. Therapist Matching Flow

Patient Data β†’ CSV Parse β†’ Scoring Algorithm β†’ Ranked Results β†’ Selection β†’ Appointment

3. Conversation Flow

User Message β†’ Crisis Check β†’ Answer Extract β†’ Save β†’ Section Check β†’ Next Question or Summary

Testing

Test Pages

The application includes dedicated test pages for each feature:

  • /test-csv-matching - Test therapist matching with sample data
  • /test-insurance - Test insurance OCR and cost estimation
  • /test-matching - Test matching algorithm
  • /test-scheduling - Test scheduling interface

Running Tests

npm test              # Run unit tests
npm run test:watch    # Watch mode
npm run test:coverage # Coverage report

Development Features

Section Jumper (Dev Tool)

Access the section jumper in development mode to quickly navigate between intake sections:

  • Press keyboard shortcut (check component)
  • Or use the floating dev tool button

Environment Variables

# Required
NEXT_PUBLIC_OPENAI_API_KEY=sk-...

# Optional (Future)
DATABASE_URL=
API_BASE_URL=
SENTRY_DSN=

Deployment

Build for Production

npm run build
npm run start

Deployment Platforms

  • Vercel (recommended) - One-click deployment
  • AWS - Full control
  • DigitalOcean - Simple and affordable

Pre-Production Checklist

  • Move OpenAI API key server-side
  • Set up backend database
  • Configure error monitoring (Sentry)
  • Enable analytics
  • Set up CORS properly
  • Implement rate limiting
  • Security audit
  • HIPAA compliance review

Security & Privacy

Current State (Development)

  • Input sanitization implemented
  • Crisis detection active
  • localStorage for data persistence
  • Client-side API calls (development only)

Production Requirements

  • Move API calls server-side
  • Implement authentication
  • HTTPS everywhere
  • Data encryption at rest
  • HIPAA compliance
  • Audit logging
  • BAA with vendors

Performance

Current Metrics (Dev)

  • Bundle size: ~450KB (gzipped)
  • Initial load: ~2s
  • CSV parsing: ~50ms (400 rows)
  • Matching: ~10ms (50 therapists)

Optimization Targets

  • Bundle size: < 400KB
  • Initial load: < 1.5s
  • Lighthouse score: > 90

Browser Support

  • Chrome 90+ βœ…
  • Firefox 88+ βœ…
  • Safari 14+ βœ…
  • Edge 90+ βœ…
  • Mobile browsers (iOS Safari 14+, Chrome for Android) βœ…

Known Issues

High Priority

  • API key is client-side (security concern for production)
  • Test coverage needs improvement

Medium Priority

  • Some test files need updating after refactors
  • Voice WebSocket proxy error recovery

Low Priority

  • Bundle size could be optimized
  • Code splitting not fully optimized

See Progress for complete list.

Contributing

Development Workflow

  1. Create feature branch
  2. Make changes with TypeScript types
  3. Add/update tests
  4. Update documentation
  5. Run linter: npm run lint
  6. Submit pull request

Code Style

  • TypeScript strict mode
  • Functional components with hooks
  • Tailwind for styling
  • ESLint rules enforced

Roadmap

Completed βœ…

  • Core intake flow
  • AI conversation system
  • Insurance OCR and cost estimation
  • CSV-based therapist matching
  • Appointment scheduling
  • PDF summary generation
  • Voice input capability
  • Session save/resume

In Progress 🚧

  • Documentation organization
  • Test coverage improvement

Planned πŸ“‹

  • Backend API and database
  • Email notifications
  • Admin dashboard
  • Real-time availability updates
  • Mobile app (React Native)
  • EHR integration

See Progress for detailed roadmap.

Support

Documentation

Common Issues

"OpenAI API key is not configured"

  • Create .env.local with your API key
  • Restart dev server

CSV files not loading

  • Check webpack config in next.config.ts
  • Ensure CSV files exist in data/Daybreak Health Test Cases/

HEIC images not converting

  • Ensure heic2any is installed
  • Check browser console for errors

License

Private - Daybreak Health

Acknowledgments

  • OpenAI for GPT-4 Turbo API
  • Next.js team for excellent framework
  • Open source community for libraries

Built with ❀️ for better mental health care access

For detailed setup instructions, see SETUP.md

For project architecture and patterns, see memory-bank/systemPatterns.md

About

Gauntlet Week 5 Daybreak

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors