A Spring Boot REST API that implements CRUD operations for user management.
By José Agustín Moreno Larios
- Java 21
- Maven 3.x
mvn spring-boot:runThe application will start on http://localhost:8080.
- Swagger UI: http://localhost:8080/swagger-ui.html
- OpenAPI JSON: http://localhost:8080/v3/api-docs
- Type: H2 in-memory database
- Console: http://localhost:8080/h2-console
- JDBC URL:
jdbc:h2:mem:testdb
| Method | Endpoint | Description |
|---|---|---|
| GET | /users?sortedBy={column} |
Get users sorted by a specific column |
| GET | /users?filter={params} |
Filter users by parameters |
| POST | /users |
Create a new user |
| PATCH | /users/{id} |
Update an existing user |
| DELETE | /users/{id} |
Delete a user by ID |
| POST | /login |
Authenticate a user |
sortBy endpoint format: GET /users?sortBy{column}
Valid Columns:
| Column | Description |
|---|---|
email |
Filter by email address |
id |
Filter by user UUID |
name |
Filter by user name |
phone |
Filter by phone number |
tax_id |
Filter by tax ID |
created_at |
Filter by creation timestamp |
Filter endpoint format: GET /users?filter={column}+{operation}+{query}
Valid Columns: Same as above.
Valid Operations:
| Operation | Code | Description |
|---|---|---|
| Contains | co |
Matches values containing the query |
| Equals | eq |
Matches exact values |
| Starts With | sw |
Matches values starting with query |
| Ends With | ew |
Matches values ending with query |
Filter Examples:
| Request | Description |
|---|---|
GET /users?filter=name+co+User |
Find users with "User" in their name |
GET /users?filter=email+eq+test@someplace.com |
Find user with exact email |
GET /users?filter=tax_id+sw+AAR |
Find users with tax_id starting with "AAR" |
GET /users?filter=phone+ew+555 |
Find users with phone ending in "555" |
| Field | Type | Description |
|---|---|---|
id |
UUID | Unique identifier |
email |
String | User email (required, valid format) |
name |
String | User name (required) |
phone |
String | Phone number (required, min 10 digits) |
password |
String | User password (required) |
tax_id |
String | Tax ID (required, RFC format: 12 chars for companies, 13 chars for individuals) |
created_at |
DateTime | Creation timestamp (Madagascar timezone: Africa/Nairobi) |
addresses |
List | List of user addresses |
- Email: Must be a valid email format
- Phone: Must contain at least 10 digits (country code optional)
- Tax ID: RFC format
- 12 characters for companies:
AAAmmddyyXXN - 13 characters for physical persons:
AAAmmddyyXXN
- 12 characters for companies:
The following users are preloaded in the database:
| Tax ID | Password | Name | |
|---|---|---|---|
| AARR990101XXX | password | test@someplace.com | Someone not important |
| USSE770715XXX | password2 | user2@mail.com | User Secundus |
| ABCD990501XXX | 5uP3r_57r0N9_P455 | user3@mail.net | Tercer Usuario |
{
"email": "newuser@example.com",
"name": "New User",
"phone": "+1 555 123 4567",
"password": "securePassword123",
"tax_id": "AABB990101XXX",
"addresses": [
{
"name": "home",
"street": "123 Main St",
"country_code": "US"
}
]
}{
"tax_id": "AARR990101XXX",
"password": "password"
}{
"email": "updated@example.com",
"name": "Updated Name",
"phone": "+1 555 987 6543",
"password": "newPassword456",
"tax_id": "AARR990101XXX"
}