Skip to content

Shreeja-88/ambulance-dispatch-optimization-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ambulance Dispatch Optimization System 🚑

Overview

This repository contains the backend for an Ambulance Dispatch Optimization System built with Python Flask and MySQL. The service manages ambulances, hospitals, emergency requests, dispatch records, and response logs.


Features

  • REST API backend using Flask
  • MySQL database integration with mysql-connector-python
  • Automatic database and table creation on startup
  • Simple nearest-available ambulance dispatch logic
  • JSON responses with error handling

Tech Stack

  • Backend: Flask (Python)
  • Database: MySQL
  • Connector: mysql-connector-python

API Endpoints

  • GET /ambulances - return all ambulances
  • POST /ambulance - add a new ambulance
  • GET /hospitals - return all hospitals
  • POST /request - create an emergency request
  • POST /dispatch - assign nearest available ambulance to a request
  • GET /dispatch/history - return all dispatch records with joins

Setup Instructions

1. Create and activate a virtual environment

python -m venv .venv
.venv\Scripts\Activate

2. Install dependencies

cd backend
pip install -r requirements.txt

3. Configure the database backend

By default, the app uses SQLite so it can run without a MySQL server. This is the fastest way to start the backend locally.

If you want to use MySQL later, set DB_TYPE=mysql and configure credentials.

Default SQLite file:

  • SQLITE_DB_FILE=ambulance_system.db

Optional MySQL settings:

  • DB_TYPE=mysql
  • DB_HOST=127.0.0.1
  • DB_USER=root
  • DB_PASSWORD= (empty)
  • DB_NAME=ambulance_system

Example for MySQL:

set DB_TYPE=mysql
set DB_HOST=127.0.0.1
set DB_USER=root
set DB_PASSWORD=your_password
set DB_NAME=ambulance_system

4. Run the app

python app.py

The backend will run on http://127.0.0.1:5000 in debug mode.


Notes

  • The app creates the ambulance_system database and required tables automatically when first run.
  • Dispatch selection uses a simple first-available ambulance strategy.

Development

Start the server locally and test the routes with Postman, curl, or any REST client.


License

This repository is distributed under the terms of the existing license.

About

A DBMS-based full-stack system that optimizes ambulance dispatch using real-time availability, location, and emergency priority. Built with MySQL, Flask, and a simple web interface.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors