An AI-powered mental health intake assessment system that streamlines patient onboarding through intelligent conversation, automated insurance verification, and data-driven therapist matching.
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
- Demographics form with validation
- Guardian information for minors
- Insurance information with OCR scanning
- HEIC image format support (iOS photos)
- Manual data correction capability
- 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
- 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
- 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
- Weekly availability selector
- Time block preferences (morning/afternoon/evening)
- Timezone-aware scheduling
- Available slot display from matched therapist
- One-click appointment confirmation
- 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
- Comprehensive intake summary
- Patient information display
- Chat statistics and key topics
- Cost estimate details
- Therapist match information
- Session timeline
- Professional PDF download
- Node.js 18 or higher
- OpenAI API key (Get one here)
# 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 devOpen http://localhost:3000 to start using the application.
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 concurrentlydb_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
- SETUP.md - Detailed installation and configuration guide
- docs/FILE_ORGANIZATION.md - Documentation structure overview
The memory-bank directory contains the complete project knowledge base:
- projectbrief.md - Project overview and requirements
- productContext.md - User experience and goals
- systemPatterns.md - Architecture and design patterns
- techContext.md - Technology stack and setup
- progress.md - Current status and roadmap
- activeContext.md - Current work focus
- SIMPLIFIED_CHAT_FLOW_SUMMARY.md - Conversation management
- chat-ai-flow-spec.md - AI integration details
- COST_ESTIMATION_DATA_ANALYSIS.md - Cost calculation logic
- CSV_MATCHING_README.md - Matching algorithm details
- THERAPIST_MATCHING_IMPLEMENTATION.md - Implementation guide
- SCHEDULING_IMPLEMENTATION.md - Scheduling system overview
- COMPLETE_FLOW_DOCUMENTATION.md - Full flow documentation
- FLOW_VERIFICATION.md - Flow testing and verification
- SECURITY_REFACTOR_COMPLETE.md - Security improvements
- WELCOME_FLOW_FIX.md - Welcome flow updates
- Additional implementation tracking files
- DATA_SCHEMA_DOCUMENTATION.md - CSV data structure
Component-specific READMEs are co-located with components:
- src/components/summary/README.md - PDF generation and display
- src/components/matching/README.md - Therapist selection UI
- src/components/scheduling/README.md - Availability selector
- Next.js 15.1.3 - React framework with App Router
- React 19 - UI library
- TypeScript 5 - Type safety
- Tailwind CSS 3.4 - Styling
- OpenAI GPT-4 Turbo - Conversational AI
- Tesseract.js - OCR for insurance cards
- Whisper API - Voice transcription
- Zustand 5.0 - State management with persistence
- date-fns - Date manipulation
- CSV parsing - Client-side data processing
- Framer Motion - Animations
- Lucide React - Icons
- jsPDF - PDF generation
- html2canvas - Screenshot capability
- heic2any - iOS image format support
- WebSocket - Real-time voice communication
Welcome β Demographics β Insurance β Assessment β Scheduling β Confirmation β Summary
Patient Data β CSV Parse β Scoring Algorithm β Ranked Results β Selection β Appointment
User Message β Crisis Check β Answer Extract β Save β Section Check β Next Question or Summary
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
npm test # Run unit tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage reportAccess the section jumper in development mode to quickly navigate between intake sections:
- Press keyboard shortcut (check component)
- Or use the floating dev tool button
# Required
NEXT_PUBLIC_OPENAI_API_KEY=sk-...
# Optional (Future)
DATABASE_URL=
API_BASE_URL=
SENTRY_DSN=npm run build
npm run start- Vercel (recommended) - One-click deployment
- AWS - Full control
- DigitalOcean - Simple and affordable
- 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
- Input sanitization implemented
- Crisis detection active
- localStorage for data persistence
- Client-side API calls (development only)
- Move API calls server-side
- Implement authentication
- HTTPS everywhere
- Data encryption at rest
- HIPAA compliance
- Audit logging
- BAA with vendors
- Bundle size: ~450KB (gzipped)
- Initial load: ~2s
- CSV parsing: ~50ms (400 rows)
- Matching: ~10ms (50 therapists)
- Bundle size: < 400KB
- Initial load: < 1.5s
- Lighthouse score: > 90
- Chrome 90+ β
- Firefox 88+ β
- Safari 14+ β
- Edge 90+ β
- Mobile browsers (iOS Safari 14+, Chrome for Android) β
- API key is client-side (security concern for production)
- Test coverage needs improvement
- Some test files need updating after refactors
- Voice WebSocket proxy error recovery
- Bundle size could be optimized
- Code splitting not fully optimized
See Progress for complete list.
- Create feature branch
- Make changes with TypeScript types
- Add/update tests
- Update documentation
- Run linter:
npm run lint - Submit pull request
- TypeScript strict mode
- Functional components with hooks
- Tailwind for styling
- ESLint rules enforced
- 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
- Documentation organization
- Test coverage improvement
- Backend API and database
- Email notifications
- Admin dashboard
- Real-time availability updates
- Mobile app (React Native)
- EHR integration
See Progress for detailed roadmap.
- Getting Started: SETUP.md for installation
- Project Context: memory-bank/ for complete project understanding
- Architecture: docs/architecture/ for system design
- Features: docs/features/ for feature implementation guides
- Components: Component READMEs (e.g.,
src/components/*/README.md) for component details - File Organization: docs/FILE_ORGANIZATION.md for documentation structure
"OpenAI API key is not configured"
- Create
.env.localwith 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
heic2anyis installed - Check browser console for errors
Private - Daybreak Health
- 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