# Pain Management Support Group Platform
A comprehensive web-based platform for delivering an 8-week Pain Management Support Group program. This system integrates educational content delivery, AI-powered Q&A, pain tracking, assessment tools, and outcome analytics.
This platform was designed to address a critical gap in pain management care: empowering patients with knowledge, reducing power differentials between patients and providers, and providing evidence-based alternatives to traditional pain management approaches.
Middle-aged adults dealing with chronic pain from multiple conditions including:
| Component | Technology |
pain-management-support-group/
βββ backend/ # FastAPI backend application
β βββ api/ # API routes
β βββ models/ # Database models
β βββ controllers/ # Business logic controllers
β βββ services/ # Service layer (RAG, email, etc.)
β βββ utils/ # Utility functions
β βββ config/ # Configuration management
βββ frontend/ # React frontend application
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ pages/ # Page components
β β βββ hooks/ # Custom React hooks
β β βββ context/ # React context providers
β β βββ services/ # API client services
β βββ public/ # Static assets
βββ curriculum/ # 8-week curriculum content
β βββ week-01/ # Week 1 materials
β β βββ sessions/ # Individual session content
β β βββ materials/ # Handouts and resources
β β βββ slides/ # PowerPoint/Keynote slides
β β βββ assessments/ # Pre/post tests
β βββ ... # Weeks 2-8
βββ assessments/ # Assessment tools and analytics
β βββ python/ # Python assessment generators
β βββ r/ # R statistical analysis scripts
βββ research/ # Research and reference materials
β βββ medications/ # Drug safety data
β βββ support-groups/ # Global support group comparison
β βββ literature/ # AAFP journal references
βββ rag/ # RAG system components
β βββ documents/ # Source documents for knowledge base
β βββ embeddings/ # Vector embeddings storage
β βββ prompts/ # LLM prompt templates
βββ visual-aids/ # Educational visual materials
β βββ anatomy/ # Anatomical diagrams
β βββ diagrams/ # Process diagrams
β βββ infographics/ # Educational infographics
βββ database/ # Database schemas and migrations
βββ docker/ # Docker configuration files
βββ docs/ # Documentation
βββ tests/ # Test suites
git clone https://github.com/your-org/pain-management-support-group.git
cd pain-management-support-group
cp .env.example .env
# Edit .env with your API keys and configuration
docker-compose up -d
docker-compose exec backend python -m backend.scripts.init_db
cd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Set up database
createdb pain_management
alembic upgrade head
Run backend
uvicorn main:app --reload
Frontend Setup
cd frontend
npm install
npm start
Edit .env file with the following required settings:
OpenAI API (for LLM and embeddings)
OPENAI_API_KEY="your-key-here"
Database
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/pain_management"
Security
SECRET_KEY="generate-a-secure-random-key"
Vector Database (choose one)
USE_PINECONE=false # Set to true for Pinecone, false for ChromaDB
PINECONE_API_KEY="your-pinecone-key" # If using Pinecone
Each week includes:
from backend.services.rag_service import RAGService
rag = RAGService()
Query the knowledge base
result = await rag.query(
query="How do NSAIDs reduce inflammation?",
conversation_history=[]
)
print(result["response"])
Response includes citations from medical literature
Features:
from assessments.python.outcome_analytics import OutcomeAnalytics
analytics = OutcomeAnalytics()
report = analytics.generate_patient_report(
user_id=123,
pain_logs=patient_logs,
assessment_scores=scores,
program_completion=True
)
print(f"Pain reduction: {report['changes']['pain_level']['absolute_change']}")
print(f"Clinically significant: {report['clinically_significant']['pain_level']}")
source("assessments/r/statistical_analysis.R")
Load patient data
data <- load_patient_data("data/outcomes.csv")
Perform paired t-tests
ttests <- perform_paired_ttests(data)
Generate comprehensive report
results <- generate_statistical_report(data)
Analyses Included:
Register
POST /api/v1/auth/register
{
"email": "patient@example.com",
"username": "patient123",
"password": "securepass",
"first_name": "John",
"last_name": "Doe"
}
Login
POST /api/v1/auth/login
{
"username": "patient123",
"password": "securepass"
}
Response
{
"access_token": "eyJ...",
"token_type": "bearer"
}
Get all weeks
GET /api/v1/curriculum/weeks
Get specific week
GET /api/v1/curriculum/week/1
Get week sessions
GET /api/v1/curriculum/week/1/sessions
Log pain entry
POST /api/v1/pain/log
{
"pain_level": 6,
"pain_locations": "[\"lower_back\", \"hip_right\"]",
"sleep_quality": 5,
"fatigue_level": 7,
"medications_taken": "[\"ibuprofen 400mg\"]"
}
Get pain history
GET /api/v1/pain/history?limit=30
Get analytics
GET /api/v1/pain/analytics
Query AI
POST /api/v1/rag/query
{
"query": "What are the side effects of long-term NSAID use?",
"conversation_id": 123,
"use_history": true
}
Response
{
"response": "Long-term NSAID use can lead to several side effects...",
"sources": [
{"source": "AAFP_journal_2020.pdf", "content": "..."}
],
"conversation_id": 123,
"message_id": 456
}
Get pre-test
GET /api/v1/assessments/week/1/pre
Submit answers
POST /api/v1/assessments/week/1/pre/submit
{
"answers": {
"q1": "B",
"q2": "A",
...
}
}
Full API documentation available at: http://localhost:8000/docs
Backend tests
cd backend
pytest tests/ -v --cov
Frontend tests
cd frontend
npm test
Integration tests
docker-compose -f docker-compose.test.yml up --abort-on-container-exit
See research/support-groups/global_comparison.md for comprehensive analysis of pain support programs worldwide:
See research/medications/ for detailed compilations.
The visual-aids/ directory includes templates and examples for:
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Areas where contributions are especially valuable:
[Choose appropriate license - MIT, GPL, etc.]
This project was inspired by the lived experience of patients navigating chronic pain management in a healthcare system that often dismisses or under-treats pain due to fear of regulatory scrutiny.
Special thanks to:
Check logs
docker-compose logs -f
Restart services
docker-compose down
docker-compose up -d
Issue: Database connection errors
Verify PostgreSQL is running
docker-compose ps postgres
Check connection
docker-compose exec postgres psql -U postgres -d pain_management -c "SELECT 1;"
Issue: RAG queries returning no results
Verify documents are ingested
docker-compose exec backend python -m backend.scripts.check_vector_db
Re-ingest documents
docker-compose exec backend python -m backend.scripts.ingest_docs
Issue: Frontend can't reach backend
Check REACT_APP_API_URL in frontend .env
Ensure backend is running on expected port
curl http://localhost:8000/health
---
Built with β€οΈ for pain patients seeking knowledge, community, and better care.