https://github.com/hyuseinleshov/power-log
A strength training application developed using Spring MVC. PowerLog helps users track their workouts, monitor progress, and manage their training schedules.
https://github.com/hyuseinleshov/power-log
ajax bootstrap fitness-tracking hibernate i18n java javascript jpa jquery jwt lombok mapstruct mysql restful-api scheduling spring-boot spring-mvc spring-security thymeleaf web-application
Last synced: 3 months ago
JSON representation
A strength training application developed using Spring MVC. PowerLog helps users track their workouts, monitor progress, and manage their training schedules.
- Host: GitHub
- URL: https://github.com/hyuseinleshov/power-log
- Owner: hyuseinleshov
- License: mit
- Created: 2024-06-10T13:34:55.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-07T20:39:00.000Z (almost 2 years ago)
- Last Synced: 2025-08-19T08:46:46.586Z (10 months ago)
- Topics: ajax, bootstrap, fitness-tracking, hibernate, i18n, java, javascript, jpa, jquery, jwt, lombok, mapstruct, mysql, restful-api, scheduling, spring-boot, spring-mvc, spring-security, thymeleaf, web-application
- Language: Java
- Homepage:
- Size: 929 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PowerLog
PowerLog is a Spring MVC web application designed to help strength training enthusiasts track their workouts, monitor progress, and manage their training schedules.
## Table of Contents
- [Introduction](#introduction)
- [Features](#features)
- [Technologies Used](#technologies-used)
- [Installation](#installation)
- [API Endpoints](#api-endpoints)
- [Database Schema](#database-schema)
- [Security](#security)
- [Validation and Error Handling](#validation-and-error-handling)
- [Internationalization (i18n)](#internationalization-i18n)
- [Contact Management](#contact-management)
- [Events and Scheduling](#events-and-scheduling)
- [Apache Kafka](#apache-kafka)
- [Mapping](#mapping)
- [Testing](#testing)
- [Front-end Design](#front-end-design)
- [Usage](#usage)
- [Contact](#contact)
## Introduction
PowerLog was developed as part of the [Spring Advanced Course @ SoftUni](https://softuni.bg/trainings/4532/spring-advanced-june-2024). It provide a comprehensive strength training tracking system.
## Features
- **Home, About, and Contact pages:** Accessible to unauthenticated users.
- **Authentication:** Login and register options.
- **Workout Management:**
- Create, update, and delete workouts.
- Use routines as templates for new workouts.
- Create custom exercises.
- View exercise progress with graphs using Chart.js.
- **Tools:**
- Log daily weight and view progress graphs.
- Store and view progress photos.
- **Account Management:**
- View and edit profile information (email, password).
- **Admin Dashboard:**
- View all users.
- View all contacts.
- Access to app interface settings and usage statistics.
- Role-based access control with user and admin roles.
## Technologies Used
- **Backend:** Spring Framework, Spring Boot
- **Frontend:** JavaScript, jQuery, AJAX, HTML, Bootstrap, Thymeleaf, Thymeleaf Layout Dialect, Chart.js, DataTables
- **Database:** MySQL, Hibernate (JPA provider)
- **Messaging:** Apache Kafka
- **Storage Cloud:** Cloudinary
- **Security:** Spring Security, JWT authentication with refresh tokens
- **Other Libraries:** MapStruct, Lombok
## Installation
### Prerequisites
- JDK 17+
- Gradle
- MySQL
### Steps
1. Clone the repository:
```bash
git clone https://github.com/hyuseinlesho/power-log.git
2. Set up environment variables.
```bash
DB_USERNAME=
DB_PASSWORD=
SECRET_KEY=
ACCESS_TOKEN_EXPIRATION=
REFRESH_TOKEN_EXPIRATION=
REMEMBER_ME_REFRESH_TOKEN_EXPIRATION=
ACCESS_TOKEN_COOKIE_MAX_AGE=
REFRESH_TOKEN_COOKIE_MAX_AGE=
REMEMBER_ME_REFRESH_TOKEN_COOKIE_MAX_AGE=
MAIL_USERNAME=
MAIL_PASSWORD=
ADMIN_EMAIL=
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=
3. Set up used Cloudinary for storing progress pictures, install and run Apache Kafka server for messages from ContactService or uncomment this property in `application.yaml`:

4. Run the application and enjoy it!
## API Endpoints
### Authentication Controller
- `GET /auth/login`
- `POST /auth/login`
- `GET /auth/register`
- `POST /auth/register`
- `POST /auth/logout`
### Contact Controller
- `GET /contact`
- `POST /contact`
### Exercise Controller
- `GET /exercises`
- `GET /exercises/graph`
### Home Controller
- `GET /`
- `GET /about`
- `GET /home`
### Progress Photo Controller
- `GET /progress-photos`
- `GET /progress-photos/upload`
### Routine Controller
- `GET /workouts/routines`
- `GET /workouts/routines/create`
- `POST /workouts/routines/create`
- `POST /workouts/routines/{id}/delete`
- `GET /workouts/routines/{id}/details`
- `GET /workouts/routines/{id}/edit`
- `POST /workouts/routines/{id}/edit`
### User Controller
- `GET /users/profile`
### Weight Log Controller
- `GET /weight-logs`
- `POST /weight-logs/graph`
### Workout Controller
- `GET /workouts/create`
- `POST /workouts/create`
- `GET /workouts/history`
- `GET /workouts/history/search`
- `POST /workouts/{id}/delete`
- `GET /workouts/{id}/details`
- `GET /workouts/{id}/edit`
- `POST /workouts/{id}/edit`
#### Other is used for AJAX requests
### Exercise Log REST Controller
- `GET /api/exercise-logs`
### Exercise REST Controller
- `POST /api/exercies/create`
- `PUT /api/exercies/{id}`
- `DELETE /api/exercies/{id}`
### User Profile REST Controller
- `POST /users/profile/change-email`
- `POST /users/profile/change-password`
### Weight Log REST Controller
- `GET /api/weight-logs`
- `POST /api/weight-logs/create`
- `PUT /api/weight-logs/{id}`
- `DELETE /api/weight-logs/{id}`
## Database Schema
- The database schema for the PowerLog application is designed to support the functionalities required for tracking strength training workouts, user authentication, and role-based access control. Below is a detailed description of each table and its relationships.
### ER Diagram

- This schema ensures that each user can have multiple roles, workouts, exercises, routines, weight logs, and progress photos, providing a comprehensive structure for the application's functionality.
## Security
- Custom JWT authentication with refresh tokens based on [this tutorial](https://medium.com/@tericcabrel/implement-jwt-authentication-in-a-spring-boot-3-application-5839e4fd8fac).
- Role-based authentication with user and admin roles.
- Security features including CSRF protection and password hashing.
## Validation and Error Handling
- Client-side and server-side validation.
### Examples of validation messages.



## Internationalization (i18n)
- Supported languages: English, Bulgarian, and German.



## Contact Management
Utilizes a separate REST service, [ContactService](https://github.com/hyuseinlesho/contact-service), for saving new contacts and fetching contacts based on date.
## Events and Scheduling
- Event which send welcome email after a new user registers.

- Event which send notification email after users create now contact.
- Consume new messages from ContactService producer through Kafka

- Scheduler to send a weekly contact summary email to the admin with new contacts created.

## Apache Kafka
### Setup and Configuration
- Ensure Apache Kafka is installed and running to test it locally.
### Contact Consumer
- Consumes messages from the Kafka topic `contact-topic` and ContactService as producer.
- Parses the consumed message and processes the contact data.
- Configured consumer settings, including bootstrap servers, key and value deserializers, and group ID in `application.yaml` file.
### Process Contact
- Processes the contact data after consumption from Kafka.
- Sends notification email to the admin when a new contact is created.
### Note
- Ensure that Kafka server is installed and running when testing the integration.
## Mapping
- Use MapStruct for DTO conversions.
## Testing
- Unit tests for service layer.
- Integration tests for REST controllers.
- Achieved ~60% line coverage.
## Front-end Design
The PowerLog application uses modern web technologies to ensure a responsive and user-friendly interface. Key technologies include:
### Thymeleaf Templates with Layout Dialect
- **Thymeleaf**: Used as the template engine to generate dynamic HTML content on the server side.
- **Layout Dialect**: Provides tools to create reusable layouts, components, and fragments, ensuring consistency across the application.
- **Security Integration**: Manages user authentication and authorization within templates using Spring Security.
### Bootstrap for Styling
- **Bootstrap 5**: Utilized for responsive CSS styling and layout design, offering a library of pre-designed components like forms, buttons, and navigation bars.
- **Modals**: Used for creating dialog boxes and forms for user interactions without navigating away from the current page.
### JavaScript and AJAX for Interactivity
- **JavaScript**: Enhances user interactions and provides dynamic functionality on the client side, including form validation and event handling.
- **AJAX**: Enables asynchronous communication with the server, allowing data to be sent and received without reloading the page, thus improving user experience.
### Chart.js for Data Visualization
- **Chart.js**: Utilized for creating responsive and interactive charts, helping to visualize workout progress and other data in a clear and engaging manner.
### DataTables for Tabular Data
- **DataTables**: Provides advanced interaction controls for HTML tables, such as sorting, filtering, and pagination, making it easier to manage and analyze tabular data.
## Usage
Here is a demonstration video of PowerLog application:
- [PowerLog demo](https://youtu.be/bhbnsqqFx3Y)
### * Note that this video is from 2024/07/28
## Contact
- Author: Hyusein Lesho
- [Email](mailto:hl.dev.acc@gmail.com)