Inspiration

In India, blood shortages account for thousands of preventable deaths annually—not because of a lack of donors, but because of slow, fragmented coordination. When a hospital puts out an emergency call, teams often rely on scattered WhatsApp messages, phone trees, and manual spreadsheets.

I wanted to build a system that uses intelligent matching to cut through the noise, but with one critical difference: explainability. In high-stakes medical logistics, coordinators need to trust the AI's recommendations. A black-box score won't save a life if nobody trusts it. RaktConnect makes every match transparent, showing exactly why a donor was ranked highest.

What it does

RaktConnect is a full-featured emergency blood donor coordination dashboard.

When a hospital needs blood urgently, the system:

  1. Matches the recipient's blood group with compatible, verified, and available donors.
  2. Ranks donors using a 6-factor explainable score:
    • Blood Compatibility (40)
    • Distance (30)
    • Availability (15)
    • Urgency (10)
    • Reliability (5)
    • Verification (2)
  3. Displays a transparent breakdown so coordinators see exactly how the score is calculated.
  4. Tracks the emergency request through a live workflow (Created → Matching → Contact → Confirmed → Closed).

Beyond matching, RaktConnect includes:

  • 🏥 Blood Bank Inventory — monitor simulated bank stock levels.
  • 📝 Donor Registration — add new demo donors.
  • 🗺️ Network Map — visualize donor distribution geographically.
  • 🤖 AI Assistant — Groq-powered Q&A for blood compatibility and donation basics.
  • 📊 Analytics Dashboard — monitor supply and demand trends. ## How I built it Tech Stack:
  • Frontend & Logic: Python + Streamlit
  • Data Processing: Pandas, NumPy
  • Geospatial: Haversine formula for distance calculations
  • AI: Groq (Llama-3.1-8B-Instruct) for the educational AI Assistant
  • Styling: Custom CSS with dark/light theme support

Architecture:

  • The app uses Streamlit's session_state to manage the multi-step emergency workflow, chat history, and theme preferences across 7 tabs.
  • 10,000 synthetic donor records are generated using numpy.random with realistic blood-group distributions and geographic clustering around 10 Indian cities.
  • The matching engine computes pairwise distances using the Haversine formula and combines six weighted factors into a single explainable score, capped at 100.
  • The AI Assistant is designed with graceful degradation — if the Groq API key is missing or the service fails, the AI tab simply shows a friendly "unavailable" message without crashing the rest of the app. ## Challenges I ran into ### 1. Graceful API Failure The biggest technical challenge was ensuring the app wouldn't crash if the GROQ_API_KEY was missing. I solved this by using st.secrets.get("GROQ_API_KEY", None) and wrapping the Groq client initialization in try-except blocks, allowing the AI tab to fail safely while the core emergency functionality remained fully operational.

2. CSS Scope Conflicts

Styling a complex multi-tab Streamlit app with custom CSS proved tricky. Broad global selectors (like styling every div) would break native Streamlit widgets—select boxes, text inputs, and buttons would become unreadable. I learned to strictly scope my CSS to custom class names (e.g., .rc-card, .match, .hero) and used minimal global overrides.

3. Realistic Demo Data

Generating 10,000 synthetic donors that looked realistic required careful calibration. I had to:

  • Match blood-group distributions to real-world frequencies.
  • Spread donors across 10 cities with realistic geographic variance.
  • Randomize verification status, donation history, and availability without creating unrealistic patterns.

4. State Management Across Tabs

Managing state across 7 tabs while maintaining a consistent emergency workflow was complex. I used a centralized session_state dictionary with clear default values and ensured that actions in one tab (like creating an emergency) would reflect instantly across all others.

What I learned

Explainable AI (XAI) builds trust. In life-critical applications, users won't accept a black-box recommendation. Breaking a score into intuitive, weighted components makes the system credible and actionable.

  • Graceful degradation is essential. A production app should never crash because of a missing optional dependency or API key. Planning for failure—and providing clear user feedback—is a sign of maturity.
  • Geospatial matching is computationally simple but impactful. The Haversine formula, combined with basic weighted scoring, can deliver highly relevant results without needing heavy ML models.
  • Streamlit is surprisingly powerful for rapid prototyping. With custom CSS and session state, I built a complex, multi-tab dashboard with interactive workflows entirely in Python—no frontend framework required.

What's next for RaktConnect

  • Live integration with verified blood banks and hospital APIs.
  • SMS/WhatsApp alerts to donors based on proximity and urgency.
  • Regional language support (Tamil, Hindi, Marathi).
  • Expanded explainability — adding visual charts for score components.
  • Real-time inventory sync with government and private blood banks across India.

Built With

Share this project:

Updates