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.
These instructions will guide you through setting up and running the application on your local machine.
Ensure you have the following installed:
- JDK 11 or newer
- Maven
- Your favorite IDE (e.g., IntelliJ IDEA, Eclipse, VS Code)
-
Clone the repository
Open your terminal and run:
git clone https://github.com/ranitraj/Spring-FitnessTracker.git cd Spring-FitnessTracker
-
Build the project
Using Maven:
mvn clean install
-
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.
The H2 database console is enabled by default and can be accessed through your web browser for direct database interactions:
- Navigate to
http://localhost:8080/h2-console
in your browser. - Use the following settings to connect:
- JDBC URL:
jdbc:h2:mem:workouts_db
- User Name:
sa
- Password: (leave this blank)
- JDBC URL:
- Click Connect to access the database console.
This configuration can be found in the application.properties
file located in the path: src/main/resources
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.
- Method: POST
- URL:
/workouts
- Body:
{
"workoutDate": "2024-05-06 00:00:00",
"workoutType": "Cardio",
"durationMinutes": 30,
"caloriesBurned": 325.6
}
- Method: GET
- URL:
/workouts
- Method: GET
- URL:
/workouts/{id}
-
Method: PUT
-
URL:
/workouts/{id}
-
Body: (Modify as needed)
{ "workoutDate": "2024-05-06 00:00:00", "workoutType": "Legs", "durationMinutes": 45, "caloriesBurned": 572.6 }
- Spring Boot - The web framework used
- H2 Database - In-memory database for development and testing
- Maven - Dependency Management