This is a Spring Boot application developed for the Elemental Technical Test. It processes a pipe-delimited text file, validates the request IP address, and logs request details to an H2 database.
- Java 17
- Docker (optional, for containerization)
First, ensure you have the Gradle wrapper generated (if not already):
gradle wrapperThen, build the project:
./gradlew clean buildYou can run the application using Gradle:
./gradlew bootRunOr run the built JAR file:
java -jar build/libs/elemental-technical-test-0.0.1-SNAPSHOT.jarThe application will start on port 8080.
Once the application is running, you can access the OpenAPI documentation at:
- Swagger UI: http://localhost:8080/swagger-ui/index.html
- OpenAPI JSON: http://localhost:8080/v3/api-docs
The application uses an in-memory H2 database. You can access the console at:
- URL: http://localhost:8080/h2-console
- JDBC URL:
jdbc:h2:mem:testdb - User:
sa - Password:
password
URL: /process-file
Method: POST
Content-Type: multipart/form-data
Parameters:
file: The text file to process.
Example using cURL:
curl -F "file=@EntryFile.txt" http://localhost:8080/process-fileSample EntryFile.txt content:
18148426-89e1-11ee-b9d1-0242ac120002|1X1D14|John Smith|Likes Apricots|Rides A Bike|6.2|12.1
3ce2d17b-e66a-4c1e-bca3-40eb1c9222c7|2X2D24|Mike Smith|Likes Grape|Drives an SUV|35.0|95.5
1afb6f5d-a7c2-4311-a92d-974f3180ff5e|3X3D35|Jenny Walters|Likes Avocados|Rides A Scooter|8.5|15.3
URL: /logs
Method: GET
Content-Type: application/json
Example using cURL:
curl http://localhost:8080/logsdocker build -t elemental-technical-test .docker run -p 8080:8080 elemental-technical-test- File Processing: Parses a custom pipe-delimited file format.
- IP Validation: Validates the request IP against
ip-api.com. Blocks requests from China, Spain, USA, and specific ISPs (AWS, GCP, Azure). - Request Logging: Logs request details (IP, Country, ISP, Duration, Status) to the database.
- OpenAPI: Auto-generated API documentation.