A minimal proof-of-concept AI therapy chatbot using Next.js, Supabase, and OpenRouter.
- Intake Wizard: 5-question assessment including PHQ-2 and GAD-2 screening
- AI Chat: Context-aware therapy conversations using CBT techniques
- Two Therapy Modes:
- Quick check-in (unstructured chat)
- Guided CBT exercises (thought challenging, deep breathing, grounding)
- Crisis Detection: Automatic keyword detection with crisis resources
- Dashboard: Session history, mood trends, and progress tracking
- Memory System: Stores last 10 messages + patient profile for context
- Frontend: Next.js 14 (App Router), React, TypeScript, Tailwind CSS, shadcn/ui
- Backend: Next.js API Routes
- Database: Supabase PostgreSQL with pgvector
- AI: OpenRouter (deepseek/deepseek-r1-distill-llama-70b at $0.27/1M tokens)
- Auth: NextAuth.js with Supabase
- Deployment: Vercel (free tier)
git clone <repository-url>
cd avilonai.comnpm install- Create a project at https://supabase.com
- Go to SQL Editor and execute the schema from
lib/db/schema.sql - Copy your project URL and keys from Settings > API
- Create an account at https://openrouter.ai
- Generate an API key from the dashboard
- Add credits to your account ($5-10 is sufficient for POC testing)
Copy .env.example to .env and fill in your credentials:
cp .env.example .envRequired variables:
NEXT_PUBLIC_SUPABASE_URL: Your Supabase project URLNEXT_PUBLIC_SUPABASE_ANON_KEY: Supabase anonymous keySUPABASE_SERVICE_ROLE_KEY: Supabase service role key (for admin operations)NEXTAUTH_URL: Your app URL (http://localhost:3000 for development)NEXTAUTH_SECRET: Random secret (generate withopenssl rand -base64 32)OPENROUTER_API_KEY: Your OpenRouter API keyNEXT_PUBLIC_APP_URL: Your app URL
npm run devVisit http://localhost:3000
- Push your code to GitHub
- Import project to Vercel
- Add environment variables in Vercel dashboard
- Deploy
- Sign Up: Create an account at
/signup - Complete Intake: Fill out the 5-step intake wizard
- Start Session: Choose session type and rate your mood
- Chat: Engage with Avilon using CBT techniques
- Dashboard: View your session history and mood trends
The system automatically detects crisis keywords and provides immediate resources:
- 988 Suicide & Crisis Lifeline
- Crisis Text Line (741741)
- Emergency room guidance
All incidents are logged for safety monitoring.
- Infrastructure: $0 (Vercel + Supabase free tiers)
- LLM Costs: ~$5-10/month for 100-200 conversations
- Total: Under $10/month for POC
/app
/api
/auth # Authentication endpoints
/chat # Chat and session endpoints
/intake # Intake form submission
/dashboard # Dashboard data
/(auth) # Login and signup pages
/(dashboard) # Protected dashboard pages
/components
/chat # Chat interface
/intake # Intake wizard
/ui # shadcn/ui components
/lib
/ai # AI agent configuration
/db # Database schema and client
/utils # Utilities (crisis detection, etc.)
- User authentication via NextAuth.js + Supabase
- Environment variables for API keys
- Server-side API routes for sensitive operations
- Crisis incidents logged for safety
- Not a replacement for professional mental health care
- Not HIPAA compliant
- Not suitable for production use without additional security and compliance measures
- Crisis detection is keyword-based and may have false positives/negatives
MIT
For issues or questions, please open a GitHub issue.