This is a Spring Boot REST API application with a MongoDB database. The application is designed around a Client
model, which includes fields for id
, ip
, email
, and name
.
I used simple username/password authentication, with user and admin users(mainly to practice the new lambda dsl for spring security).
The Client
model includes the following fields:
id
: This is an identifier for the client. It should comply with Israeli ID standards.ip
: This is the IP address for the client. It should be a valid IPv4 address.email
: This is the email address for the client.name
: This is the name of the client. It should be in the format "first last", where "first" is the first name and "last" is the last name.
The application can initialize the database from a CSV file with 30,000 records.
This initialization is controlled by the init.database
property. If this property is set to true
, the application will load the records from the CSV file into the database.
I used the ip-api API to get the IP address location, 100 at a time, carefully using spring-retry with exponential back-off strategy to avoid overloading the API.
The entire init process should take about 10 minutes. after the first run, please set the init.database
property to false
to avoid re-initializing the database.
The application includes exception handling using @RestControllerAdvice
. This ensures that exceptions are handled in a consistent manner across the application.
The application includes custom validation annotations.
These are implemented using the Spring Boot Starter Validation, and spring AOP.
- extract the zip file
- use the maven wrapper to build the project:
./mvnw clean package
- run
docker compose up
- don't forget to update the relevant properties in the
application.properties
file, or the env variables if you use docker-compose.
- The API is documented using Swagger. You can access the Swagger UI at
http://localhost:8080/swagger-ui.html
.