An AI-powered healthcare communication platform for research, featuring ElevenLabs voice conversations, medication adherence analysis, and secure patient data tracking.
Database Note: This project uses Neon PostgreSQL (free serverless PostgreSQL) for the database. The backend API is deployed on Railway, giving you the best of both: free database + affordable compute.
- ElevenLabs Voice Chat: Natural voice conversations with AI assistant
- Medication Analysis: NLP-powered analysis of medication adherence from conversations
- Research ID System: Secure authentication for research participants
- Admin Dashboard: Manage research IDs and analyze patient data
- PostgreSQL Database: Track all conversations for research analysis
- HIPAA-Aware Design: Patient safety-first architecture
- Frontend: Next.js 14 + TypeScript + Tailwind CSS (Deployed on Vercel)
- Backend: FastAPI + Python 3.11 (Deployed on Railway)
- Database: Neon PostgreSQL (Free serverless PostgreSQL)
- AI Services: ElevenLabs Conversational AI + Groq AI (Llama models)
- Python 3.11+
- Node.js 18+
- PostgreSQL database
- ElevenLabs API key
- Groq API key (for medication analysis)
# Navigate to backend
cd paco-api
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Set up environment variables
cat > .env << EOF
DATABASE_URL=postgresql://user:password@localhost:5432/paco_db
JWT_SECRET_KEY=$(python -c "import secrets; print(secrets.token_urlsafe(32))")
ADMIN_PASSWORD=your_secure_admin_password
GROQ_API_KEY=gsk_...
ELEVENLABS_API_KEY=your_elevenlabs_key
CORS_ORIGINS=["http://localhost:3000"]
EOF
# Run database migrations
alembic upgrade head
# Seed initial research IDs (optional)
python scripts/seed_research_ids.py
# Start the server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000# Navigate to frontend
cd paco-frontend
# Install dependencies
npm install
# Set up environment variables
cat > .env.local << EOF
NEXT_PUBLIC_API_URL=http://localhost:8000/api/v1
NEXT_PUBLIC_ELEVENLABS_AGENT_ID=your_agent_id
EOF
# Start development server
npm run devVisit http://localhost:3000
PatientCommunication/
├── paco-api/ # FastAPI backend
│ ├── app/
│ │ ├── api/endpoints/ # API routes
│ │ │ ├── auth.py # Authentication
│ │ │ ├── chat.py # ElevenLabs message sync
│ │ │ ├── admin.py # Admin management
│ │ │ └── medication_analysis.py
│ │ ├── core/ # Configuration & security
│ │ ├── models/ # Database models
│ │ ├── schemas/ # Pydantic schemas
│ │ └── services/ # Business logic
│ ├── alembic/ # Database migrations
│ └── requirements.txt
├── paco-frontend/ # Next.js frontend
│ ├── app/ # Next.js app directory
│ ├── components/
│ │ ├── ResearchIDScreen.tsx
│ │ ├── DisclaimerScreen.tsx
│ │ └── ElevenLabsWidget.tsx # Main chat interface
│ ├── lib/api.ts # API client
│ └── types/ # TypeScript types
└── DEPLOYMENT.md # Deployment guide
- ResearchID: Authorized research participants
- UserSession: Active JWT sessions
- DisclaimerAcknowledgment: Research consent tracking
- Conversation: All chat messages (user + assistant)
- MedicationAdherenceAnalysis: NLP analysis results
POST /api/v1/auth/login- Login with research IDPOST /api/v1/auth/validate- Validate research IDPOST /api/v1/auth/disclaimer- Acknowledge disclaimer
POST /api/v1/chat/save-message- Save ElevenLabs messagesPOST /api/v1/chat/sync-elevenlabs-conversation- Sync full conversationGET /api/v1/chat/conversations/elevenlabs- List conversationsPOST /api/v1/chat/history- Get conversation history
POST /api/v1/admin/research-ids- Create research IDGET /api/v1/admin/research-ids- List all research IDsPUT /api/v1/admin/research-ids/{id}- Update research IDDELETE /api/v1/admin/research-ids/{id}- Deactivate research IDGET /api/v1/admin/stats- System statistics
POST /api/v1/medication-analysis/analyze- Analyze adherence
# Database
DATABASE_URL=postgresql://user:password@host:5432/database
# Security
JWT_SECRET_KEY=your_secret_key
ADMIN_PASSWORD=your_admin_password
# APIs
GROQ_API_KEY=gsk_...
ELEVENLABS_API_KEY=...
# CORS
CORS_ORIGINS=["https://your-frontend.vercel.app"]NEXT_PUBLIC_API_URL=https://your-backend.railway.app/api/v1
NEXT_PUBLIC_ELEVENLABS_AGENT_ID=your_agent_id- JWT-based authentication with expiry
- Research ID validation
- Admin password protection for sensitive endpoints
- CORS protection
- SQL injection prevention (SQLAlchemy ORM)
- Secure session management
# Run migrations
alembic upgrade head
# Create new migration
alembic revision --autogenerate -m "description"
# Run tests
pytest
# Format code
black app/# Development
npm run dev
# Build
npm run build
# Lint
npm run lintMIT License - See LICENSE file for details
Extremely affordable for research projects!
- Database (Neon): FREE forever
- Backend (Railway): ~$5-10/month
- Frontend (Vercel): FREE
- APIs (ElevenLabs + Groq): $5-30/month depending on usage
Total: ~$15-40/month for complete infrastructure
See COSTS.md for detailed breakdown and optimization tips.
For issues or questions, please open a GitHub issue.