This is the backend engine powering ReachOut, an AI-driven mental health chatbot designed to provide empathetic support, document-based Q&A, and crisis detection. The backend integrates multiple AI models and services to enable safe, responsive, and intelligent mental health assistance.
- Conversational Engine: Uses Gemini API for empathetic responses to user queries.
- Document Q&A Engine: Powered by LlamaIndex, enabling document retrieval and answering based on mental health resources.
- Crisis Detection Module: Scans user input for crisis-related signals and triggers automated safety protocols.
- HuggingFace Embeddings: Generates semantic embeddings for queries to enhance document retrieval.
- Custom Logging: Tracks user sessions and logs interactions for auditing and safety purposes.
- Framework: FastAPI (Python)
- AI Integrations:
- Gemini API (chat responses)
- LlamaIndex (document querying)
- HuggingFace Sentence Transformers (embeddings)
- Natural Language Toolkit (NLTK): Tokenization and text preprocessing.
- Logging: Custom logging system for auditing interactions.
git clone https://github.com/your-username/reachout-backend.git
cd reachout-backendpython -m venv venv
source venv/bin/activatepython -m venv venv
venv\Scripts\activatepip install -r requirements.txtuvicorn main:app --reloadThe following environment variables need to be set in AWS Amplify:
# Python Runtime
PYTHON_VERSION=3.9.12
# Application Settings
PORT=8080
NLTK_DATA=/tmp/nltk_data
# Model Settings
TRANSFORMERS_NO_TF=1
TOKENIZERS_PARALLELISM=false-
AWS Amplify Console Setup:
- Go to App settings → Environment variables
- Add all required environment variables
- Build settings will use amplify.yml
- Monitor builds in the Deploy tab
-
Custom Domain (Optional):
- Set up in Domain management
- SSL certificate provided automatically
-
Monitoring:
- View logs in Deploy tab
- Real-time monitoring in App settings → Monitoring