-
Initially i wanted to hardcode the system path of the CSV and process it but i have assumed that my solution would be used for uploading files dynamically by differenct clients. Hence i have designed it as an API to be used by the clients.
-
The application processes only CSV files for now. But we can easily extend the functionality to process other file types by creating a new implementation class which implements FileParser interface.
-
I was thinking about processing only the unique records and save them to the database but it might cause ambiguity to the client. So if any duplicate record exists, none of the records would be processed and stored in DB.
-
The CSV has more columns than the database table but i am only processing what is required by the DB table. I am using builder pattern to construct the object based on the attributes.
-
I am using separate DB for application (MySQL) and Tests (H2).
-
This solution follows Test Driven Development (TDD) approach where the test cases were written first and made to fail. Then the actual logic was written and the test cases were executed to pass.
-
Test cases have been written and executed to test the controller end point, service, utility and the repository.
-
I am following Domain Driver Design (DDD) where every class name, method name and the class variables follow the business domain
-
This solutions follows SOLID principles of Object Oriented Design (OOD)
-
Every class in this project follows SRP(Single Responsibility Principle). Example ExceptionHandling is done by a separate class and it only does that work. All the possible exceptions have been handled by the code.
-
Hibernate ORM tool is used for persistence. In future, we can easily switch to any database provider with minimal configuration
-
I am assuming that the file size is not more than 100 MB. If the file size is more, client needs to split the file into multiple file or we need to do batch processing asynchronously using Spring Batch. This ensures better throughput with low latency.
-
I am assuming that docker image is built for this application it runs inside docker containers with a container orchestrator like Kubernetes. This will make the application highly scalable, fault tolerant and resilient.
-
I have assumed that my end points are secured using OAuth2 / Open ID Connect frameworks.
-
I have assumed that my Database credentials are encrypted and stored in a vault and the applications are not affected when the password is rotated
Navigate to the folder \StoreOrderApplication in cmd prompt or shell
-
Run all the tests, download the dependencies and generate the jar file
-
execute the command
mvn clean install
- Run the jar file inside the embedded server 3. execute this command to start the server in default port 8080
mvn spring-boot:run
- Test file upload from postman
Submit a post request to the url http://localhost:8080/api/uploadStoreOrder with the key as 'file' and then choose the csv file.
Verify the response messages in the postman
-
Navigate to the folder \StoreOrderApplication\Javadocs
-
Open the index.html to naviage across and read the javadocs for all the classes and its method