Skip to content

A full-stack web application designed to track Body Mass Index (BMI) over time. Unlike simple static calculators, this project leverages FastAPI for a high-performance backend and SQLite for data persistence, allowing users to store and analyze their history log.

Notifications You must be signed in to change notification settings

A-Najjar/FastAPI-BMI-App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BMI Tracker

BMI Calculator Web Application

Video Demo

youtube video

Description

A full-stack web application designed to track Body Mass Index (BMI) over time. Unlike simple static calculators, this project leverages FastAPI for a high-performance backend and SQLite for data persistence, allowing users to store and analyze their history log.

Key Technologies: Python, FastAPI, SQLite, HTML/Bootstrap.

  • Persistent History Tracking:
    • Utilizes a SQLite database to store user records permanently.
    • Performs backend calculations to analyze weight trends and percentage changes compared to previous entries.

The application features:

  • BMI Calculation: Users input their weight and height, and the app calculates their BMI and categorizes it.
  • History: Users can view their BMI calculation history, including the percentage change in BMI from previous records.
  • CORS-enabled: The app allows communication between the frontend and backend even when hosted on different origins, thanks to FastAPI’s CORS middleware.

Files

  • app.py: This is the FastAPI backend. It handles the POST request to calculate BMI and the GET request to retrieve the BMI history.
  • index.html: This HTML file contains the frontend interface for the user to input their weight and height, see BMI calculations, and view the history.
  • requirements.txt: Lists the Python dependencies required for the project.

Features

  • BMI Calculation:

    • The app calculates BMI using the formula:
      [ \text{BMI} = \frac{\text{weight (kg)}}{\text{height (m)}^2} ]
    • It classifies BMI into categories (Underweight, Normal, Overweight, Obese).
  • History Feature:

    • Users can track their previous BMI calculations along with the percentage change between them.
    • The app saves BMI history in an SQLite database.
  • Responsive Design:

    • The app uses Bootstrap to make the frontend responsive and user-friendly across different devices.

Setup and Installation

  1. Clone the repository:
    git clone https://github.com/A-Najjar/FastAPI-BMI-App.git
    cd bmi_calculator
    
  2. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
  1. Install dependencies:
pip install -r requirements.txt
  1. Run the FastAPI application:
uvicorn app:app --reload

you can add /docs to the url to get to the swaggar ui

  1. Access the frontend:

    • Open the index.html file in your browser, or serve it using a local HTTP server (e.g., python -m http.server).
  2. Test the application:

    • Enter your weight and height on the frontend.
    • Click "Calculate BMI" to get your BMI result.
    • Click "Load History" to view your previous BMI records.

About

A full-stack web application designed to track Body Mass Index (BMI) over time. Unlike simple static calculators, this project leverages FastAPI for a high-performance backend and SQLite for data persistence, allowing users to store and analyze their history log.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages