Connecting Thalassemia patients with blood donors through intelligent SMS communication
Project Pavlov is an intelligent SMS-based blood donation system designed specifically to help Thalassemia patients find compatible blood donors. The system uses natural language processing and automated workflows to facilitate blood donation requests and donor registration through simple SMS conversations.
- Bridge the gap between Thalassemia patients and blood donors
- Simplify blood donation through accessible SMS communication
- Ensure privacy and compliance with healthcare regulations
- Provide education about Thalassemia and blood donation
Thalassemia patients require regular blood transfusions, but finding compatible donors can be challenging. Traditional methods are often slow and inefficient, leading to delays in critical care.
- Intelligent Chatbot: Natural language processing for donor registration and blood requests
- Multi-step Registration: Guided donor registration process via SMS
- Blood Compatibility Matching: Automatic matching of compatible blood types
- Educational Content: Thalassemia awareness and blood donation education
- Live Statistics: Real-time donor and request tracking
- Interactive Charts: Daily registration trends and blood group availability
- Compliance-focused: Privacy-protected donor information display
- Responsive Design: Modern, accessible web interface
- Data Hashing: Phone numbers and personal data are hashed for privacy
- Healthcare Compliance: Designed according to healthcare data protection standards
- Audit Trails: Complete tracking of all interactions and requests
- Urgent Blood Requests: Priority handling for emergency situations
- Donor Notifications: Automated SMS alerts to compatible donors
- Location-based Matching: Geographic proximity consideration
project-pavlov/
โโโ app.py # Flask backend server (route handlers)
โโโ streamlit_app.py # Streamlit frontend dashboard
โโโ utils/ # Modular utility functions
โ โโโ constants.py # Configuration constants
โ โโโ data_utils.py # API calls & data processing
โ โโโ chart_utils.py # Chart creation functions
โ โโโ helpers.py # Utility functions
โ โโโ backend_utils.py # Backend logic & state management
โ โโโ styles.py # CSS styling & HTML templates
โโโ pyproject.toml # Modern Python packaging
โโโ requirements.txt # Legacy pip dependencies
โโโ README.md # This file
- Backend: Flask (Python web framework)
- Frontend: Streamlit (data science web app)
- SMS: Twilio (communication platform)
- Charts: Plotly (interactive visualizations)
- Data: Pandas (data manipulation)
- Python 3.8 or higher
- Twilio account (for SMS functionality)
- ngrok (for local development with Twilio webhooks)
git clone https://github.com/bloodwarriors/project-pavlov.git
cd project-pavlov# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create virtual environment and install dependencies
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e .# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -e .# Copy environment template
cp .env.example .env
# Edit .env with your Twilio credentials
nano .env# Terminal 1: Start Flask backend
python app.py
# Terminal 2: Start Streamlit frontend
streamlit run streamlit_app.py- Python: 3.8 or higher
- Memory: 512MB RAM minimum
- Storage: 100MB free space
- Network: Internet connection for Twilio SMS
For development and testing, install with dev dependencies:
# Using uv
uv pip install -e ".[dev]"
# Using pip
pip install -e ".[dev]"For production deployment, consider:
- Database: Replace in-memory storage with PostgreSQL/MySQL
- Caching: Add Redis for session management
- Load Balancer: Use nginx for production traffic
- SSL: Configure HTTPS for secure communications
Create a .env file in the project root:
# Twilio Configuration
TWILIO_ACCOUNT_SID=your_account_sid_here
TWILIO_AUTH_TOKEN=your_auth_token_here
TWILIO_PHONE_NUMBER=+1234567890
# Flask Configuration
FLASK_ENV=development
FLASK_DEBUG=True
# Optional: Database Configuration (for production)
DATABASE_URL=postgresql://user:password@localhost/pavlov_db- Create Twilio Account: Sign up at twilio.com
- Get Phone Number: Purchase a Twilio phone number
- Configure Webhook: Set webhook URL to
https://your-domain.com/webhook - Test SMS: Verify SMS functionality in Twilio console
User: hi
Bot: ๐ฉธ Welcome to Blood Warriors - Project Pavlov!
How can we help you today?
1. ๐ฉธ Register as Blood Donor
2. ๐จ Request Blood
3. ๐ Learn About Thalassemia
4. ๐ Get Help
User: 1
Bot: ๐ฉธ Welcome to Blood Warriors Donor Registration!
Please provide your blood type (A+, A-, B+, B-, AB+, AB-, O+, O-):
User: A+
Bot: Great! Now please provide your full name:
User: John Doe
Bot: Please provide your email address:
User: john@example.com
Bot: Please provide your location (city/district):
User: Mumbai
Bot: Please provide your age:
User: 25
Bot: Are you available for donation? (YES/NO):
User: YES
Bot: โ
Registration Successful!
You're now registered as a A+ donor in Mumbai.
Donor ID: a1b2c3d4e5f6
We'll notify you when someone needs your blood type.
User: 2
Bot: ๐จ Blood Request Form
Please provide your blood type (A+, A-, B+, B-, AB+, AB-, O+, O-):
User: O+
Bot: What's the urgency level? (URGENT/NORMAL):
User: URGENT
Bot: Please provide your location (city/district):
User: Delhi
Bot: โ
Blood Request Submitted!
๐จ O+ blood needed in Delhi
๐ We've notified 3 potential donors
โฐ We'll contact you within 30 minutes
- Test SMS conversations in real-time
- Simulate donor registration and blood requests
- Clear chat history while preserving donor data
- Real-time metrics: Total donors, available donors, active requests
- Interactive charts showing daily registration trends
- Blood group availability visualization
- Privacy-compliant donor listing
- Hashed phone numbers for security
- Blood group distribution charts
- Anonymized request tracking
- Urgency level monitoring
- Request status management
utils/
โโโ constants.py # Blood types, educational content, colors
โโโ data_utils.py # API calls, data retrieval, health checks
โโโ chart_utils.py # Plotly chart creation functions
โโโ helpers.py # Validation, hashing, utility functions
โโโ backend_utils.py # SMS handling, conversation logic, state management
โโโ styles.py # CSS styling and HTML templates
Handles incoming SMS from Twilio
- Input: Twilio webhook payload
- Output: TwiML response
Returns system statistics
{
"total_donors": 15,
"available_donors": 12,
"active_requests": 3,
"total_requests": 25
}Returns all registered donors (public data only)
{
"+1234567890": {
"blood_type": "A+",
"location": "Mumbai",
"available": true,
"registered_at": "2025-08-04T10:30:00"
}
}Returns all blood requests
{
"req_1": {
"blood_type": "O+",
"urgency": "urgent",
"location": "Delhi",
"status": "active",
"created_at": "2025-08-04T11:00:00"
}
}Health check endpoint
{
"status": "healthy",
"timestamp": "2025-08-04T11:00:00"
}- File:
streamlit_app.py(tab1) - Purpose: Test SMS conversations
- Features: Real-time chat, message history, clear functionality
- File:
streamlit_app.py(tab2) - Purpose: View system statistics and charts
- Features: Live metrics, interactive charts, responsive design
- File:
streamlit_app.py(tab3) - Purpose: View registered donors
- Features: Privacy-compliant display, blood group distribution
- File:
streamlit_app.py(tab4) - Purpose: View blood requests
- Features: Anonymized data, urgency tracking
This project is licensed under the MIT License - see the LICENSE file for details.
- Thalassemia Patients: For inspiring this project
- Blood Donors: For their life-saving contributions
- Twilio: For providing SMS infrastructure
- Streamlit: For the amazing web app framework
- Open Source Community: For the tools and libraries
๐ฉธ Every blood donation saves up to 3 lives. You're not just donating blood - you're giving someone a chance to live! โค๏ธ