Skip to content

Fitness tracking application enhanced with Diffblue Cover for robust, automated unit testing.

License

Notifications You must be signed in to change notification settings

ranitraj/Spring-FitnessTracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot Fitness Workout Tracking API

This Spring Boot application demonstrates a simple fitness workout tracking system with CRUD functionality, utilizing an H2 in-memory database for data persistence. This README provides instructions on setting up and running the application, as well as connecting to the H2 database console for data verification and testing.

Getting Started

These instructions will guide you through setting up and running the application on your local machine.

Prerequisites

Ensure you have the following installed:

  • JDK 11 or newer
  • Maven
  • Your favorite IDE (e.g., IntelliJ IDEA, Eclipse, VS Code)

Setup and Run

  1. Clone the repository

    Open your terminal and run:

    git clone https://github.com/ranitraj/Spring-FitnessTracker.git
    cd Spring-FitnessTracker
  2. Build the project

    Using Maven:

    mvn clean install
  3. Run the application

    Execute the following command:

    mvn spring-boot:run

    The application will start and be accessible at http://localhost:8080. However, this URL won't display anything as it is not an actual API endpoint.

Accessing the H2 Database Console

The H2 database console is enabled by default and can be accessed through your web browser for direct database interactions:

  1. Navigate to http://localhost:8080/h2-console in your browser.
  2. Use the following settings to connect:
    • JDBC URL: jdbc:h2:mem:workouts_db
    • User Name: sa
    • Password: (leave this blank)
  3. Click Connect to access the database console.

This configuration can be found in the application.properties file located in the path: src/main/resources

Testing API Endpoints

You can test the API endpoints using Postman or any other API testing tool by sending requests to http://localhost:8080/workouts. Below are sample requests for each available endpoint.

Create a New Workout

  • Method: POST
  • URL: /workouts
  • Body:
{
   "workoutDate": "2024-05-06 00:00:00",
   "workoutType": "Cardio",
   "durationMinutes": 30,
   "caloriesBurned": 325.6
}

Retrieve All Workouts

  • Method: GET
  • URL: /workouts

Retrieve a Workout by ID

  • Method: GET
  • URL: /workouts/{id}

Update a Workout

  • Method: PUT

  • URL: /workouts/{id}

  • Body: (Modify as needed)

    {
      "workoutDate": "2024-05-06 00:00:00",
      "workoutType": "Legs",
      "durationMinutes": 45,
      "caloriesBurned": 572.6
    }

Built With

About

Fitness tracking application enhanced with Diffblue Cover for robust, automated unit testing.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages