Skip to content

Repository files navigation

πŸ₯ Frontline Worker Support AI System

A comprehensive multi-agent AI system built for connecting citizens with frontline workers and healthcare services. This prototype demonstrates intelligent triage, service guidance, hospital capacity management, booking, and follow-up communications.

🎯 System Overview

This system provides:

  • Citizen Portal: Easy-to-use interface for submitting requests
  • AI-Powered Triage: Intelligent classification of urgency and service needs
  • Service Guidance: Recommendations based on location and requirements
  • Hospital Capacity: Real-time availability checking
  • Automated Booking: Appointment scheduling with confirmations
  • Follow-up Communications: SMS/email notifications
  • Admin Dashboard: Real-time analytics and case management

πŸ—οΈ Architecture

Backend (FastAPI + Google Cloud)

  • FastAPI: REST API with async support
  • Firestore: NoSQL database for cases, hospitals, bookings
  • Vertex AI: LLM integration for intelligent agents
  • Google Cloud Services: Translation, Speech, Text-to-Speech
  • Twilio: SMS notifications

Frontend (Next.js + React)

  • Next.js 14: Modern React framework with App Router
  • TypeScript: Type-safe development
  • Tailwind CSS: Utility-first styling
  • Recharts: Data visualization
  • Lucide Icons: Beautiful icons

AI Agents

  1. Triage Agent: Classifies urgency and service type
  2. Guidance Agent: Provides service recommendations
  3. Hospital Capacity Agent: Checks availability
  4. Booking Agent: Creates appointments
  5. Follow-up Agent: Sends confirmations
  6. Equity Oversight Agent: Monitors for bias
  7. Analytics Agent: Generates insights

πŸš€ Quick Start

Prerequisites

  • Python 3.9+
  • Node.js 18+
  • Google Cloud Project (optional for local development)

1. Backend Setup

# Navigate to project root
cd /home/sameer/hackathon/inovista-hackathon

# Install Python dependencies
pip install -r requirements.txt

# Copy environment template
cp env.example .env

# Edit .env with your configuration (optional for demo)
# nano .env

# Start the backend server
python -m uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000

2. Frontend Setup

# Navigate to frontend directory
cd frontend

# Install dependencies
npm install

# Start the development server
npm run dev

3. Access the Application

πŸ“Š Demo Flow

Citizen Journey

  1. Submit Request: Citizen describes their situation
  2. AI Triage: System classifies urgency (Emergency/Urgent/Routine)
  3. Service Guidance: Recommends appropriate services/hospitals
  4. Capacity Check: Finds available hospitals with capacity
  5. Booking: Creates appointment with confirmation
  6. Follow-up: Sends SMS/email with details
  7. Dashboard Update: Admin sees real-time analytics

Example: Chest Pain Case

Input: "I have severe chest pain and shortness of breath"
β†’ Triage: EMERGENCY (95% confidence)
β†’ Guidance: Emergency Medical Services
β†’ Capacity: Hospital A has 15 beds available
β†’ Booking: Emergency Dept, immediate appointment
β†’ Follow-up: SMS sent with confirmation code
β†’ Dashboard: Case marked as completed

πŸ—„οΈ Sample Data

The system includes sample data from Pakistan:

  • 220 Frontline Worker Cases: Various emergency and service requests
  • 3000+ Hospitals: Real hospital data with locations and specialties

Load sample data via:

  • Admin Dashboard β†’ "Load Sample Data" button
  • API endpoint: POST /admin/ingest-sample-data

πŸ”§ Configuration

Environment Variables (.env)

# Google Cloud (optional for demo)
GOOGLE_CLOUD_PROJECT=your-project-id
GOOGLE_APPLICATION_CREDENTIALS=path/to/service-account.json
VERTEX_AI_LOCATION=us-central1

# Twilio (optional)
TWILIO_ACCOUNT_SID=your-twilio-account-sid
TWILIO_AUTH_TOKEN=your-twilio-auth-token
TWILIO_PHONE_NUMBER=your-twilio-phone-number

# API Configuration
API_HOST=0.0.0.0
API_PORT=8000
API_DEBUG=true

# Frontend
NEXT_PUBLIC_API_URL=http://localhost:8000

πŸ“± API Endpoints

Core Workflow

  • POST /intake - Submit citizen request
  • POST /triage/{case_id} - Classify case
  • POST /guidance/{case_id} - Get service recommendations
  • POST /capacity/{case_id} - Check hospital availability
  • POST /booking/{case_id} - Create appointment
  • POST /followup/{case_id} - Send notifications
  • POST /process-complete/{case_id} - Run complete flow

Data & Analytics

  • GET /dashboard - Dashboard analytics
  • GET /cases - List cases with filters
  • GET /cases/{case_id} - Get case details
  • GET /health - System health check

Admin

  • POST /admin/ingest-sample-data - Load sample data

🎨 Features

Citizen Portal

  • βœ… Multi-step request form
  • βœ… Real-time processing status
  • βœ… Urgency level selection
  • βœ… Contact information capture
  • βœ… Emergency warnings
  • βœ… Responsive design

Admin Dashboard

  • βœ… Real-time case statistics
  • βœ… Hospital capacity monitoring
  • βœ… Interactive charts and graphs
  • βœ… Recent cases table
  • βœ… System health indicators
  • βœ… Alert notifications
  • βœ… Data ingestion controls

AI Agents

  • βœ… Rule-based triage with confidence scoring
  • βœ… Location-aware service recommendations
  • βœ… Dynamic hospital capacity simulation
  • βœ… Automated booking with confirmations
  • βœ… Multi-channel follow-up (SMS/email mock)
  • βœ… Equity oversight logging
  • βœ… Real-time analytics generation

πŸ§ͺ Testing

Manual Testing

  1. Start both backend and frontend
  2. Visit citizen portal at http://localhost:3000
  3. Submit a test request (e.g., "I have chest pain")
  4. Watch the processing flow in real-time
  5. Check admin dashboard for updates

API Testing

# Health check
curl http://localhost:8000/health

# Submit request
curl -X POST http://localhost:8000/intake \
  -H "Content-Type: application/json" \
  -d '{"request_text": "I need medical help", "urgency": "urgent"}'

# Check dashboard
curl http://localhost:8000/dashboard

πŸš€ Production Deployment

Google Cloud Deployment

  1. Backend: Deploy to Cloud Run
  2. Frontend: Deploy to Firebase Hosting or Vercel
  3. Database: Use Firestore in production mode
  4. AI: Enable Vertex AI APIs
  5. Monitoring: Set up Cloud Monitoring

Docker Deployment

# Backend Dockerfile (create if needed)
FROM python:3.9
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY backend/ .
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

# Frontend Dockerfile (create if needed)
FROM node:18-alpine
WORKDIR /app
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ .
RUN npm run build
CMD ["npm", "start"]

πŸ”’ Security Considerations

  • Input validation and sanitization
  • Rate limiting on API endpoints
  • Authentication for admin dashboard (not implemented in demo)
  • HTTPS in production
  • Environment variable security
  • Database access controls

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“„ License

This project is created for the Inovista Hackathon. See individual component licenses for details.

πŸ†˜ Support

For issues and questions:

  1. Check the API documentation at /docs
  2. Review the console logs for errors
  3. Ensure all services are running
  4. Verify environment configuration

🎯 Future Enhancements

  • Real Vertex AI integration
  • Voice interface with Dialogflow CX
  • Real-time hospital capacity feeds
  • Advanced analytics with BigQuery
  • Mobile app development
  • Multi-language support
  • Geographic information system (GIS) integration
  • Real Twilio SMS integration
  • Authentication and user management
  • Advanced AI models for better triage

About

A comprehensive multi-agent AI system built for connecting citizens with frontline workers and healthcare services. This prototype demonstrates intelligent triage, service guidance, hospital capacity management, booking, and follow-up communications.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages