A modern REST API for managing gyms, students, and workouts with Spring Boot.
π AboutΒ Β β’Β Β π οΈ TechnologiesΒ Β β’Β Β β¨ FeaturesΒ Β β’Β Β ποΈ Database DiagramΒ Β β’Β Β π Getting StartedΒ Β β’Β Β π API Documentation
SpringFit is a REST API for gym management built with Spring Boot and Spring Security. It allows you to register students, create personalized workouts, manage exercises by muscle group, and record physical assessments. The API features JWT authentication, role-based access control, and interactive documentation powered by Swagger.
- β Java 17 β Main programming language.
- π± Spring Boot β Framework for building modern Java applications.
- π Spring Security β Authentication and access control.
- ποΈ Spring Data JPA β Data access abstraction with Hibernate.
- π¦ Maven β Dependency management and project build automation.
- π¬ MySQL β Relational database used in production.
- π³ Docker β Database containerization for a reproducible environment.
- π SpringDoc OpenAPI β Interactive API documentation via Swagger UI.
- π JJWT β JWT token generation and validation.
- ποΈ Lombok β Boilerplate reduction through code generation.
- β Bean Validation β Input data validation.
- π JWT authentication (register and login)
- π₯ Role-based access control (
ADMINandSTUDENT) - π Student registration and removal
- ποΈ Personalized workout creation per student
- πͺ Exercise management by muscle group
- π Physical assessment registration and retrieval
- π Paginated assessment listing
- π‘οΈ Students can only view their own physical assessment
- π Interactive documentation with Swagger UI
erDiagram
student {
uuid id PK
string name
string email
string password
string phone
date birth_date
int assessment_id FK
datetime created_at
}
physical_assessment {
uuid id PK
float weight
float height
float body_fat_percentage
float bmi
datetime created_at
datetime updated_at
}
workout {
uuid id PK
string name
string objective
string description
uuid student_id FK
datetime created_at
datetime updated_at
}
exercise {
uuid id PK
string name
string muscle_group
string equipment
string description
string difficulty_level
datetime created_at
}
workout_exercise {
int workout_id PK, FK
int exercise_id PK, FK
}
student ||--|| physical_assessment : "has"
student ||--o{ workout : "has"
workout ||--o{ workout_exercise : "contains"
exercise ||--o{ workout_exercise : "used in"
-
Clone the repository:
git clone https://github.com/joschonarth/spring-fit.git
-
Navigate to the project folder:
cd spring-fit -
Set up environment variables in
src/main/resources/application.yml:datasource: username: ${DB_USERNAME:docker} password: ${DB_PASSWORD:docker} jwt: key: ${JWT_KEY:your_secret_key} expiration: ${JWT_EXPIRATION:900000}
π‘ Values after
:are the defaults used when the environment variable is not set.
Start the MySQL container with Docker:
docker compose up -dIf you prefer to use the in-memory H2 database without Docker, comment out the MySQL block and uncomment the H2 block in src/main/resources/application.yml:
# H2 In-Memory Database
datasource:
url: jdbc:h2:mem:testdb
driver-class-name: org.h2.Driver
username: sa
password:
h2:
console:
enabled: true
path: /h2-consoleWith H2 enabled, the console will be available at http://localhost:8080/h2-console.
Start the application with Maven:
./mvnw spring-boot:runThe API will be available at http://localhost:8080.
With the application running, access the interactive documentation generated by Swagger UI:
http://localhost:8080/swagger-ui/index.html
π‘ To test protected endpoints, click Authorize and provide the JWT token obtained at login with the
Bearerprefix.
If you liked this project, leave a β on GitHub β it means a lot!
Made with β₯ by JoΓ£o OtΓ‘vio Schonarth