A Flask-based backend API for estimating arterial blood pressure (ABP) using a trained machine learning/deep learning model.
This repository demonstrates backend API development, model integration, input preprocessing, prediction handling, environment-based configuration, logging, and a simple supporting dashboard/testing workflow.
Deployment status: Not currently publicly hosted.
The project exposes a Python/Flask API that receives input data, prepares it for the trained model, performs inference, and returns the predicted ABP values as JSON.
The repository is intended as a technical portfolio project showing how a trained model can be integrated into a backend service.
Machine learning models are often developed separately from the applications that use them.
This project focuses on turning an ABP estimation model into an API that can:
- receive structured input,
- preprocess the input using the required scaler,
- run inference through the trained model,
- reverse the scaling of the model output,
- return the prediction through a JSON response.
The application uses Flask as the API layer and integrates the trained model and preprocessing components directly into the backend workflow.
High-level flow:
Client Request
|
v
Flask API
|
v
Input Validation / Preparation
|
v
Feature Scaling
|
v
Trained Model
|
v
Inverse Transformation
|
v
JSON Prediction Response
- Python
- Flask
- TensorFlow / Keras
- scikit-learn
- NumPy
- Logging
- Environment variables
- Git / GitHub
Additional repository files may include dashboard or testing utilities used during development.
abp-api/
|
|-- app.py
|-- dashboard.py
|-- requirements.txt
|-- Procfile
|-- .env.example
|-- .gitignore
|-- README.md
|-- model / data artifacts (where applicable)
`-- supporting scripts and files
The exact set of supporting files may vary depending on the current repository version.
The backend performs the following steps:
- Accepts a request from the client.
- Reads and prepares the input values.
- Converts the input into the shape expected by the model.
- Applies the fitted input scaler.
- Runs inference using the loaded model.
- Applies inverse transformation to the prediction.
- Returns the predicted ABP values as JSON.
A successful prediction response follows the general structure:
{
"predicted_abp": [
...
]
}Errors are returned as JSON responses rather than raw application output.
git clone https://github.com/Fatoomnoour/abp-api.git
cd abp-apiWindows:
py -m venv .venv
.venv\Scripts\activateLinux/macOS:
python3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txtDependency compatibility may depend on the Python and TensorFlow versions installed on the machine.
Copy .env.example if needed and configure the application locally.
Current example:
PORT=5000No real credentials or secrets should be committed to the repository.
python app.pyBy default, the application uses port 5000 unless another value is supplied through the PORT environment variable.
The application reads the server port from the environment:
PORT
Example:
PORT=5000The repository intentionally does not contain ngrok credentials or ngrok configuration.
- No credentials should be hardcoded in source files.
.envis excluded through.gitignore..env.examplecontains example configuration only.- Historical ngrok-related code has been removed from the current application.
- Secrets should always be supplied through environment variables or a secure secret-management solution.
The API uses Python logging to provide visibility into important stages of request processing, including:
- server startup,
- input preparation,
- transformed input shape,
- prediction execution,
- output shape,
- runtime errors.
This makes debugging and local development easier without relying on print statements.
The backend integrates a trained TensorFlow/Keras model.
The inference workflow includes:
Raw Input
|
v
NumPy / Input Reshaping
|
v
StandardScaler Transformation
|
v
TensorFlow / Keras Model
|
v
Prediction
|
v
Inverse Scaling
|
v
ABP Output
The model and preprocessing artifacts must be available in the expected repository locations for successful inference.
Prediction logic is wrapped in error handling so failures can be logged and returned to the client as JSON.
General error response format:
{
"error": "error message"
}Further validation and production-grade exception handling can be added as the API evolves.
The repository contains development/testing utilities, but a complete automated test suite is not yet documented as production-ready.
Recommended next improvements:
- unit tests for input preparation,
- API endpoint tests,
- invalid-input tests,
- model-loading checks,
- prediction-shape validation.
A Streamlit dashboard is included in the repository history/current project files as a supporting interface for interacting with or demonstrating the model.
It should be treated as a development/demo component rather than evidence of public production deployment unless a live deployment is available.
Current status: Not currently publicly hosted.
The repository may contain deployment-related files from previous experiments, such as a Procfile, but the project should not be described as publicly deployed unless a working live deployment is verified.
Possible future deployment targets include any platform capable of running a Python/Flask application with the required model dependencies.
Current limitations may include:
- dependency compatibility across Python/TensorFlow versions,
- no verified public production deployment,
- limited automated test coverage,
- local model/artifact dependencies,
- additional validation may be required for production usage,
- the project is a portfolio/technical implementation and should not be treated as a medical diagnostic system.
High-value next steps:
- add request schema validation,
- add automated API tests,
- improve dependency reproducibility,
- add OpenAPI/Swagger documentation where appropriate,
- add CI for linting and tests,
- containerize the API with Docker,
- deploy a verified live demo,
- separate application configuration from model-loading logic,
- improve production error handling.
This project demonstrates experience with:
- Python backend development,
- Flask API design,
- machine learning model integration,
- preprocessing pipelines,
- JSON request/response handling,
- environment-based configuration,
- logging,
- Git/GitHub repository hygiene.
This project is intended for educational, research, and portfolio purposes.
ABP predictions produced by the model should not be used as medical advice, diagnosis, or a replacement for validated clinical measurement devices.