CounsellorAI is an open source hobby project for experimenting with AI-powered mental health support.
This is a personal project created for:
- Learning and experimenting with AI therapy applications
- Exploring mental health support technologies
- Personal use and self-reflection
- Contributing to open source mental health tools
Security Features Implemented:
- ✅ JWT Authentication with bcrypt password hashing
- ✅ Database encryption (SQLCipher with AES-256)
- ✅ Data export for GDPR compliance
- ✅ Input validation (Zod schemas)
- ✅ SQL injection protection
- ✅ Sensitive data redaction in logs
- ✅ CSRF protection
- ✅ Automatic backups with encryption
Please Note: While security best practices have been implemented, this is a hobby project. Use at your own discretion and comfort level.
CounsellorAI is a free, open-source AI therapist that provides personalized mental health support through natural conversations. Think of it as having a supportive, understanding therapist available 24/7 on your computer.
Important: This is NOT a replacement for professional mental health care. If you're in crisis, please contact emergency services or a crisis hotline.
- 🤖 Multiple AI Options: Choose between GPT-4o (OpenAI), Claude 3.5 Sonnet (Anthropic), or Gemini 2.0 Flash (Google)
- 🔒 Privacy Focused: Run it on your own computer - your conversations stay private
- 💬 Natural Conversations: Chat like you would with a real therapist
- 📊 Track Your Progress: See your mood patterns over time
- 📱 Works Everywhere: Use on your computer, tablet, or phone
- 🆓 Completely Free: Just bring your own AI API key
Don't worry if you're not tech-savvy! This guide will walk you through every step.
Before starting, you'll need:
- A Computer (Windows, Mac, or Linux)
- Internet Connection (for downloading and AI responses)
- An AI API Key (we'll show you how to get one - it's like a password for the AI)
Node.js is what makes the app run. Think of it as the engine.
- Go to nodejs.org
- Download the "LTS" version (the big green button)
- Run the installer - just click "Next" for everything
- To check it worked, open Terminal/Command Prompt and type:
node --version
You need at least ONE of these (they're free to start):
- Go to platform.openai.com
- Sign up for a free account
- Click "API Keys" in the left menu
- Click "Create new secret key"
- Copy the key (starts with
sk-) - Save it somewhere safe! You can't see it again
- Go to console.anthropic.com
- Sign up for a free account
- Go to "API Keys"
- Create a new key
- Copy and save it
- Go to makersuite.google.com/app/apikey
- Sign in with Google
- Click "Create API Key"
- Copy and save it
- Click the green "Code" button on this page
- Click "Download ZIP"
- Extract the ZIP file to your Desktop or Documents folder
- In the CounsellorAI folder, find the file called
.env.example - Make a copy and rename it to
.env(remove the.examplepart) - Open it with any text editor (Notepad is fine)
- Add your API key(s) and security keys:
# AI API Keys (at least one required) OPENAI_API_KEY=your-openai-key-here ANTHROPIC_API_KEY=your-anthropic-key-here GOOGLE_API_KEY=your-google-key-here # Security Keys (generate random values) DATABASE_ENCRYPTION_KEY=generate-a-32-character-random-string JWT_SECRET=generate-another-32-character-random-string CSRF_SECRET=generate-another-32-character-random-string - To generate random security keys:
- On Mac/Linux: Run
openssl rand -base64 32in Terminal - On Windows: Use an online generator like randomkeygen.com
- Or just type 32 random characters (mix of letters, numbers, symbols)
- On Mac/Linux: Run
- Save the file
- Open Terminal (Mac) or Command Prompt (Windows)
- Navigate to the CounsellorAI folder:
cd Desktop/CounsellorAI - Install everything:
npm install
- Start the app:
npm run dev
- Open your web browser and go to:
http://localhost:5173
That's it! You should see the login page. Create an account (it's stored locally on your computer) and start chatting!
- Frontend: React 18, TypeScript, Material-UI 5, Vite
- Backend: Express.js, TypeScript, SQLite with SQLCipher
- AI: OpenAI, Anthropic, and Google Gemini APIs
- Auth: JWT with bcrypt
- State: Zustand + React Query
# Clone the repo
git clone https://github.com/yourusername/CounsellorAI.git
cd CounsellorAI
# Install dependencies
npm install
# Copy environment variables
cp .env.example .env
# Edit .env and add your API keys and generate security keys
# Run development server
npm run dev
# The app will be available at:
# Frontend: http://localhost:5173
# Backend API: http://localhost:3001CounsellorAI/
├── client/ # React frontend
├── server/ # Express backend
├── shared/ # Shared TypeScript types
└── database/ # SQLite database (auto-created)
The following security measures have been implemented:
- Authentication: JWT-based with bcrypt password hashing (12 rounds)
- Database Encryption: SQLCipher with AES-256 encryption
- Input Validation: Zod schemas on all endpoints
- CSRF Protection: Double-submit cookie pattern with session binding
- SQL Injection Protection: Parameterized queries throughout
- XSS Protection: Input sanitization and output encoding
- Rate Limiting: AI endpoint limits (20 req/15min) and request size limits (1MB)
- Sensitive Data Redaction: Automatic PII removal from logs
- Backup Encryption: Automatic encrypted backups
- GDPR Compliance: Data export and deletion features
Contributions are welcome! Please feel free to submit a Pull Request. Some areas that could use help:
- UI/UX improvements
- Additional AI model integrations (Llama, Mistral, etc.)
- Better crisis detection and intervention
- Progress visualization and insights
- Multi-language support
- Documentation improvements
- Bug fixes and testing
- Accessibility features
- Follow TypeScript best practices
- Add tests for new features
- Update documentation
- Follow the existing code style
- Test with all AI models
All available configuration options are documented in .env.example. Key variables:
USE_ENCRYPTED_DB: Enable database encryption (default: true)AUTO_BACKUP: Enable automatic backups (default: true)BACKUP_INTERVAL: Backup frequency (hourly/daily/weekly/monthly)ENABLE_AUTO_LEARNING: Enable AI learning from conversations (default: true)DEFAULT_AI_MODEL: Default AI model to useJWT_EXPIRES_IN: Session duration (default: 24h)
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with love for the mental health community
- Inspired by the need for accessible mental health tools
- Thanks to all contributors and users
- Not Medical Advice: This is not a replacement for professional therapy
- Crisis Support: If you're in crisis, please contact emergency services
- Privacy: While we implement security best practices, this is a hobby project
- AI Limitations: AI responses may not always be appropriate or accurate
If you're experiencing a mental health crisis:
- US: National Suicide Prevention Lifeline: 988
- UK: Samaritans: 116 123
- Australia: Lifeline: 13 11 14
- International: findahelpline.com
Remember: You're not alone, and help is available. 💙