A trauma-informed chatbot powered by vector embeddings, semantic search, and Google Gemini AI. Built with FastAPI (backend), React + Electron (frontend), and ChromaDB (vector store).
- Python 3.12+
- Node.js 18+
- AWS Account (for S3 storage and Lambda deployment)
- Google Gemini API Key (get one at https://ai.google.dev)
cd CareCompass
# Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install Python dependencies
pip install -r requirements.txtCreate a .env file in the root directory:
# Google AI API
GOOGLE_API_KEY=your_gemini_api_key_here
# AWS S3 Buckets (created automatically, or provide your own)
S3_DOCUMENTS_BUCKET=care-compass-documents-{account-id}-dev
S3_VECTORDB_BUCKET=care-compass-vectordb-{account-id}-dev
S3_LOGS_BUCKET=care-compass-logs-{account-id}-dev
# Model Configuration (optional)
MODEL_NAME=gemini-2.5-flash
TEMPERATURE=0.7
TOP_K=3# Development with auto-reload
uvicorn api:app --host 0.0.0.0 --port 8000 --reload
# Production (no reload)
uvicorn api:app --host 0.0.0.0 --port 8000Backend ready at: http://localhost:8000
API docs: http://localhost:8000/docs
cd chatbot-frontend
# Install dependencies
npm install
# Development
npm run dev
# Build for production
npm run buildFrontend ready at: http://localhost:5173
┌─────────────────────────────────────────────────────────┐
│ Electron + React App │
└─────────────────────────────────────────────────────────┘
↓
FastAPI Backend (8000)
↓
┌───────────────────────────────┐
↓ ↓ ↓ ↓
[Crisis [Retrieval] [Embedding] [LLM]
Detector] (ChromaDB) (Sentence (Gemini
Transformers) API)
↓ ↓ ↓ ↓
└───────────────────────────────┘
↓
┌──────────────────────┐
↓ ↓ ↓
[Documents] [Logs] [VectorDB]
(S3) (S3) (S3)
Raw PDFs API Calls Backups
POST /chat
{
"query": "What STI testing do I need?",
"scenario": "medical_followup"
}GET /categories
Returns available support categories (medical, mental health, legal, etc.)
GET /health
Returns {"status": "ok"}
GET /stats
Returns bot statistics (documents indexed, model info, etc.)
POST /clear
Clears conversation history for fresh start
Your system uses 3 dedicated S3 buckets:
| Bucket | Purpose | Contents |
|---|---|---|
| Documents | Raw healthcare PDFs | SAMHSA guides, protocols, reference materials |
| VectorDB | Database backups | Weekly snapshots of ChromaDB (disaster recovery) |
| Logs | Audit trail | All API interactions with timestamps |
Automatic Backups: ChromaDB is backed up to S3 weekly (configurable in api.py line 101: backup_interval_hours=168)
Scans for crisis keywords and provides immediate resources
Local ChromaDB for fast semantic search (~300ms)
Finds top-k relevant documents using cosine similarity
Interface with Google Gemini API for response generation
Automatic weekly backups of vector database to S3
Edit config/settings.py to customize:
CHUNK_SIZE = 500 # Document chunk size (tokens)
CHUNK_OVERLAP = 50 # Overlap between chunks
TOP_K = 3 # Documents to retrieve
SIMILARITY_THRESHOLD = 0.7 # Minimum similarity score
TEMPERATURE = 0.7 # LLM creativity (0-1)# Check if port 8000 is in use
lsof -i :8000 # macOS/Linux
netstat -ano | findstr :8000 # Windows
# Kill and restart
pkill -f uvicorn # macOS/Linux
taskkill /IM python.exe # WindowsFirst startup downloads the embedding model (~400MB). Subsequent starts are fast.
Verify AWS credentials: ~/.aws/credentials
Ensure bucket names match your account ID in .env
Check backend is running: curl http://localhost:8000/health
Verify CORS is enabled (should be by default)
# Test backup functionality
python test_backup.py
# Manual API test
curl http://localhost:8000/healthTrauma-Informed: Responses follow SAMHSA principles
Fast Retrieval: Local vector search (~300ms)
Crisis Detection: Immediate escalation when needed
Auto-Backup: Weekly database backups to AWS S3
Audit Trail: All interactions logged
Multi-Scenario: Tailored responses for different situations
# Configure AWS credentials
aws configure
# Or manually create ~/.aws/credentials:
[default]
aws_access_key_id = YOUR_ACCESS_KEY
aws_secret_access_key = YOUR_SECRET_KEY
region = us-east-1The backend will:
- Download embedding model (~400MB, first time only)
- Initialize ChromaDB vector store
- Begin accepting requests
For issues, check:
- Backend logs:
http://localhost:8000/docs(Swagger UI) - Browser console for frontend errors
- S3 console for backup status
- Ensure all environment variables are set