Skip to content

A modern RESTful API for user management built with Spring Boot and Java 17. Features comprehensive data validation, robust error handling, and clean API design. Includes CRUD operations for user entities with Spring JDBC and H2 database integration. Perfect for learning Spring Boot fundamentals or as a foundation for larger applications.

Notifications You must be signed in to change notification settings

khan-sk-dev/user-management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ User Management System

Java Spring Boot Maven H2 Database

A modern RESTful API for user management built with Spring Boot


πŸ“‹ Table of Contents


✨ Features

Clean RESTful APIs for seamless user management

  • πŸ“‹ List Users: Retrieve all users with a single GET request
  • πŸ‘€ Create Users: Add new users with comprehensive validation
  • πŸ›‘οΈ Data Validation: Robust input validation with detailed error messages
  • πŸ”„ Exception Handling: Graceful error handling with meaningful responses

πŸ› οΈ Technologies

Backend Java Spring Boot
Data Layer Spring JDBC H2
Build Tool Maven

πŸš€ Getting Started

πŸ“‹ Prerequisites

Ensure you have the following installed:

Requirement Version Download
β˜• Java 17+ Oracle JDK / OpenJDK
πŸ”§ Maven 3.6+ Apache Maven
πŸ’» IDE Latest IntelliJ IDEA / VS Code

πŸ“¦ Installation

πŸ”½ Click to expand installation steps

1️⃣ Clone the Repository

git clone https://github.com/khan-sk-dev/user-management.git
cd user-management

2️⃣ Build the Project

mvn clean install

3️⃣ Run the Application

mvn spring-boot:run

4️⃣ Verify Installation

🌐 Open your browser and navigate to: http://localhost:8080


πŸ“‘ API Endpoints

πŸ” Overview

Method Endpoint Description Status
GET /users Retrieve all users βœ… Available
POST /users Create a new user βœ… Available

πŸ“ Create User Example

πŸ“€ POST /users

Request:

POST /users
Content-Type: application/json

{
  "id": 1,
  "name": "John Doe",
  "email": "john.doe@example.com"
}

Response:

HTTP/1.1 201 Created
Content-Type: application/json

{
  "id": 1,
  "name": "John Doe",
  "email": "john.doe@example.com",
  "createdAt": "2025-05-19T10:30:00Z"
}
πŸ“‹ GET /users

Request:

GET /users

Response:

HTTP/1.1 200 OK
Content-Type: application/json

[
  {
    "id": 1,
    "name": "John Doe",
    "email": "john.doe@example.com",
    "createdAt": "2025-05-19T10:30:00Z"
  },
  {
    "id": 2,
    "name": "Jane Smith",
    "email": "jane.smith@example.com",
    "createdAt": "2025-05-19T11:15:00Z"
  }
]

βœ… Validation Rules

Field Rules Example
πŸ†” ID β‰₯ 0 (zero or positive) 1, 42, 0
πŸ‘€ Name 2-255 characters β€’ not blank "John Doe"
πŸ“§ Email valid format β€’ not empty "user@domain.com"

πŸ” Validation Examples

βœ… Valid User Data
{
  "id": 0,
  "name": "Al",
  "email": "al@example.com"
}
❌ Invalid User Data
{
  "id": -1,           // ❌ Negative ID
  "name": "A",        // ❌ Too short (< 2 chars)
  "email": "invalid"  // ❌ Invalid email format
}

πŸ”§ Error Handling

The API provides detailed error responses for better debugging:

❌ Validation Error Response

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
  "timestamp": "2025-05-19T10:30:00Z",
  "status": 400,
  "error": "Bad Request",
  "message": "Validation failed",
  "path": "/users",
  "fieldErrors": {
    "id": "ID must be zero or positive",
    "name": "Name must be between 2 and 255 characters",
    "email": "Email must be a valid email address"
  }
}

🀝 Contributing

We welcome contributions! πŸŽ‰

GitHub Issues GitHub Forks GitHub Stars

πŸ“ How to Contribute

  1. 🍴 Fork the repository
  2. 🌿 Create a feature branch: git checkout -b feature/amazing-feature
  3. πŸ’Ύ Commit your changes: git commit -m 'Add some amazing feature'
  4. πŸ“€ Push to the branch: git push origin feature/amazing-feature
  5. πŸ”„ Open a Pull Request

⭐ Found this project helpful? Give it a star!

Built with ❀️ using Spring Boot

About

A modern RESTful API for user management built with Spring Boot and Java 17. Features comprehensive data validation, robust error handling, and clean API design. Includes CRUD operations for user entities with Spring JDBC and H2 database integration. Perfect for learning Spring Boot fundamentals or as a foundation for larger applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages