Skip to content

A User Registration and Authentication Microservice (Code Generated by Claude Code)

Notifications You must be signed in to change notification settings

rubensgomes/user-ms

Repository files navigation

User Microservice (user-ms)

This project is a cloud native microservice that provides RESTful APIs to manage the registration of users, authentication and password management using JWT tokens. It provides APIs to create the user account, confirm the registration of the user account via email, change the user's account password, authenticate the user (e.g., during sign in), and display the user account information.

AI General Disclaimer

For AI-GENERATED CONTENT, please refer to DISCLAIMER

Branching Strategy

The project is using two branches:

  1. main: which is used as the Trunk-Based Development (TBD) with tagging for new releases.
  2. release: which contains the most recently released code. That is, every time a release is made, this branch is updated.

CICD Automation

The CI/CD build pipeline is using the GitHub Workflow Actions. The built artifact package is deployed to the following GitHub Package:

Tech Stack

  • Java 25 - Programming language
  • Spring Boot 4.x - Application framework
  • Gradle 9.1.x - Build tool
  • MariaDB 11.8.x - Production database
  • H2 Database - Development/testing database
  • Spring Security - Authentication and authorization
  • Spring Data JPA - Database access layer
  • Lombok - Boilerplate code reduction
  • OpenAPI 3.1 - API documentation specification
  • Swagger UI - Interactive API documentation
  • JUnit 5 - Unit testing framework
  • Mockito - Mocking framework for tests
  • JWT - Token-based authentication

Project Structure

com.rubensgomes.userms/
├── controller/     # REST controllers
├── service/        # Business logic
├── repository/     # Data access layer
├── model/          # Entity classes
├── dto/            # Data transfer objects
└── security/       # Security configuration

Database Schema

User Table

Field Type Description
email VARCHAR(100) User email address
password VARCHAR(255) Encrypted password
created_at TIMESTAMP User creation timestamp
password_changed_at TIMESTAMP Last password change timestamp

Quick Start

Prerequisites

  • Java 25
  • Gradle 9.1.x
  • MariaDB 11.8.x (for production)
  • H2 Database (included for development)

Setup

Development Setup (Recommended)

  1. Clone the repository
  2. Start the application with H2 database:
    ./gradlew bootRun --args='--spring.profiles.active=dev'
  3. Access H2 Console: http://localhost:8080/h2-console
    • JDBC URL: jdbc:h2:mem:userms
    • Username: sa
    • Password: (leave empty)

Production Setup

  1. Clone the repository
  2. Install and configure MariaDB 11.8.x
  3. Configure database connection in application.yml
  4. Run database migrations
  5. Start the application: ./gradlew bootRun

Environment Configuration

# application.yml
spring:
  datasource:
    url: jdbc:mariadb://localhost:3306/userms
    username: ${DB_USER:userms}
    password: ${DB_PASSWORD:password}

jwt:
  secret: ${JWT_SECRET:your-secret-key}
  expiration: ${JWT_EXPIRATION:86400000}

API Documentation

Comprehensive API documentation is available in API.md.

Quick Links

Development

Development Commands

# Display Java version installed
./gradlew -q javaToolchains
# Lint and unit tests
./gradlew check -i
# Build the project
./gradlew build
# Only Rubens can release
./gradlew release -i
# Run application with H2 database (development)
./gradlew bootRun --args='--spring.profiles.active=dev'
# Run application with MariaDB (production)
./gradlew bootRun

Stop the running application

Press Ctrl+C (or Cmd+C on Mac) in the terminal where the application is running

Alternative: Kill the application process

ps aux | grep java | grep user-ms # Find the process ID kill # Replace with actual process ID

Running with Docker

docker-compose up -d

Security

  • Passwords are encrypted using bcrypt
  • JWT tokens for stateless authentication
  • CORS configuration for cross-origin requests
  • Input validation and sanitization

Contributing

  1. Follow Java coding standards
  2. Write unit tests for new features
  3. Update API documentation
  4. Ensure all tests pass before submitting

License

Apache License 2.0

About

A User Registration and Authentication Microservice (Code Generated by Claude Code)

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages