Skip to content

Latest commit

 

History

History
129 lines (113 loc) · 5.42 KB

File metadata and controls

129 lines (113 loc) · 5.42 KB

Therapeutic AI Assistant - Project Summary

Overview

Serene is a compassionate AI assistant for mental wellness and emotional support, built with Next.js, Firebase, Stripe, and self-hosted TTS.

Key Features

  • 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

Tech Stack

  • 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

Project Structure

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
└── ...

Security Enhancements

The project now includes comprehensive input validation on all API endpoints:

  1. Authentication Routes (NEW):

    • /api/auth/login - Validates email format and password length
    • /api/auth/signup - Validates email format, password length, and password confirmation
  2. 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

Self-Hosted TTS Implementation

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

Documentation

  • README.md - Project overview and setup instructions
  • SECURITY_IMPROVEMENTS.md - Detailed security enhancement documentation
  • SELF_HOSTED_TTS.md - Self-hosted TTS setup and configuration
  • TESTING.md - Testing strategies and coverage
  • ARCHITECTURE.md - System architecture and design decisions
  • COMPLETION_SUMMARY.md - Summary of completed work
  • PROJECT_SUMMARY.md - This file

Testing

  • Comprehensive validation tests for all input schemas
  • Component tests for UI elements
  • API route tests for validation and error handling

Environment Variables

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

Getting Started

  1. Clone the repository
  2. Install dependencies with npm install
  3. Create a .env.local file with your API keys
  4. Run the development server with npm run dev
  5. Open http://localhost:3000 in your browser

Deployment

This project is configured for deployment on Vercel:

  1. Push your code to a GitHub repository
  2. Connect your repository to Vercel
  3. Add your environment variables in the Vercel dashboard
  4. Deploy!