Skip to content

joschonarth/spring-fit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

65 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌱 SpringFit

A modern REST API for managing gyms, students, and workouts with Spring Boot.

last-commit repo-top-language repo-language-count

πŸ“ƒ AboutΒ Β β€’Β Β  πŸ› οΈ TechnologiesΒ Β β€’Β Β  ✨ FeaturesΒ Β β€’Β Β  πŸ—„οΈ Database DiagramΒ Β β€’Β Β  πŸš€ Getting StartedΒ Β β€’Β Β  πŸ“– API Documentation


πŸ“ƒ About

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.


πŸ› οΈ Technologies

  • β˜• 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.

✨ Features

  • πŸ” JWT authentication (register and login)
  • πŸ‘₯ Role-based access control (ADMIN and STUDENT)
  • πŸŽ“ 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

πŸ—„οΈ Database Diagram

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"
Loading

πŸš€ Getting Started

πŸ“‹ Prerequisites

πŸ”§ Installation

  1. Clone the repository:

    git clone https://github.com/joschonarth/spring-fit.git
  2. Navigate to the project folder:

    cd spring-fit
  3. 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.

🐳 Database

Start the MySQL container with Docker:

docker compose up -d

πŸ—„οΈ Alternative Database (H2)

If 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-console

With H2 enabled, the console will be available at http://localhost:8080/h2-console.

▢️ Running

Start the application with Maven:

./mvnw spring-boot:run

The API will be available at http://localhost:8080.


πŸ“– API Documentation

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 Bearer prefix.


⭐ Support this Project

If you liked this project, leave a ⭐ on GitHub β€” it means a lot!


Made with β™₯ by JoΓ£o OtΓ‘vio Schonarth

GitHub LinkedIn Gmail

About

🌱 RESTful API for gym management, providing student registration, personalized workouts, exercise tracking, and physical assessments, built with Java, Spring Boot, and Spring Security.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages