top of page

Develop a Microservice to Import Users from External Application to our System Using Spring Boot

We are also providing Data Science Assignment Help, Homework help and Project Help for our domestic client. Realcode4you.com is group of PHD researchers and Masters that can help you to do your data science projects.


Here you get complete code with full explanation without any plagiarism issues.


Below will the list of steps.

1. Admin will upload the file

2. Validation should run to verify if the file valid or not

- File should not be empty

- Extension should be .csv only

- File should have these headers "First_Name", "Last_Name", "Email",

"Phone_Number"


Once the validation will be completed, we will send 201 as status code in response OR else we will send 400 as status code with error message


Below list of error message

"FILE_EMPTY": "File should not be empty"

"EXTENSION_INVALID": "File extension should be .csv only"

"HEADERS_NOT_AVAILABLE": Either "First_Name OR Last_Name" And "Email OR Phone_Number" should be available


3. Once validated place the file in this location BASE_PATH/user_import/ "BASE_PATH" can be any path on your system and insert the file details in user_import_task_audit table with "PENDING" status.

Also update the total no users need to be imported.

4. Write a scheduler which will pick the files from the audit table whose status is "PENDING"

5. Traverse through the list of user import tasks and start reading of files one by one

6. For the read records start preparing user objects

7. Send this user objects to kafka producer

8. Listen the user objects and perform necessary validations (such as for email/phone number) and create user entry into the table

9. Update the audit table status as per sequence diagram


Technical Specifications

Build Tool: Maven

Language: Java

Framework: Spring boot, kafka

Database: Postgres

API Testing: Postman

Topic Name: event.user.import

Database Name: external_data_import

Project Name: ExternalDataImport


Sample Csv File Structure

"First_Name", "Last_Name", "Email", "Phone_Number"

“Manoj”, “Dubey”, manoj@xyz.com, “1234567890”

“Raj”, “Singhania”, “raj@xyz.com”, “1234567809”


Sequence Diagram


Scheduler


ER Diagram


ENTITY


entity UserImportTask {

id Long required,

fileName String required,

filePath String required,

createdAt TimeStamp required,

createdBy Long required

}


entity UserImportTaskAudit {

id Long required,

userImportTaskId Long required,

totalNumberOfUsers Long required,

taskStatus TaskStatus required

createdAt TimeStamp required,

createdBy Long required,

updatedAt TimeStamp,

updatedBy Long

}


entity User {

id Long required,

firstName String,

lastName String,

email String,

phoneNumber String,

password Secret required,

createdAt TimesStamp required,

createdBy Long required

}


enum TaskStatus {

PENDING, IN_PROGRESS, ERROR, COMPLETED, COMPLETED_WITH_ERROR

}


relationship OneToOne {

UserImportTask{region} to UserImportTaskAudit

}



ENDPOINTS

host: Server_host_name


Create User Import Task

Http Method: POST

Endpoint: host/upload

Payload:

file Multipart

Request Body String data

{

“fileName”: “Name of file”;

“uploadedBy”: “Id who uploaded the file any random value can be 1L”

}


Response:

Success : 201

{

“id”: 1L,

“fileName”: “user.csv”,

“audit”: {

“id”:1L,

“totalNumberOfRecords”: 20L,

“taskStatus”: PENDING

}

}

400 BAD_REQUEST


FETCH USER IMPORT TASK LIST

Http Method: GET

Endpoint: host/tasks

Payload:

Response :

200

{[

{

“id”: 1L,

“fileName”: “user.csv”,

“audit”: {

“id”:1L,

“totalNumberOfRecords”: 20L,

“taskStatus”: PENDING

}

}


]

}


FETCH USERS

Http Method: GET

Endpoint: host/users

Response:

Return paginated list of users

{

[

“id”: 1L,

“firstName”:”Manoj”,

“lastName”:”Dubey”,

“email”:manoj@xyz.com,

“phoneNumber”:”1234567890”

]

}


PS: Resolve SONAR issue and code coverage should be 80% at least

*OpenCsv library can be used for file reading but choice depends/ try to use java 8/11 features where possible

* Try to use JPA wherever possible instead of native queries

* Add common exception handler

* Implement logging whenever necessary

* Swagger Configuration

* Actuator enablement for health endpoints


Good To Have

Suggestive search


Http Method: GET

Endpoint: host/users/{searchString}

Response:

Return paginated list of users

{

[

“id”: 1L,

“firstName”:”Manoj”,

“lastName”:”Dubey”,

“email”:manoj@xyz.com,

“phoneNumber”:”1234567890”

]

}


*If possible try to use mapstruct library for mapping data from dto to entity and vice versa


Pre-Requisites

- Any docker solution should be installed for e.g. Docker Desktop, rancha desktop etc.

- For kafka use docker containers

- All necessary softwares such as IDE, Java, Maven, Database etc. should be installed



To get solution of above problem or need any help related to Java Spring Boot then you can send your assignment request at:


realcode4you@gmail.com

Comments


bottom of page