Giter Site home page Giter Site logo

simple-workouttracker's Introduction

*** Project has been re-worked, please visit FitBuddy ***

Workout Tracker app

Workout Tracker app made with Spring Boot.

Alt text Alt text

What's inside

The project uses the following technologies:

  • Java 11
  • Spring Boot
  • Spring Security
  • HTML, CSS and JavaScript
  • SQL
  • Maven

Features

  • Users can register and login to the application.
  • Users can create their custom exercises.
  • Users can log their workout by adding their own custom exercises to a specific date.

Overview

The service uses Controller - Service - Repository pattern:

  • Controllers: Handle the clients' REST API requests and pass them to the Services.
  • Services: Provide a service to the application. Receive input from Controllers, perform validation and business logic, and calling Repositories for data manipulation.
  • Repositories: Responsible to database operations.

The main components of the service are:

  • AppUserService: Provides a service to manipulate AppUsers.
  • UserExerciseService: Provides a service to manipulate UserExercises.
  • ExerciseHistoryService: Provides a service to manipulate ExerciseHistory.
  • LoginService: Provides a service to handle the login process.
  • RegisterService: Provides a service to handle the registering process.

Installation

The project is created with Maven, so you just need to import it to your IDE and build the project to resolve the dependencies.

Alternatively, you can start the project with: mvnw spring-boot:run

Running the application

A default user with some preloaded data is added at the start of the application.

username: user
password: user

Each newly registered user comes with some default exercises which are read from the file: default_exercises.txt

Live Preview

The app is hosted on Heroku: https://spring-workouttracker.herokuapp.com

Data Storage

It uses an in-memory (H2) database to store the data.

To view and query the database you can browse to /console, eg.: http://localhost:8080/console

Login details:

spring.datasource.url=jdbc:h2:mem:db
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=admin
spring.datasource.password=admin
schema.sql

CREATE TABLE appuser (
	id INT NOT NULL AUTO_INCREMENT,
	username VARCHAR(16) NOT NULL,
	password VARCHAR(72) NOT NULL,
	rolename VARCHAR(16) NOT NULL,
	PRIMARY KEY (id)
);

CREATE TABLE user_exercise (
	id INT NOT NULL AUTO_INCREMENT,
	name VARCHAR(32) NOT NULL,
	userId INT NOT NULL,	
	PRIMARY KEY (id),
	FOREIGN KEY (userId) REFERENCES appuser(id)
);

CREATE TABLE exercise_history (
	id INT NOT NULL AUTO_INCREMENT,
	userId INT NOT NULL,
	userExerciseId INT NOT NULL,
	weight INT,
	reps INT NOT NULL,
	exercise_date VARCHAR(16) NOT NULL,
	PRIMARY KEY (id),
	FOREIGN KEY (userId) REFERENCES appuser(id),
	FOREIGN KEY (userExerciseId) REFERENCES user_exercise(id)
);

Endpoints

AppUserController:

  • GET requests to /user/username to retrieve the current user's name.

ExerciseHistoryController:

  • GET requests to /user/history/{date} to retrieve all the ExerciseHistory from a specific date.
  • POST requests to /user/history/add to add a new ExerciseHistory.
  • DELETE requests to /user/history/delete/{id} to delete an ExerciseHistory.

LoginController:

  • POST requests to /login/perform_login to handle the login using the LoginForm model.

RegisterController:

  • POST requests to /register to handle the registering using the RegisterForm model.

UserExerciseController:

  • GET requests to /user/exercises/all to retrieve all the UserExercise.
  • POST requests to /user/exercises/new to add a new exercise.

WebController:

  • Maps the client's GET requests to a html page.

simple-workouttracker's People

Contributors

mepox avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.