Serene is a compassionate AI assistant for mental wellness and emotional support, built with Next.js, Firebase, Stripe, and self-hosted TTS.
- Emotional Support Chat: AI-powered conversational interface for mental wellness
- Voice Responses: Text-to-speech capabilities with customizable voices
- User Authentication: Secure login/signup with Google and email/password options
- Subscription Plans: Free, Premium, and Pro tiers with different feature sets
- Responsive Design: Beautiful UI that works on all devices
- Smooth Animations: Framer Motion powered transitions and interactions
- Robust Security: Comprehensive input validation on all API endpoints
- Frontend: Next.js 14 with App Router, React, TypeScript
- Styling: Tailwind CSS with custom indigo theme
- Animations: Framer Motion
- Authentication: Firebase Authentication
- Payments: Stripe Checkout and Billing
- Voice: Self-hosted XTTS (Coqui TTS)
- Validation: Zod schema validation
- Testing: Vitest with React Testing Library
- Deployment: Vercel
therapeutic-ai-assistant/
├── src/
│ ├── app/ # Next.js app router pages and API routes
│ │ ├── api/ # Backend API routes
│ │ │ ├── auth/ # Authentication routes (NEW)
│ │ │ │ ├── login/ # Login API route (NEW)
│ │ │ │ └── signup/ # Signup API route (NEW)
│ │ │ ├── chat/ # Chat API route
│ │ │ ├── payment/ # Payment API routes
│ │ │ └── voice/ # Voice API route
│ │ ├── layout.tsx # Root layout
│ │ └── page.tsx # Main page
│ ├── components/ # React components
│ │ ├── auth/ # Authentication components
│ │ ├── chat/ # Chat interface components
│ │ ├── payment/ # Payment and subscription components
│ │ └── voice/ # Voice and TTS components
│ ├── lib/ # Library code
│ │ └── tts/ # Text-to-speech client
│ ├── services/ # Business logic
│ │ ├── auth/ # Authentication service
│ │ ├── chat/ # Chat service
│ │ ├── payment/ # Payment service
│ │ └── voice/ # Voice service
│ ├── types/ # TypeScript types
│ ├── utils/ # Utility functions
│ │ ├── validation/ # Input validation schemas and utilities
│ │ └── errorHandler.ts # Error handling utilities
│ └── __tests__/ # Test files
├── public/ # Static assets
└── ...
The project now includes comprehensive input validation on all API endpoints:
-
Authentication Routes (NEW):
/api/auth/login- Validates email format and password length/api/auth/signup- Validates email format, password length, and password confirmation
-
Existing Routes (Already had validation):
/api/chat- Validates message content length/api/payment/checkout- Validates plan ID and user ID/api/payment/webhook- Validates Stripe webhook signatures/api/voice- Validates text content, voice ID, and speed range
The project has been updated to use self-hosted XTTS (Coqui TTS) instead of ElevenLabs:
- Updated voice service to use XTTS API
- Modified environment variables to use XTTS configuration
- Updated documentation to reflect self-hosted TTS setup
README.md- Project overview and setup instructionsSECURITY_IMPROVEMENTS.md- Detailed security enhancement documentationSELF_HOSTED_TTS.md- Self-hosted TTS setup and configurationTESTING.md- Testing strategies and coverageARCHITECTURE.md- System architecture and design decisionsCOMPLETION_SUMMARY.md- Summary of completed workPROJECT_SUMMARY.md- This file
- Comprehensive validation tests for all input schemas
- Component tests for UI elements
- API route tests for validation and error handling
The application requires the following environment variables:
# Firebase Configuration
NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_firebase_auth_domain
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_firebase_project_id
# Stripe Configuration
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=your_stripe_publishable_key
STRIPE_SECRET_KEY=your_stripe_secret_key
STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret
STRIPE_PREMIUM_PRICE_ID=your_stripe_premium_price_id
STRIPE_PRO_PRICE_ID=your_stripe_pro_price_id
# XTTS Configuration
XTTS_API_URL=http://localhost:8000
XTTS_API_KEY=your_xtts_api_key
# Application Settings
NEXT_PUBLIC_APP_URL=http://localhost:3000
- Clone the repository
- Install dependencies with
npm install - Create a
.env.localfile with your API keys - Run the development server with
npm run dev - Open http://localhost:3000 in your browser
This project is configured for deployment on Vercel:
- Push your code to a GitHub repository
- Connect your repository to Vercel
- Add your environment variables in the Vercel dashboard
- Deploy!