Skip to content

codewithmahad/fitness-tracker-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Fitness Tracker Banner

πŸ‹οΈ Enterprise-Grade Fitness Tracking Platform

A production-ready, stateless REST API engineered with senior-level backend architecture patterns. Features JWT authentication, role-based access control, dynamic workout tracking, and AI-powered fitness recommendations with strict data integrity and zero-tolerance security standards.

Java 21 Spring Boot Spring Security JWT MySQL Flyway MapStruct

License: MIT Build Status Code Quality


πŸ“‹ Table of Contents


⚑ Core Engineering Features

This is not a basic CRUD application. It demonstrates senior-level backend engineering with enterprise-grade architectural patterns and best practices:

πŸ” Security & Authentication

  • Stateless JWT Authentication: Custom security filter chains using io.jsonwebtoken for horizontally scalable, session-less authentication
  • Role-Based Access Control (RBAC): Fine-grained permission management with USER and ADMIN roles
  • BCrypt Password Hashing: Industry-standard one-way encryption with 10 rounds of salting
  • CORS Configuration: Production-ready cross-origin request handling
  • Global Exception Handling: Centralized @RestControllerAdvice preventing sensitive error information leakage

πŸ—„οΈ Database & Persistence

  • Strict Schema Control: Hibernate DDL auto-generation disabled (ddl-auto=validate) for production safety
  • Flyway Migrations: Version-controlled database evolution with rollback capabilities
  • Optimized Indexing: Composite indexes on (user_id, activity_id) and unique constraints on email fields
  • Database-Level Constraints: CHECK constraints ensuring data integrity at the storage layer
  • Connection Pooling: HikariCP for high-performance database connection management

🎯 Architecture & Design Patterns

  • N-Tier Architecture: Strict separation of concerns (Controller β†’ Service β†’ Repository β†’ Entity)
  • DTO Pattern with MapStruct: Compile-time code generation eliminating reflection overhead and preventing data leakage
  • Dependency Injection: Constructor-based DI for immutability and testability
  • Repository Pattern: Spring Data JPA interfaces with custom query methods
  • Transaction Management: @Transactional boundaries ensuring ACID properties

πŸš€ Advanced Features

  • JSON Column Support: @JdbcTypeCode(SqlTypes.JSON) for flexible, schema-less workout metrics storage
  • Pagination & Sorting: Pageable support for efficient large dataset handling
  • Bean Validation: JSR-303/380 annotations for declarative input validation
  • OpenAPI 3.0 Documentation: Auto-generated interactive API documentation via Swagger UI
  • Custom Exception Hierarchy: Business-specific exceptions (ResourceNotFoundException, ResourceAlreadyExistsException, etc.)

πŸ› οΈ Technology Stack

Core Framework

Technology Version Purpose
Java 21 (LTS) Primary programming language with virtual threads support
Spring Boot 3.4.x Application framework and dependency injection container
Spring Security 6.x Authentication, authorization, and security filters
Spring Data JPA 3.x Data access layer abstraction
Hibernate 6.x ORM and entity lifecycle management

Data & Persistence

Technology Version Purpose
MySQL 8.x Primary relational database
Flyway 10.x Database version control and migrations
HikariCP 5.x JDBC connection pooling

Security & Authentication

Technology Version Purpose
jjwt-api 0.12.x JWT token generation and validation
BCrypt Built-in Password hashing algorithm

Code Generation & Mapping

Technology Version Purpose
MapStruct 1.6.x Compile-time DTO-Entity mapping
Lombok 1.18.x Boilerplate code reduction

Documentation & Validation

Technology Version Purpose
SpringDoc OpenAPI 2.x API documentation and Swagger UI
Jakarta Validation 3.x Bean validation (JSR-380)

Build & Dependencies

Technology Version Purpose
Maven 3.9.x Dependency management and build automation
Maven Compiler Plugin 3.13.x Java compilation with annotation processing

πŸ—οΈ System Architecture

The application follows a strict N-tier architecture ensuring clean separation of concerns, high testability, and maintainability.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Client Layer                              β”‚
β”‚              (Web, Mobile, Third-party APIs)                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚ HTTP/HTTPS Requests
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Security Filter Chain                          β”‚
β”‚        (JWT Validation, CORS, CSRF Protection)                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Controller Layer                             β”‚
β”‚    β€’ HTTP Request Mapping (@RestController)                      β”‚
β”‚    β€’ Input Validation (@Valid, @Validated)                       β”‚
β”‚    β€’ Response Formatting                                         β”‚
β”‚    β€’ Exception Handling Trigger                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚ DTOs
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      Service Layer                               β”‚
β”‚    β€’ Business Logic Implementation                               β”‚
β”‚    β€’ Transaction Management (@Transactional)                     β”‚
β”‚    β€’ Entity ↔ DTO Mapping (MapStruct)                           β”‚
β”‚    β€’ Complex Validations                                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚ Entities
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Repository Layer                              β”‚
β”‚    β€’ Data Access Abstraction (Spring Data JPA)                   β”‚
β”‚    β€’ Custom Queries (JPQL, Native SQL)                           β”‚
β”‚    β€’ Pagination & Sorting                                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚ SQL Queries
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      MySQL Database                              β”‚
β”‚    β€’ Relational Data Storage                                     β”‚
β”‚    β€’ Flyway Schema Migrations                                    β”‚
β”‚    β€’ Constraints, Indexes, Triggers                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Layer Responsibilities

Layer Responsibilities Technologies
Controller Request routing, validation, response serialization Spring Web, Jackson, Jakarta Validation
Service Business logic, transactions, orchestration Spring Core, MapStruct
Repository Database queries, entity management Spring Data JPA, Hibernate
Entity Domain model, database mapping JPA, Hibernate

πŸ—ΊοΈ Entity Relationship Diagram

The database schema is normalized to 3NF to enforce referential integrity, minimize data redundancy, and optimize query performance.

erDiagram
    USERS ||--o{ ACTIVITIES : "logs (ON DELETE CASCADE)"
    USERS ||--o{ RECOMMENDATIONS : "receives"
    ACTIVITIES ||--o{ RECOMMENDATIONS : "generates"

    USERS {
        BIGINT id PK
        VARCHAR(254) email UK "RFC 5321 Compliant"
        CHAR(60) password "BCrypt Hash"
        VARCHAR(100) first_name
        VARCHAR(100) last_name
        ENUM role "USER, ADMIN"
        TIMESTAMP created_at
        TIMESTAMP updated_at
    }

    ACTIVITIES {
        BIGINT id PK
        BIGINT user_id FK
        ENUM type "RUNNING, CYCLING, WEIGHTLIFTING, SWIMMING..."
        INT duration "CHECK > 0 (minutes)"
        JSON additional_metrics "Flexible Schema"
        DATETIME start_time
        TIMESTAMP created_at
    }

    RECOMMENDATIONS {
        BIGINT id PK
        BIGINT user_id FK
        BIGINT activity_id FK
        JSON improvements "Performance enhancement suggestions"
        JSON safety "Injury prevention guidance"
        TIMESTAMP created_at
    }
Loading

Key Database Features

  • Composite Unique Constraint: (user_id, activity_id) on recommendations table prevents duplicate AI-generated insights
  • Foreign Key Cascades: ON DELETE CASCADE for activities ensures orphaned data is automatically cleaned
  • Check Constraints: Database-level validation (e.g., duration > 0) as a second line of defense
  • Optimized Data Types: CHAR(60) for BCrypt hashes, VARCHAR(254) for RFC 5321-compliant emails

πŸ“‘ API Endpoints

Fully documented via OpenAPI 3.0. Once running, visit http://localhost:8080/swagger-ui.html for the interactive Swagger UI.

Authentication Endpoints

Method Endpoint Description Request Body Response Access
POST /api/auth/register Register new user account RegisterUserDto UserResponseDto + JWT Public
POST /api/auth/login Authenticate and receive JWT token LoginUserDto LoginResponse (JWT) Public

Example Registration Request:

{
  "email": "[email protected]",
  "password": "SecureP@ssw0rd",
  "firstName": "John",
  "lastName": "Doe"
}

Example Login Response:

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "expiresIn": 3600000
}

User Management Endpoints

Method Endpoint Description Parameters Response Access
GET /api/users/me Get current authenticated user - UserResponseDto USER, ADMIN
GET /api/users/{id} Get user by ID id (path) UserResponseDto ADMIN
GET /api/users List all users (paginated) page, size Page<UserResponseDto> ADMIN
PUT /api/users/{id} Update user details id (path), UpdateUserDto UserResponseDto USER, ADMIN
DELETE /api/users/{id} Delete user account id (path) 204 No Content ADMIN

Activity Tracking Endpoints

Method Endpoint Description Parameters Response Access
POST /api/activities Log new fitness activity ActivityDto ActivityResponseDto USER, ADMIN
GET /api/activities/user/{userId} Get user's activity history userId, page, size Page<ActivityResponseDto> USER, ADMIN
GET /api/activities/{id} Get activity by ID id (path) ActivityResponseDto USER, ADMIN
PUT /api/activities/{id} Update activity details id (path), ActivityDto ActivityResponseDto USER, ADMIN
DELETE /api/activities/{id} Delete activity log id (path) 204 No Content USER, ADMIN

Example Activity Request:

{
  "type": "RUNNING",
  "duration": 45,
  "startTime": "2024-03-15T06:30:00Z",
  "additionalMetrics": {
    "distance": 8.5,
    "averagePace": "5:17",
    "heartRate": 165,
    "calories": 520
  }
}

Recommendation Endpoints

Method Endpoint Description Parameters Response Access
POST /api/recommendations Generate AI-powered fitness recommendations RecommendationDto RecommendationResponseDto ADMIN
GET /api/recommendations/activity/{activityId} Get recommendations for specific activity activityId (path) RecommendationResponseDto USER, ADMIN
GET /api/recommendations/user/{userId} Get all user recommendations userId (path) List<RecommendationResponseDto> USER, ADMIN

πŸ”’ Security Architecture

JWT Token Flow

1. User Registration/Login
   β”œβ”€β†’ Password hashed with BCrypt (10 rounds)
   β”œβ”€β†’ JWT generated with HS256 algorithm
   └─→ Token contains: { userId, email, role, exp }

2. Authenticated Request
   β”œβ”€β†’ Client sends: Authorization: Bearer <token>
   β”œβ”€β†’ JwtAuthenticationFilter validates token
   β”œβ”€β†’ SecurityContext populated with user details
   └─→ @PreAuthorize checks role permissions

3. Token Expiration
   β”œβ”€β†’ Default expiry: 24 hours
   β”œβ”€β†’ Refresh mechanism: Re-authenticate
   └─→ Invalid tokens return 401 Unauthorized

Security Features

Feature Implementation Benefits
Password Hashing BCrypt with strength 10 Resistant to rainbow table attacks
JWT Signing HMAC-SHA256 Tamper-proof tokens
CORS Configurable origins Prevents unauthorized cross-origin requests
CSRF Protection Stateless (disabled for APIs) JWT-based authentication doesn't require CSRF tokens
SQL Injection Parameterized queries (JPA) Prevents malicious SQL execution
Role-Based Access @PreAuthorize annotations Fine-grained endpoint protection

πŸš€ Quick Start Guide

Prerequisites

Requirement Version Download
JDK 21+ Oracle JDK or OpenJDK
Maven 3.9+ Apache Maven
MySQL 8.0+ MySQL Community Server
Git Latest Git Downloads

Installation Steps

1️⃣ Clone Repository

git clone https://github.com/shaikhmahad/fitness-tracker-backend.git
cd fitness-tracker-backend

2️⃣ Database Configuration

Create the database:

CREATE DATABASE fitness_tracker CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Create application-local.yml in src/main/resources/:

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/fitness_tracker?useSSL=false&serverTimezone=UTC
    username: your_mysql_username
    password: your_mysql_password
    driver-class-name: com.mysql.cj.jdbc.Driver

  jpa:
    hibernate:
      ddl-auto: validate  # NEVER use 'update' or 'create-drop' in production
    show-sql: true
    properties:
      hibernate:
        format_sql: true
        dialect: org.hibernate.dialect.MySQL8Dialect

  flyway:
    enabled: true
    baseline-on-migrate: true

security:
  jwt:
    secret-key: your-256-bit-secret-key-change-this-in-production
    expiration: 86400000  # 24 hours in milliseconds

Security Warning: Never commit application-local.yml to version control. Add it to .gitignore.

3️⃣ Environment Variables (Recommended for Production)

export DB_URL="jdbc:mysql://localhost:3306/fitness_tracker"
export DB_USERNAME="your_username"
export DB_PASSWORD="your_password"
export JWT_SECRET="your-secure-secret-key-min-256-bits"
export JWT_EXPIRATION="86400000"

4️⃣ Build Project

MapStruct requires compilation to generate mapper implementations:

mvn clean install

5️⃣ Run Application

mvn spring-boot:run

Or run the JAR directly:

java -jar target/fitness-tracker-backend-1.0.0.jar

6️⃣ Verify Installation

Once started, visit:

You should see:

{
  "status": "UP"
}

βš™οΈ Configuration

Application Profiles

Profile Purpose Activation
default Development Active by default
prod Production --spring.profiles.active=prod
test Integration Testing Automatically activated during tests

Key Configuration Properties

# Server Configuration
server:
  port: 8080
  servlet:
    context-path: /

# Security
security:
  jwt:
    secret-key: ${JWT_SECRET:default-secret-for-dev-only}
    expiration: ${JWT_EXPIRATION:86400000}

# Database Connection Pooling (HikariCP)
spring:
  datasource:
    hikari:
      maximum-pool-size: 10
      minimum-idle: 5
      connection-timeout: 30000
      idle-timeout: 600000
      max-lifetime: 1800000

# Flyway Migration
spring:
  flyway:
    enabled: true
    baseline-on-migrate: true
    validate-on-migrate: true

# Logging
logging:
  level:
    root: INFO
    dev.shaikhmahad.fitness: DEBUG
    org.hibernate.SQL: DEBUG

πŸ—ƒοΈ Database Migrations

Flyway manages all schema changes with version-controlled SQL scripts located in src/main/resources/db/migration/.

Migration Files

File Description Execution Order
V1__init.sql Initial schema creation (users, activities, recommendations) 1
V2__add_missing_recommendation_fields.sql Adds JSON columns for improvements and safety tips 2

Running Migrations Manually

# Validate migrations
mvn flyway:validate

# View migration status
mvn flyway:info

# Execute pending migrations
mvn flyway:migrate

# Rollback (requires Flyway Teams edition)
mvn flyway:undo

Migration Best Practices

βœ… DO:

  • Use descriptive filenames: V{version}__{description}.sql
  • Test migrations on a copy of production data
  • Keep migrations idempotent where possible
  • Version control all migration scripts

❌ DON'T:

  • Modify existing migration files after deployment
  • Use Hibernate's ddl-auto=update in production
  • Store sensitive data in migration scripts

πŸ§ͺ Testing

Running Tests

# Run all tests
mvn test

# Run with coverage report
mvn test jacoco:report

# Run specific test class
mvn test -Dtest=UserServiceImplTest

# Run integration tests only
mvn verify -P integration-tests

Test Structure

src/test/java/dev/shaikhmahad/fitness/
β”œβ”€β”€ controllers/    # Controller layer tests (MockMvc)
β”œβ”€β”€ services/       # Service layer tests (Mockito)
β”œβ”€β”€ repositories/   # Repository tests (DataJpaTest)
└── integration/    # End-to-end integration tests

⚑ Performance Optimization

Database Optimization

  • Composite Indexes: (user_id, activity_id) for recommendation lookups
  • Connection Pooling: HikariCP with optimized pool sizes
  • Query Optimization: N+1 query prevention with @EntityGraph
  • Pagination: All list endpoints return Page<T> to limit result sets

Application Performance

  • DTO Mapping: Compile-time MapStruct (zero reflection overhead)
  • Lazy Loading: Strategic use of FetchType.LAZY for collections
  • Caching: Spring Cache abstraction ready for Redis integration
  • Async Processing: @Async support for non-blocking operations

πŸ“ Project Structure

fitness-tracker-backend/
β”‚
β”œβ”€β”€ src/main/java/dev/shaikhmahad/fitness/
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ ApplicationConfiguration.java      # Bean definitions
β”‚   β”‚   β”œβ”€β”€ JwtAuthenticationFilter.java       # JWT validation filter
β”‚   β”‚   └── SecurityConfiguration.java         # Security chains
β”‚   β”‚
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ AuthenticationController.java      # /api/auth/*
β”‚   β”‚   β”œβ”€β”€ UserController.java                # /api/users/*
β”‚   β”‚   β”œβ”€β”€ ActivityController.java            # /api/activities/*
β”‚   β”‚   └── RecommendationController.java      # /api/recommendations/*
β”‚   β”‚
β”‚   β”œβ”€β”€ dto/
β”‚   β”‚   β”œβ”€β”€ request/                           # Inbound DTOs
β”‚   β”‚   β”‚   β”œβ”€β”€ RegisterUserDto.java
β”‚   β”‚   β”‚   β”œβ”€β”€ LoginUserDto.java
β”‚   β”‚   β”‚   └── ActivityDto.java
β”‚   β”‚   └── response/                          # Outbound DTOs
β”‚   β”‚       β”œβ”€β”€ UserResponseDto.java
β”‚   β”‚       └── ActivityResponseDto.java
β”‚   β”‚
β”‚   β”œβ”€β”€ entities/
β”‚   β”‚   β”œβ”€β”€ User.java                          # JPA entity
β”‚   β”‚   β”œβ”€β”€ Activity.java
β”‚   β”‚   └── Recommendation.java
β”‚   β”‚
β”‚   β”œβ”€β”€ enums/
β”‚   β”‚   β”œβ”€β”€ UserRole.java                      # USER, ADMIN
β”‚   β”‚   └── ActivityType.java                  # RUNNING, CYCLING, etc.
β”‚   β”‚
β”‚   β”œβ”€β”€ exceptions/
β”‚   β”‚   β”œβ”€β”€ GlobalExceptionHandler.java        # @RestControllerAdvice
β”‚   β”‚   β”œβ”€β”€ ResourceNotFoundException.java
β”‚   β”‚   └── ResourceAlreadyExistsException.java
β”‚   β”‚
β”‚   β”œβ”€β”€ mappers/
β”‚   β”‚   β”œβ”€β”€ UserMapper.java                    # MapStruct interface
β”‚   β”‚   └── ActivityMapper.java
β”‚   β”‚
β”‚   β”œβ”€β”€ repositories/
β”‚   β”‚   β”œβ”€β”€ UserRepository.java                # Spring Data JPA
β”‚   β”‚   β”œβ”€β”€ ActivityRepository.java
β”‚   β”‚   └── RecommendationRepository.java
β”‚   β”‚
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ AuthenticationService.java
β”‚   β”‚   β”œβ”€β”€ JwtService.java
β”‚   β”‚   β”œβ”€β”€ UserService.java
β”‚   β”‚   └── impl/                              # Service implementations
β”‚   β”‚       β”œβ”€β”€ UserServiceImpl.java
β”‚   β”‚       └── ActivityServiceImpl.java
β”‚   β”‚
β”‚   └── FitnessTrackerApplication.java         # Spring Boot entry point
β”‚
β”œβ”€β”€ src/main/resources/
β”‚   β”œβ”€β”€ db/migration/                          # Flyway SQL scripts
β”‚   β”‚   β”œβ”€β”€ V1__init.sql
β”‚   β”‚   └── V2__add_missing_recommendation_fields.sql
β”‚   β”œβ”€β”€ application.yml                        # Main configuration
β”‚   └── application-prod.yml                   # Production overrides
β”‚
β”œβ”€β”€ src/test/java/                             # Unit & integration tests
β”œβ”€β”€ pom.xml                                    # Maven dependencies
└── README.md                                  # This file

🀝 Contributing

Contributions are welcome! Please follow these guidelines:

How to Contribute

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/amazing-feature
  3. Make your changes following the coding standards
  4. Write tests for new functionality
  5. Commit with conventional commits
    git commit -m "feat: add amazing feature"
  6. Push to your fork
    git push origin feature/amazing-feature
  7. Open a Pull Request

Coding Standards

  • Follow Java naming conventions
  • Use meaningful variable/method names
  • Write JavaDoc for public methods
  • Maintain test coverage above 80%
  • Use Lombok to reduce boilerplate
  • Follow SOLID principles

Commit Message Convention

feat: Add new feature
fix: Bug fix
docs: Documentation changes
style: Code formatting
refactor: Code restructuring
test: Add tests
chore: Build/config changes

πŸ“„ License

This project is licensed under the MIT License.

MIT License

Copyright (c) 2024 Shaikh Mahad

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

πŸ™ Acknowledgments

  • Spring Team - For the excellent Spring Framework and Spring Boot
  • Hibernate Team - For robust ORM capabilities
  • MapStruct Contributors - For compile-time DTO mapping
  • Flyway - For database version control
  • JWT.io - For JWT implementation resources

πŸ“ž Support & Contact

πŸ‘¨β€πŸ’» Built & Maintained By

Shaikh Mahad Backend Engineer | Java & Spring Boot Specialist

Portfolio LinkedIn GitHub

πŸ’¬ Get In Touch

Have questions or suggestions? Feel free to reach out!

πŸ“§ Email: [email protected] πŸ’Ό LinkedIn: linkedin.com/in/codewithmahad 🌐 Portfolio: shaikhmahad.vercel.app


⭐ Star This Repository

If you found this project helpful or learned something new, please consider giving it a ⭐!

GitHub stars GitHub forks


About

Layered Java Spring Boot backend for a fitness tracking platform featuring REST APIs, JWT security, and database persistence.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages