A full-stack web application that demonstrates and compares different scheduling algorithms for healthcare resource allocation. The system implements three classic CPU scheduling algorithms adapted for healthcare resource management: First-Come-First-Served (FCFS), Priority-Based Scheduling, and Round Robin.
This project simulates a hospital resource management system where patients request healthcare resources (doctors, beds, equipment) and different scheduling algorithms determine the allocation order. It includes both a Python backend API and a React frontend for visualization and interaction.
-
Three Scheduling Algorithms:
- FCFS (First-Come-First-Served): Processes requests in arrival order
- Priority-Based: Allocates resources based on patient priority levels (HIGH, MEDIUM, LOW)
- Round Robin: Fair time-sharing with configurable time quantum
-
Resource Types:
- Doctors (8 available)
- Beds (15 available)
- Medical Equipment (10 available)
-
Full-Stack Application:
- FastAPI backend with RESTful endpoints
- React frontend with real-time resource visualization
- CORS-enabled for seamless frontend-backend communication
-
Comprehensive Testing:
- Standalone test suite demonstrating each algorithm
- Input/output comparison for algorithm analysis
472Project 2/
├── backend/ # Python FastAPI backend
│ ├── core/
│ │ └── resource_manager.py # Resource allocation engine
│ ├── models/
│ │ └── resource.py # Data models (Request, Resource, enums)
│ ├── schedulers/
│ │ ├── base_scheduler.py # Abstract scheduler interface
│ │ ├── fcfs_scheduler.py # FCFS implementation
│ │ ├── priority_scheduler.py # Priority-based implementation
│ │ └── round_robin_scheduler.py # Round Robin implementation
│ └── main.py # FastAPI application & routes
│
├── scheduler-frontend/ # React frontend
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── api.js # API client
│ │ └── App.js # Main application
│ └── package.json
│
├── test_schedulers.py # Comprehensive test suite
└── requirements.txt # Python dependencies
- Python 3.8+
- Node.js 14+ and npm
- pip (Python package manager)
-
Clone the repository:
git clone https://github.com/MrYo10/472Project2.git cd 472Project2 -
Install Python dependencies:
pip install -r requirements.txt
-
Install frontend dependencies:
cd scheduler-frontend npm install cd ..
If using VSCode, use the provided launch configuration:
- Open the project in VSCode
- Go to Run and Debug (Ctrl+Shift+D / Cmd+Shift+D)
- Select "Run Frontend + Backend" from the dropdown
- Press F5 or click the green play button
Terminal 1 - Backend:
cd backend
uvicorn main:app --reloadThe backend will start on http://localhost:8000
Terminal 2 - Frontend:
cd scheduler-frontend
npm startThe frontend will start on http://localhost:3000
Run the comprehensive test suite to see all algorithms in action:
python test_schedulers.pyThis will execute 5 test scenarios:
- FCFS Scheduler demonstration
- Priority Scheduler demonstration
- Round Robin Scheduler demonstration
- Algorithm comparison with identical inputs
- Resource shortage scenario
Add a new patient request to the queue.
Request Body:
{
"patient_name": "John Doe",
"resource_type": "doctor",
"priority": 3,
"duration": 30
}Priority Levels:
1= LOW2= MEDIUM3= HIGH
Resource Types:
"doctor""bed""equipment"
Execute scheduling algorithm and allocate resources.
Parameters:
alg: Algorithm to use (fcfs,priority, orrr)
Response:
{
"scheduler": "Priority-Based Scheduler",
"allocations": [
{
"patient": "John Doe",
"resource": "Dr. Smith",
"resource_type": "doctor",
"duration": 30
}
]
}Get current status of all resources.
Get all pending requests in the queue.
| Algorithm | Advantages | Disadvantages | Best Use Case |
|---|---|---|---|
| FCFS | Simple, fair arrival order | Ignores urgency | Non-emergency scenarios |
| Priority | Critical cases first | Low-priority starvation | Emergency departments |
| Round Robin | Fair time distribution | Context switching overhead | Balanced workloads |
Backend:
- Python 3.x
- FastAPI - Modern web framework
- Pydantic - Data validation
- Uvicorn - ASGI server
Frontend:
- React 19.x
- React Scripts
- JavaScript (ES6+)
The backend uses FastAPI with hot-reload enabled:
cd backend
uvicorn main:app --reloadReact development server with hot-reload:
cd scheduler-frontend
npm start- Start both backend and frontend
- Open
http://localhost:3000in your browser - Add patient requests through the UI
- Select a scheduling algorithm (FCFS, Priority, or Round Robin)
- View resource allocations and compare algorithm performance