Skip to content

TherapyBot is a full-stack web application designed to provide mental health support using AI. Created during a 9-hour hackathon, this project leverages natural language processing to interact with users in real-time and simulate therapeutic conversations.

Notifications You must be signed in to change notification settings

RasheedMartin/TherapyBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TherapyBot πŸ§ πŸ’¬

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.

Python Django React LlamaIndex

🌟 Features

  • 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

πŸ—οΈ Architecture

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

πŸš€ Getting Started

Prerequisites

Backend Setup

  1. Clone the repository

    git clone https://github.com/RasheedMartin/TherapyBot.git
    cd TherapyBot
  2. Create and activate virtual environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Set up environment variables β€” create a .env file 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
    
  5. Run migrations

    cd backend
    python manage.py migrate
  6. Build the knowledge base (first time only)

    python testingAI.py
    # Type 'rebuild' to create the vector index
  7. Run the Django server

    python manage.py runserver

Frontend Setup

  1. Navigate to frontend directory

    cd frontend
  2. Install dependencies

    npm install
  3. Start the development server

    npm run dev
  4. Open your browser

    http://localhost:5173
    

☁️ Deployment

Backend β€” Railway

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.

Frontend β€” Vercel

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.

πŸ’‘ Usage

  1. Select a therapy type from the dropdown (e.g., Family Therapy, CBT)
  2. Enter your question or concern in the text area
  3. Click "Submit" to get an AI-powered response
  4. The system retrieves relevant information from the knowledge base and generates a contextual response

πŸ”§ Configuration

Adding More Knowledge Sources

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
    ]
)

πŸ› οΈ Tech Stack

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

πŸ“Š API Endpoints

Get Therapy Response

GET /api/get_started/
Parameters:
  - question: string (required)
  - therapy_type: string (optional, default: "general therapy")

Response:
{
  "response": "AI-generated therapeutic guidance..."
}

⚠️ Disclaimer

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

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘¨β€πŸ’» Author

Rasheed Martin

πŸ™ Acknowledgments


Note: Originally created during a 9-hour hackathon and evolved into a full-stack production application with AI capabilities.

About

TherapyBot is a full-stack web application designed to provide mental health support using AI. Created during a 9-hour hackathon, this project leverages natural language processing to interact with users in real-time and simulate therapeutic conversations.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors