- β¨ Features
- π οΈ Technologies
- π Getting Started
- π‘ API Endpoints
- β Validation Rules
- π§ Error Handling
- π€ Contributing
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
| Backend |
|
| Data Layer |
|
| Build Tool |
|
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 |
π½ Click to expand installation steps
git clone https://github.com/khan-sk-dev/user-management.git
cd user-managementmvn clean installmvn spring-boot:runπ Open your browser and navigate to: http://localhost:8080
| Method | Endpoint | Description | Status |
|---|---|---|---|
GET |
/users |
Retrieve all users | β Available |
POST |
/users |
Create a new user | β Available |
π€ 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 /usersResponse:
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"
}
]| 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" |
β 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
}The API provides detailed error responses for better debugging:
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"
}
}- π΄ Fork the repository
- πΏ Create a feature branch:
git checkout -b feature/amazing-feature - πΎ Commit your changes:
git commit -m 'Add some amazing feature' - π€ Push to the branch:
git push origin feature/amazing-feature - π Open a Pull Request
β Found this project helpful? Give it a star!
Built with β€οΈ using Spring Boot