Skip to content

Repository files navigation

Hospital Shift Optimization & Scheduling System

An automated scheduling and shift optimization platform designed for hospital clinics (such as the Louis Pasteur University Hospital). The system balances staff availability, specialized qualifications, and complex clinical constraints using Mathematical Optimization.


πŸš€ Project Overview

The application streamlines clinical scheduling by dividing the workflow into two major pillars:

  1. Core Administration & Tracking (Phase 1):
  • Employees: Log in to submit their unavailabilities and manage their medical qualifications.
  • Clinic Managers: Oversee specific clinics, manually adjust schedules, and manage staff constraints.
  1. Automated Optimization (Phase 2):
  • Uses a Linear Programming (LP) solver to automatically construct optimal monthly or weekly shift schedules, fully respecting employee unavailabilities and required clinical credentials.

πŸ› οΈ Technical Stack

  • Frontend: React, Vite, TypeScript, Zustand (State Management), Axios
  • Backend: Python (FastAPI), SQLAlchemy (ORM), Alembic (Migrations)
  • Database: PostgreSQL
  • Containerization: Docker & Docker Compose

πŸ“‚ Project Structure

β”œβ”€β”€ .agents/
β”‚   └── rules/              # Custom behavioral guidelines for AI development agents
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/            # FastAPI REST endpoints
β”‚   β”‚   β”œβ”€β”€ models/         # SQLAlchemy ORM models
β”‚   β”‚   β”œβ”€β”€ schemas/        # Pydantic data validation and serialization
β”‚   β”‚   └── services/       # Core business logic and LP optimization algorithms
β”‚   └── database/           # DB engine sessions and migrations
β”œβ”€β”€ frontend/
β”‚   └── src/
β”‚       β”œβ”€β”€ api/            # API client configurations (Axios)
β”‚       β”œβ”€β”€ components/     # Reusable UI component library
β”‚       β”œβ”€β”€ stores/         # Global application state (Zustand)
β”‚       └── views/          # Page layouts (Manager Board, Calendars)
β”œβ”€β”€ docker-compose.yml      # Orchestrates Python, React, and PostgreSQL containers
└── CONTEXT.md              # Global technical architectural context


⚑ Quick Start (Docker Deployment)

The easiest way to run the entire stack (React frontend, FastAPI backend, and PostgreSQL database) is using Docker Compose.

Prerequisites

Make sure you have Docker and Docker Compose installed on your system.

Running the Application

  1. Clone the repository and navigate to the root directory:
git clone <repository-url>
cd scheduling

Copy the environment template and replace the placeholder password and secret:

Copy-Item .env.example .env
  1. Build and start the containers in detached mode (PowerShell):
.\start.ps1 -Detached

This command automatically:

  • Builds the React frontend container.
  • Builds the Python FastAPI backend container.
  • Retries one transient Docker BuildKit snapshot failure automatically.
  • Applies pending Alembic database migrations before the backend starts.
  • Pulls and initializes the PostgreSQL database.
  • Links them all under a single shared network.
  1. Verify the services are running:
docker compose ps
  1. Access the applications:

Stopping the Services

To stop and remove all containers, networks, and associated volumes:

docker compose down -v

πŸ§‘β€πŸ’» Development Rules & Guidelines

If you are modifying this project or using an AI developer agent (like Antigravity), you must strictly adhere to the contracts defined in .agents/rules/:

  • global.md: Enforces strict English code, docstrings, type hinting, and structural modularity.
  • backend.md: Mandates a strict 1:1:1 domain decoupling (SQLAlchemy Models ↔ Pydantic Schemas ↔ FastAPI Routers).
  • database.md: Outlines transaction safety boundaries and Alembic migration protocols.

Automatic test/demo data

The backend startup runs the database bootstrap before Uvicorn. Schema creation is always safe to run, while deterministic mock data is updated only when explicitly enabled:

AUTO_SEED=true
SEED_CONFIG=config_1

Each seed profile declares a version. The backend stores applied versions in seed_versions and skips an already-current profile. Increment the profile's version whenever its data changes. Keep AUTO_SEED=false (the default) for production databases; enable it only for CI, preview, test, or controlled demo environments.

  • database-schema.md: Defines the exact relational database layout.

About

πŸ₯ Hospital shift scheduling platform. Optimizes clinical rotas with Linear Programming 🧠 | Built via Agentic Workflow πŸ€– with FastAPI ⚑ & React βš›οΈ

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages