A full-stack AI-powered mental health support application that provides evidence-based therapeutic guidance through natural language conversations. Built with React, Django, and LlamaIndex for intelligent document retrieval.
- AI-Powered Therapy Conversations: Leverages Groq (Llama 3.3 70B) and LlamaIndex for context-aware, evidence-based responses
- Multiple Therapy Modalities: Supports various therapy types including CBT, DBT, Family Therapy, and Teen Counseling
- Crisis Detection: Automatically detects crisis messages and directs users to appropriate resources
- Knowledge Base Integration: Built on curated mental health resources from trusted sources
- Modern React Frontend: Clean, responsive Material-UI interface
- Django REST API: Robust backend with RESTful endpoints and JWT authentication
- Vector Search: Semantic search through therapy documents using remote HuggingFace embeddings
TherapyBot/
βββ backend/
β βββ djangoProject/ # Django project config
β β βββ settings.py # Django configuration
β β βββ urls.py # URL routing
β β βββ wsgi.py # WSGI entrypoint
β βββ therapybot/ # Django app
β β βββ views.py # API endpoints
β β βββ urls.py # App URL routing
β βββ testingAI.py # LlamaIndex + Groq integration
β βββ storage/ # Vector index storage
β βββ manage.py
βββ frontend/
β βββ src/
β β βββ components/ # React components
β β βββ api/ # API client
β β βββ App.tsx # Main app
β βββ package.json
βββ requirements.txt
βββ Dockerfile
- Python 3.11+
- Node.js & npm (for React frontend)
- Groq API Key (free)
- HuggingFace API Key (free, Read access only)
-
Clone the repository
git clone https://github.com/RasheedMartin/TherapyBot.git cd TherapyBot -
Create and activate virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables β create a
.envfile in the backend directory:GROQ_API_KEY=your-groq-api-key HF_API_KEY=your-huggingface-api-key SECRET_KEY=your-django-secret-key DEBUG=True -
Run migrations
cd backend python manage.py migrate -
Build the knowledge base (first time only)
python testingAI.py # Type 'rebuild' to create the vector index -
Run the Django server
python manage.py runserver
-
Navigate to frontend directory
cd frontend -
Install dependencies
npm install
-
Start the development server
npm run dev
-
Open your browser
http://localhost:5173
The backend is deployed on Railway using Docker.
Required environment variables in Railway:
| Variable | Description |
|---|---|
SECRET_KEY |
Django secret key |
GROQ_API_KEY |
Groq API key |
HF_API_KEY |
HuggingFace API key (Read access) |
ALLOWED_HOSTS |
Your Railway domain e.g. yourapp.up.railway.app |
FRONTEND_URL |
Your Vercel frontend URL |
DATABASE_URL |
Auto-injected by Railway Postgres plugin |
Railway automatically runs migrations and starts gunicorn on deploy via the Dockerfile CMD.
The frontend is deployed on Vercel. Connect your GitHub repo and Vercel handles the rest. Set your backend Railway URL as an environment variable in Vercel for API calls.
- Select a therapy type from the dropdown (e.g., Family Therapy, CBT)
- Enter your question or concern in the text area
- Click "Submit" to get an AI-powered response
- The system retrieves relevant information from the knowledge base and generates a contextual response
Edit the URLs in build_index_local() in testingAI.py:
documents = loader.load_data(
urls=[
"https://childmind.org/article/helping-resistant-teens-into-treatment/",
"https://childmind.org/article/anxiety-disorders-in-children/",
# Add your URLs here
]
)Frontend:
- React 18
- Material-UI (MUI)
- TanStack Query (React Query)
- TypeScript
- Axios
Backend:
- Django 5.2
- Django REST Framework
- Django REST Framework SimpleJWT
- LlamaIndex 0.14
- Groq API (Llama 3.3 70B)
- HuggingFace Inference API (remote embeddings)
Infrastructure:
- Railway (backend + PostgreSQL)
- Vercel (frontend)
- Docker
GET /api/get_started/
Parameters:
- question: string (required)
- therapy_type: string (optional, default: "general therapy")
Response:
{
"response": "AI-generated therapeutic guidance..."
}
This application is for informational and educational purposes only. It is NOT a substitute for professional mental health care. If you are experiencing a mental health crisis, please contact:
- 988 Suicide & Crisis Lifeline: Call or text 988
- Crisis Text Line: Text HOME to 741741
- Emergency Services: 911
This project is licensed under the MIT License - see the LICENSE file for details.
Rasheed Martin
- GitHub: @RasheedMartin
- Mental health resources from Child Mind Institute
- Built with LlamaIndex
- Powered by Groq
Note: Originally created during a 9-hour hackathon and evolved into a full-stack production application with AI capabilities.