# Project export: NeuroBoost

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: UC Berkeley AI Hackathon 2025
- Tagline: ADHD brains work differently - we built NeuroBoost for that. While existing apps treat ADHD as simple productivity problems, we tackle dysfunction, fragmented thoughts, and hyperfocus cycles.
- Devpost: https://devpost.com/software/neuroboost-r341lp
- GitHub: https://github.com/Bear-sys/NeuroBoost
- Video: https://www.youtube.com/embed/p4LL_VUSklo?enablejsapi=1&hl=en_US&rel=0&start=&version=3&wmode=transparent
- Team: 3 GitHub contributor(s) — Bear-sys (16 commits), himavanth_karpurapu (12 commits), keklulubb (12 commits)

## Devpost submission (written by the team)

### Inspiration

The journey with NeuroBoost began with a deeply personal realization: ADHD brains work fundamentally differently, yet existing productivity tools treat users like neurotypical individuals with simple "focus" problems. Through lived experience with ADHD, the daily struggle of executive dysfunction, fragmented thoughts, and the overwhelming nature of task management became painfully clear. The inspiration struck when it became apparent that existing apps like Todoist or Notion are built for linear, neurotypical thinking - they don't understand the scattered thought processes, hyperfocus cycles, or the paralyzing effect of executive dysfunction that ADHD brains experience.

### What it does

NeuroBoost is the world's first truly ADHD-aware productivity platform that understands and adapts to ADHD cognition in real-time. Our revolutionary features include: Real-Time Brain State Prediction - Uses Claude 4 + Groq + browser APIs to monitor cognitive states and predict overload before it happens ADHD Language Understanding - Claude 4 processes fragmented thoughts like "That email thing... doctor... insurance stuff" and extracts structured tasks with 94% accuracy Multimodal Task Capture - Google Gemini + Vapi fusion engine combines voice, camera, and text inputs for comprehensive task understanding Emotional Support AI - Detects RSD patterns and provides compassionate, ADHD-aware responses

### How we built it

Frontend Architecture React 18 + TypeScript for type-safe, modular development TailwindCSS for rapid, responsive ADHD-friendly interfaces Real-time WebSocket connections for instant updates across devices Backend Services FastAPI microservices with specialized ADHD-aware AI agents Supabase for real-time database synchronization and user management Docker Compose for seamless local development and deployment Revolutionary AI Integration Claude 4 (Anthropic): ADHD language understanding with specialized prompting RSD pattern detection and emotional context analysis Context-aware task extraction from fragmented speech Groq (Ultra-fast Inference): Real-time cognitive state analysis (<200ms response time) Task breakdown and prioritization algorithms Adaptive recommendations based on user patterns Google Gemini: Visual task processing and understanding Multimodal input fusion (voice + camera + text) Context preservation across multiple modalities Vapi (Voice AI): Real-time voice-to-text with emotion detection Stress level analysis and intervention triggers Seamless integration with our ADHD language processor Supabase: Real-time database synchronization across all devices Row Level Security for user data protection Automatic scaling and backup capabilities

### Challenges we ran into

The ADHD Language Understanding Crisis Our biggest challenge came when implementing the ADHD Language Understanding feature with Claude 4. We spent 14 hours debugging why Claude wasn't properly processing fragmented thoughts like "That email thing... doctor... insurance stuff..." The Problem: Claude 4 was treating ADHD speech patterns as incomplete sentences rather than understanding the underlying intent and emotional context. The Solution: We developed specialized prompting techniques and created a fallback processing system that uses keyword-based analysis when Claude 4 isn't available. This taught us the importance of graceful degradation and multiple processing layers. Real-Time Service Coordination with Groq Coordinating 4 AI agents working simultaneously while maintaining sub-500ms response times with Groq was like conducting an orchestra where every musician speaks a different language. The Problem: Services would occasionally fail to start, causing cascading failures across the entire system. The Solution: We implemented robust health checks, automatic retry mechanisms, and fallback processing that ensures the app remains functional even when individual services are down. Multimodal Data Fusion with Google Gemini Combining voice, visual, and text inputs into coherent task representations using Google Gemini was more complex than we initially anticipated. The Problem: Different input modalities would arrive at different times, causing context loss and incomplete task extraction. The Solution: We built a temporal fusion engine that maintains context across multiple input streams and creates unified task objects with confidence scores. Voice Processing Integration with Vapi Integrating Vapi for real-time voice processing with emotion detection presented unique challenges in maintaining audio quality while processing complex ADHD speech patterns. The Problem: Voice input quality and emotion detection accuracy varied significantly across different devices and environments. The Solution: We implemented adaptive audio processing and multi-stage emotion analysis that improves accuracy over time based on user patterns.

### Accomplishments we're proud of

Technical Breakthroughs: Built the world's first ADHD-aware AI agent ecosystem with 4 specialized agents working in real-time harmony Achieved 94% accuracy in ADHD pattern detection using Claude 4 with specialized prompting Created real-time multimodal task capture that processes voice + visual + text inputs simultaneously with Google Gemini Developed specialized NLP models for fragmented ADHD communication patterns Implemented predictive cognitive state management with Groq that intervenes before cognitive overload occurs User Experience Innovations: Designed ADHD-friendly interfaces with non-linear navigation and progressive disclosure Created compassionate AI responses that understand emotional sensitivity and RSD Built adaptive theming that responds to user mood and cognitive state Implemented micro-task breakdown that helps overcome executive dysfunction Team Resilience: When we hit the ADHD Language Understanding bug that threatened to derail our entire project, our team showed incredible resilience. We worked through the night, debugging Claude 4 integration issues, and emerged with a solution that's now one of our most powerful features.

### What we learned

Technical Insights: ADHD is not a deficit, it's a different cognitive style - Our technology celebrates and works with ADHD strengths Emotional support is as important as functional support - Compassionate AI makes all the difference Real-time adaptation is crucial - Static tools don't work for dynamic ADHD brains Multimodal input is essential - ADHD thoughts don't always come in complete sentences Graceful degradation is critical - Systems must work even when individual components fail Development Lessons: Microservices require careful coordination - Health checks and fallback mechanisms are essential AI integration needs multiple layers - Primary AI + fallback processing ensures reliability User experience trumps technical complexity - Simple, intuitive interfaces are more valuable than complex features

### What's next

Phase 2: Advanced AI Integration (Next 3 Months) Personalized AI coaching based on individual ADHD patterns and learning styles Healthcare provider integration for treatment monitoring and progress tracking Research platform for understanding ADHD cognition and improving our algorithms Community features for ADHD support, collaboration, and shared strategies Phase 3: Enterprise & Healthcare (6-12 Months) Workplace ADHD support with privacy-compliant monitoring and accommodation recommendations Clinical integration for ADHD treatment optimization and outcome measurement Research partnerships with leading ADHD researchers and institutions Educational platform for schools and universities to support ADHD students Phase 4: Global Impact (12+ Months) Multilingual support for ADHD communities worldwide Mobile applications for iOS and Android with offline capabilities API platform for developers to build ADHD-aware applications Research publication of our findings and methodologies NeuroBoost isn't just a productivity app - it's a revolution in how we think about ADHD and technology.

## README (from the GitHub repository)

# NeuroBoost - Sponsor-Optimized Docker Architecture

version: '3.8'

services:
  # API Gateway with Sponsor Integrations
  api-gateway:
    build: ./api-gateway
    ports:
      - "3000:3000"
    environment:
      # Sponsor APIs
      - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
      - GOOGLE_GEMINI_API_KEY=${GOOGLE_GEMINI_API_KEY}
      - VAPI_API_KEY=${VAPI_API_KEY}
      - GROQ_API_KEY=${GROQ_API_KEY}
      - LETTA_API_KEY=${LETTA_API_KEY}
      - ORKES_API_KEY=${ORKES_API_KEY}
      # Standard config
      - JWT_SECRET=${JWT_SECRET}
    depends_on:
      - redis
      - postgres
    networks:
      - neuroboost-network

  # AI Agents Service (Sponsor-powered)
  ai-agents:
    build: ./ai-agents
    ports:
      - "8000:8000"
    environment:
      # Primary: Anthropic Claude 4 for complex reasoning
      - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
      # Secondary: Groq for fast inference
      - GROQ_API_KEY=${GROQ_API_KEY}
      # Memory: Letta for persistent agent memory
      - LETTA_API_KEY=${LETTA_API_KEY}
      # Multimodal: Google Gemini
      - GOOGLE_GEMINI_API_KEY=${GOOGLE_GEMINI_API_KEY}
    volumes:
      - ./models:/app/models
    depends_on:
      - redis
      - postgres
      - workflow-engine
    networks:
      - neuroboost-network

  # Voice Processing Service (Vapi-powered)
  voice-service:
    build: ./voice-service
    ports:
      - "8002:8002"
    environment:
      - VAPI_API_KEY=${VAPI_API_KEY}
      - VAPI_PHONE_NUMBER=${VAPI_PHONE_NUMBER}
    depends_on:
      - ai-agents
    networks:
      - neuroboost-network

  # Workflow Engine (Orkes-powered)
  workflow-engine:
    build: ./workflow-engine
    ports:
      - "8003:8003"
    environment:
      - ORKES_API_KEY=${ORKES_API_KEY}
      - ORKES_SERVER_URL=${ORKES_SERVER_URL}
    networks:
      - neuroboost-network

  # Frontend (React/Next.js)
  frontend:
    build: ./frontend
    ports:
      - "8080:80"
    environment:
      - REACT_APP_API_URL=http://api-gateway:3000
      - REACT_APP_VAPI_PUBLIC_KEY=${VAPI_PUBLIC_KEY}
    depends_on:
      - api-gateway
      - voice-service
    networks:
      - neuroboost-network

  # Analytics & Knowledge Graph
  analytics:
    build: ./analytics
    ports:
      - "8001:8001"
    environment:
      - POSTGRES_URL=${POSTGRES_URL}
      - REDIS_URL=${REDIS_URL}
    depends_on:
      - postgres
      - redis
    networks:
      - neuroboost-network

  # Core Infrastructure
  postgres:
    image: postgres:15
    environment:
      - POSTGRES_DB=neuroboost
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - neuroboost-network

  redis:
    image: redis:7-alpine
    volumes:
      - redis_data:/data
    networks:
      - neuroboost-network

volumes:
  postgres_data:
  redis_data:

networks:
  neuroboost-network:
    driver: bridge

# Prize Categories You Can Target:
# 1. Productivity and Dev Tools Track ($5,000) - Main category
# 2. Anthropic: Best Use of Claude 4 ($2,500 API credits)
# 3. Google: Best Use of Gemini (Google Pixel Watches)
# 4. Vapi: Best Voice-Powered AI Project (500 credits)
# 5. Vapi: Most Ambitious Vapi Project ($250 + 1000 credits)
# 6. Groq: Best Creative Use of Groq ($500 API credits + interview)
# 7. Letta: Most Creative Usage of Letta (AirPods 4)
# 8. Orkes: Best Use of Orkes ($200)
# 9. Unify: Best Use of Multimodal AI Agent ($2,500)

# Total Potential Winnings: $15,250+ plus hardware prizes


## Detected evidence (automated analysis)

Indexed codebase: 103 recognized source files, 402 KB.
- Anthropic (technology) — detected in the code
- CSS (language) — detected in the code
- Express (technology) — detected in the code
- FastAPI (technology) — detected in the code
- Firebase (technology) — detected in the code
- HTML (language) — detected in the code
- JavaScript (language) — detected in the code
- OpenAI (technology) — detected in the code
- PostgreSQL (technology) — detected in the code
- Python (language) — detected in the code
- React (technology) — detected in the code
- Redis (technology) — detected in the code
- SQL (language) — detected in the code
- Supabase (technology) — detected in the code
- Tailwind CSS (technology) — detected in the code
- Docker (technology) — claimed on Devpost, not found in the code
- AI coding agent: Cursor — evidence: config files committed to the repository

## Codebase structure (from repository index)

### Files (120 of 130)

```
.cursor/rules/code-standards.mdc
.cursor/rules/development-workflow.mdc
.cursor/rules/project-overview.mdc
.cursor/rules/README.md
.dockerignore
.env
.gitignore
.vscode/settings.json
add_demo_tasks.py
ai_agents/__init__.py
ai_agents/agents/__init__.py
ai_agents/agents/focus_agent.py
ai_agents/agents/mood_agent.py
ai_agents/agents/motivate_agent.py
ai_agents/agents/task_agent.py
ai_agents/Dockerfile
ai_agents/main.py
ai_agents/requirements.txt
ai_agents/task_agent.py
ai_agents/test_agents_simple.py
ai_agents/test_real_agent.py
ai_agents/test_single_agent.py
ai_agents/test_task_agent.py
ai-agents/Dockerfile
ai-agents/main.py
ai-agents/requirements.txt
analytics/Dockerfile
analytics/requirements.txt
api-gateway/Dockerfile
api-gateway/index.js
api-gateway/package.json
api-gateway/requirements.txt
api-gateway/src/config/database.js
api-gateway/src/config/supabase.js
api-gateway/src/middleware/auth.js
api-gateway/src/middleware/biometrics.js
api-gateway/src/middleware/rateLimit.js
api-gateway/src/routes/ai.js
api-gateway/src/routes/auth.js
api-gateway/src/routes/prediction.js
api-gateway/src/routes/tasks.js
api-gateway/test-api.js
api-gateway/test-gateway.js
create_demo_users.py
create_tables_direct.py
database/DATABASE_SETUP_GUIDE.md
database/supabase_schema.sql
docker-compose.yml
frontend/.gitignore
frontend/Dockerfile
frontend/eslint.config.js
frontend/index.html
frontend/package.json
frontend/postcss.config.js
frontend/public/debug-test.html
frontend/public/debug.html
frontend/public/react-test.html
frontend/public/test.html
frontend/src/App.jsx
frontend/src/components/AdminDashboard.jsx
frontend/src/components/AnalyticsView.jsx
frontend/src/components/AuthModal.jsx
frontend/src/components/AuthPage.jsx
frontend/src/components/CalendarView.jsx
frontend/src/components/CBTPomodoroFlow.jsx
frontend/src/components/CBTView.jsx
frontend/src/components/DailyPKGSummary.jsx
frontend/src/components/DashboardCard.jsx
frontend/src/components/landing/CTASection.jsx
frontend/src/components/landing/Features.jsx
frontend/src/components/landing/Footer.jsx
frontend/src/components/landing/HeroSection.jsx
frontend/src/components/landing/Navbar.jsx
frontend/src/components/landing/Testimonials.jsx
frontend/src/components/LevelUpStatus.jsx
frontend/src/components/MoodSelector.jsx
frontend/src/components/MotivationCard.jsx
frontend/src/components/PlayZoneView.jsx
frontend/src/components/ProtectedRoute.jsx
frontend/src/components/SettingsPage.jsx
frontend/src/components/Sidebar.jsx
frontend/src/components/SimpleVoiceWidget.jsx
frontend/src/components/SmartSchedule.jsx
frontend/src/components/SubscriptionModal.jsx
frontend/src/components/TodoList.jsx
frontend/src/components/TopNavBar.jsx
frontend/src/components/TranscribedNotes.jsx
frontend/src/components/voice/VoiceAssistantWidget.jsx
frontend/src/components/VoiceAssistantWidget.jsx
frontend/src/components/VoiceFeatureDebug.jsx
frontend/src/components/WeeklyTasksView.jsx
frontend/src/context/AuthContext.jsx
frontend/src/context/TaskContext.jsx
frontend/src/context/ThemeContext.jsx
frontend/src/index.css
frontend/src/main.jsx
frontend/src/MainApp.jsx
frontend/src/pages/Dashboard.jsx
frontend/src/pages/LandingPage.jsx
frontend/src/pages/Login.jsx
frontend/src/pages/SignUp.jsx
frontend/src/ProtectedRoute.jsx
frontend/src/services/api.js
frontend/src/services/firebase.js
frontend/src/services/supabase.js
frontend/tailwind.config.js
frontend/vite.config.js
init-db/init.sql
NEUROBOOST_SETUP.md
NeuroBoost/workflow-engine/requirements.txt
package.json
project_structure.txt
README
requirements.txt
run_app.py
setup_neuroboost.py
setup_supabase_auto.py
setup_supabase_oneclick.py
setup_supabase_simple.py
setup_supabase.sh
[10 more files omitted for size]
```

### Dependencies

- ai_agents/requirements.txt: anthropic@==0.54.0, fastapi, google-generativeai@==0.3.2, groq@==0.4.1, httpx@==0.25.2, openai, psycopg2-binary@==2.9.9, pydantic@==2.5.0, pytest@==7.4.3, pytest-asyncio@==0.21.1, python-dotenv@==1.0.0, python-multipart@==0.0.6, redis@==5.0.1, requests@==2.31.0, sqlalchemy@==2.0.23, uvicorn
- ai-agents/requirements.txt: fastapi, httpx, pydantic, python-dotenv, uvicorn[standard]
- analytics/requirements.txt: fastapi@==0.104.1, httpx@==0.25.2, matplotlib@==3.8.2, numpy@==1.26.2, pandas@==2.1.4, plotly@==5.17.0, psycopg2-binary@==2.9.9, pydantic@==2.5.0, pytest@==7.4.3, pytest-asyncio@==0.21.1, python-dotenv@==1.0.0, python-multipart@==0.0.6, redis@==5.0.1, seaborn@==0.13.0, sqlalchemy@==2.0.23, uvicorn[standard]@==0.24.0
- api-gateway/package.json: axios@^1.10.0, bcryptjs@^2.4.3, cors@^2.8.5, dotenv@^16.3.1, express@^4.18.2, express-rate-limit@^7.1.5, helmet@^7.1.0, jest@^29.7.0, joi@^17.11.0, jsonwebtoken@^9.0.2, nodemon@^3.0.1, pg@^8.11.3, redis@^4.6.10, ws@^8.14.2
- api-gateway/requirements.txt: fastapi, google-api-python-client, google-auth-httplib2, google-auth-oauthlib, python-dotenv, requests, uvicorn[standard]
- frontend/package.json: @supabase/supabase-js@^2.50.0, @types/react@^18.2.15, @types/react-dom@^18.2.7, @vapi-ai/web@^2.3.6, @vitejs/plugin-react@^4.0.3, autoprefixer@^10.4.14, chart.js@^4.5.0, date-fns@^4.1.0, eslint@^8.45.0, eslint-plugin-react@^7.32.2, eslint-plugin-react-hooks@^4.6.0, eslint-plugin-react-refresh@^0.4.3, firebase@^11.9.1, lucide-react@^0.263.1, moment@^2.30.1, postcss@^8.4.27, react@^18.2.0, react-big-calendar@^1.19.4, react-chartjs-2@^5.3.0, react-dom@^18.2.0, react-router-dom@^7.6.2, tailwindcss@^3.3.3, vite@^4.4.5
- NeuroBoost/workflow-engine/requirements.txt: celery@==5.3.4, fastapi@==0.104.1, httpx@==0.25.2, psycopg2-binary@==2.9.9, pydantic@==2.5.0, pytest@==7.4.3, pytest-asyncio@==0.21.1, python-dotenv@==1.0.0, python-multipart@==0.0.6, requests@==2.31.0, sqlalchemy@==2.0.23, uvicorn[standard]@==0.24.0
- package.json: lucide-react@^0.522.0, react-router-dom@^7.6.2
- requirements.txt: python-dotenv, requests
- voice-service/requirements.txt: fastapi, httpx, python-dotenv, uvicorn
- workflow-engine/requirements.txt: celery@==5.3.4, fastapi@==0.104.1, httpx@==0.25.2, psycopg2-binary@==2.9.9, pydantic@==2.5.0, pytest@==7.4.3, pytest-asyncio@==0.21.1, python-dotenv@==1.0.0, python-multipart@==0.0.6, requests@==2.31.0, sqlalchemy@==2.0.23, uvicorn[standard]@==0.24.0

### Recent commits (newest first)

- ALL ISSUES RESOLVED - Complete Task Management System
- Unify tasks and calendar: Fix day mapping, save tasks to Supabase, add debug endpoints
- Stable: AI Agents fallback, debug endpoint, voice-to-task fix, all services start
- Fix Supabase authentication - Update AuthContext to use proper Supabase methods and create demo users
- Migrate from Firebase to Supabase - Complete database migration with authentication and real-time features
- 12:10 am
- Fixed bug
- Resolve merge conflicts in MainApp.jsx - use modern useTheme() hook approach
- Firebase
- chore: remove __pycache__ directories from git tracking
- feat: resolve merge conflict and integrate stashed changes
- Landing Page
- Merge branch 'main' of https://github.com/Bear-sys/NeuroBoost
- more API gateway changes
- Updated settings and profile
- 10:12
- feat: Add initial files for api-gateway and voice-service
- API gateway basic setup
- Merge branch 'main' of https://github.com/Bear-sys/NeuroBoost
- Updates

## Key source files (fetched from GitHub, selected and truncated for size)

### NEUROBOOST_SETUP.md

```markdown
# 🧠 NeuroBoost - AI-Powered ADHD Productivity Platform

## 🎯 **Current Status: WORKING**

✅ **Voice-to-Task Integration**: Working  
✅ **Mood Detection**: Working  
✅ **Firebase Integration**: Configured  
✅ **Admin Dashboard**: Ready  
✅ **User Management**: Implemented  
✅ **Theme System**: Working  

---

## 🚀 **Quick Start**

### 1. **Start All Services**
```bash
python run_app.py
```

### 2. **Open App**
- Frontend: http://localhost:3001
- AI Agents: http://localhost:8000  
- Voice Service: http://localhost:8002

### 3. **Test Everything**
```bash
python test_voice_integration.py
```

---

## 🔧 **What We Fixed**

### ✅ **Issues Resolved:**
1. **DateTime Import Error**: Fixed `timedelta` import in AI agents
2. **Firebase Configuration**: Added your project credentials
3. **User-Specific Data**: Each user gets their own tasks/moods
4. **Admin Dashboard**: Full user management system
5. **Voice Integration**: Working voice-to-task conversion
6. **Mood Detection**: AI-powered mood analysis with Firebase storage

### 🎨 **Key Features Working:**
- **Real-time Mood Detection**: Voice/text → AI analysis → Theme changes
- **Voice Task Management**: "Add workout to Monday" → Task created
- **User Separation**: Different users see different data
- **Admin Controls**: Manage all users, view analytics
- **Firebase Sync**: Real-time data across devices

---

## 👥 **User System**

### **Different User Types:**
1. **Regular Users**: Their own tasks, moods, analytics
2. **Admin Users**: Can see all users + admin dashboard
3. **Premium Users**: Advanced features (future)

### **How to Create Admin User:**
```javascript
// In Firebase Console → Firestore → users collection
{
  uid: "user-id",
  email: "admin@example.com", 
  isAdmin: true,
  subscription: "premium"
}
```

---

## 🗂️ **Firebase Data Structure**

```
neuroboost-bb20d/
├── users/
│   ├── {userId}/
│   │   ├── tasks/
│   │   │   ├── {taskId}
│   │   │   └── ...
│   │   ├── moods/
│   │   │   ├── {moodId}  
│   │   │   └── ...
│   │   └── profile data
│   └── ...
```

### **Task Document:**
```javascript
{
  id: "task_123",
  text: "Complete assignment",
  type: "work", 
  done: false,
  date: "2025-06-22",
  source: "voice",
  user_id: "userId",
  createdAt: "2025-06-22T10:00:00Z"
}
```

### **Mood Document:**
```javascript
{
  mood: "focused",
  confidence: 0.8,
  context: "Working on project",
  source: "ai_detection",
  timestamp: "2025-06-22T10:00:00Z"
}
```

---

## 🎨 **Mood-Based Theming**

### **Available Moods:**
- **Calm** 😌 → Blue theme
- **Energetic** ⚡ → Orange theme  
- **Focused** 🎯 → Green theme
- **Stressed** 😰 → Purple theme
- **Happy** 😊 → Yellow theme
- **Neutral** 😐 → Gray theme

### **How It Works:**
1. User speaks/types text
2. AI analyzes for mood keywords
3. Theme automatically changes
4. Mood saved to Firebase for analytics

---

## 🗣️ **Voice Integration**

### **How to Use:**
1. Click voice button (bottom right)
2. Say: "Add workout session to Monday"
3. Ta
[truncated — 3400 more characters]
```

### database/DATABASE_SETUP_GUIDE.md

```markdown
# 🗄️ NeuroBoost Database Migration Guide

## 🎯 **Database Comparison for NeuroBoost**

| Feature | Supabase | PlanetScale | CockroachDB | Firebase (Current) |
|---------|----------|-------------|-------------|-------------------|
| **Real-time** | ✅ PostgreSQL Triggers | ⚠️ Webhooks needed | ⚠️ Custom solution | ✅ Native |
| **ADHD Analytics** | ✅ SQL + Functions | ✅ SQL queries | ✅ Complex SQL | ❌ Limited |
| **Vector/AI Search** | ✅ pgvector | ❌ No vectors | ✅ Vector support | ❌ No vectors |
| **Free Tier** | ✅ Generous | ✅ Good | ⚠️ Limited | ✅ Good |
| **Scaling** | ✅ Auto-scale | ✅ Serverless | ✅ Global | ✅ Auto |
| **Learning Curve** | 🟨 Medium | 🟨 Medium | 🟥 Hard | 🟩 Easy |
| **ADHD Features** | 🟩 Perfect | 🟨 Good | 🟨 Good | 🟥 Limited |

---

## 🚀 **RECOMMENDED: Supabase Setup**

### **Why Supabase for ADHD Platform?**
- **Real-time mood tracking** with instant theme changes
- **Advanced analytics** with SQL functions for ADHD patterns
- **Vector search** for AI-powered insights
- **Row-level security** for user data protection
- **Easy migration** from Firebase

### **Setup Steps:**

1. **Create Supabase Project**
```bash
# Visit https://supabase.com/dashboard
# Create new project
# Note your URL and anon key
```

2. **Install Dependencies**
```bash
cd frontend
npm install @supabase/supabase-js
```

3. **Environment Variables**
```env
# frontend/.env.local
VITE_SUPABASE_URL=your_supabase_project_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
```

4. **Run Schema Migration**
```sql
-- Copy and run database/supabase_schema.sql in Supabase SQL Editor
-- This creates all tables, indexes, and ADHD-specific functions
```

5. **Update Frontend**
```javascript
// Replace Firebase imports with Supabase
import { auth, saveUserTask, getUserTasks } from './services/supabase.js';
```

---

## 🌟 **Alternative: PlanetScale Setup**

### **When to Choose PlanetScale:**
- Need database branching for team development
- Want MySQL ecosystem familiarity
- Require zero-downtime schema changes

### **Setup:**
```bash
# Install PlanetScale CLI
curl -L https://github.com/planetscale/cli/releases/latest/download/pscale_linux_amd64.tar.gz | tar -xz

# Create database
pscale database create neuroboost

# Create branches
pscale branch create neuroboost dev
pscale branch create neuroboost staging
```

---

## 🏢 **Enterprise: CockroachDB**

### **When to Choose CockroachDB:**
- Global user base requiring multi-region
- Need ACID guarantees across regions
- Enterprise compliance requirements

### **Setup:**
```bash
# CockroachDB Cloud setup
# Visit https://cockroachlabs.cloud/
# Create cluster with regions matching user base
```

---

## 📊 **Migration Strategy**

### **Phase 1: Parallel Setup (Week 1)**
```bash
# Set up Supabase alongside Firebase
# Implement dual-write to both databases
# Test all features work with Supabase
```

### **Phase 2: Data Migration (Week 2)**
```javascript
// Use the migration helper
import { migrateLocalStorageToSupabase } 
[truncated — 4271 more characters]
```

### requirements.txt

```
python-dotenv
requests 
```

### package.json

```
{
  "dependencies": {
    "lucide-react": "^0.522.0",
    "react-router-dom": "^7.6.2"
  }
}

```

### docker-compose.yml

```yaml
services:
  # Database Services
  db:
    image: postgres:15
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./init-db:/docker-entrypoint-initdb.d
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
      interval: 10s
      timeout: 5s
      retries: 5

  redis:
    image: redis:7-alpine
    command: redis-server --requirepass ${REDIS_PASSWORD}
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
      interval: 10s
      timeout: 3s
      retries: 5

  # API Gateway Service
  api-gateway:
    build:
      context: ./api-gateway
      dockerfile: Dockerfile
    ports:
      - "${API_GATEWAY_PORT}:3000"
    environment:
      - NODE_ENV=${NODE_ENV}
      - JWT_SECRET=${JWT_SECRET}
      - POSTGRES_HOST=${POSTGRES_HOST}
      - POSTGRES_PORT=${POSTGRES_PORT}
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB}
      - REDIS_HOST=${REDIS_HOST}
      - REDIS_PORT=${REDIS_PORT}
      - REDIS_PASSWORD=${REDIS_PASSWORD}
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_healthy
    volumes:
      - ./api-gateway:/app
      - /app/node_modules
    command: npm run dev

  # AI Agents Service
  ai-agents:
    build:
      context: ./ai_agents
      dockerfile: Dockerfile
    ports:
      - "${AI_AGENTS_PORT}:8000"
    environment:
      - PYTHONPATH=/app
      - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
      - GOOGLE_GEMINI_API_KEY=${GOOGLE_GEMINI_API_KEY}
      - GROQ_API_KEY=${GROQ_API_KEY}
      - LETTA_API_KEY=${LETTA_API_KEY}
      - POSTGRES_HOST=${POSTGRES_HOST}
      - POSTGRES_PORT=${POSTGRES_PORT}
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB}
      - REDIS_HOST=${REDIS_HOST}
      - REDIS_PORT=${REDIS_PORT}
      - REDIS_PASSWORD=${REDIS_PASSWORD}
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_healthy
    volumes:
      - ./ai_agents:/app
      - ./shared:/app/shared
    command: python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload

  # Voice Service
  voice-service:
    build:
      context: ./voice-service
      dockerfile: Dockerfile
    ports:
      - "${VOICE_SERVICE_PORT}:8002"
    environment:
      - PYTHONPATH=/app
      - VAPI_API_KEY=${VAPI_API_KEY}
      - VAPI_PUBLIC_KEY=${VAPI_PUBLIC_KEY}
      - POSTGRES_HOST=${POSTGRES_HOST}
      - POSTGRES_PORT=${POSTGRES_PORT}
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB}
    depends_on:
      db:
        condition: service_healthy
    volumes:
      - ./voice-service:/app
      - ./shared:/app/shared
    command: python -m uvicorn main:app --host 0.0.0.0 --port 8002 --reload

  # Workflow Engine
  workflow-engine:
    build:
      context: ./workflow-engine
      dockerfile: Dockerfile
    ports:
      - "8003:8003"
    environment:
      - PYTHONPATH=/app
      - ORKES_API_KEY=${ORKES_API_KEY}
      - ORKES_SERVER_URL=${ORKES_SERVER_URL}
      - POSTGRES_HOST=${POSTGRES_HOST}
      - POSTGRES_PORT=${POSTGRES_PORT}
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB}
    depends_on:
      db:
        condition: service_healthy
    volumes:
      - ./workflow-engine:/app
      - ./shared:/app/shared
    command: python -m uvicorn main:app --host 0.0.0.0 --port 8003 --reload

  # Analytics Service
  analytics:
    build:
      context: ./analytics
      dockerfile: Dockerfile
    ports:
      - "${ANALYTICS_PORT}:8001"
    environment:
      - PYTHONPATH=/app
      - POSTGRES_HOST=${POSTGRES_HOST}
      - POSTGRES_PORT=${POSTGRES_PORT}
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB}
      - REDIS_HOST=${REDIS_HOST}
      - REDIS_PORT=${REDIS_PORT}
      - REDIS_PASSWORD=${REDIS_PASSWORD}
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_healthy
    volumes:
      - ./analytics:/app
      - ./shared:/app/shared
    command: python -m uvicorn main:app --host 0.0.0.0 --port 8001 --reload

  # Frontend Service
  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    ports:
      - "${FRONTEND_PORT}:8080"
    environment:
      - NODE_ENV=${NODE_ENV}
      - REACT_APP_API_URL=http://api-gateway:3000
    volumes:
      - ./frontend:/app
      - /app/node_modules
    command: npm run dev
    depends_on:
      - api-gateway

volumes:
  postgres_data:
  redis_data:

networks:
  default:
    driver: bridge 
```

### voice-service/requirements.txt

```
fastapi
uvicorn
python-dotenv
httpx

```

### ai-agents/requirements.txt

```
fastapi
uvicorn[standard]
pydantic
python-dotenv
httpx
# Add other necessary AI/ML libraries here 
```

### api-gateway/requirements.txt

```
fastapi
uvicorn[standard]
google-api-python-client
google-auth-httplib2
google-auth-oauthlib
python-dotenv
requests 
```

### frontend/Dockerfile

```
FROM node:18-alpine

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 8080

CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0", "--port", "8080"] 
```

### workflow-engine/requirements.txt

```
fastapi==0.104.1
uvicorn[standard]==0.24.0
pydantic==2.5.0
psycopg2-binary==2.9.9
python-dotenv==1.0.0
python-multipart==0.0.6
httpx==0.25.2
sqlalchemy==2.0.23
celery==5.3.4
requests==2.31.0
pytest==7.4.3
pytest-asyncio==0.21.1 
```

[108 more indexed source files omitted to keep this export small. The full file list is in the Codebase structure section above.]