This service using Spring Boot, JPA, Hibernate, Security and PostgreSQL to fulfill below requirements.
-
Upload of scanned documents and classified as Document Type (Personal, Address, ..). Below details need to be kept as well: [File, File size, Filename, Unique ID, Timestamp, customer ID, Document Type, Status]
-
The file details are saved with a status ‘Completed’ and we need to allow reading of the document database every day, each one hour based on this status.
-
Once the job reads the db record, it should generate the file on a specific folder. That folder path can change over time.
-
To be able to identify each document, an index file is needed. For each one document generation, an index file with a unique name (DS+Timestamp) will be generated equally and have below format.
-
This file shall contain a generic comment, Timestamp, customer_id, document_type, filename.
- COMMENT: ONDEMAND GENERIC INDEX FILE GENERATED
- GROUP_FIELD_NAME: Timestamp
- GROUP_FIELD_VALUE: 19/5/2022
- GROUP_FIELD_NAME: CUSTOMER_ID
- GROUP_FIELD_VALUE: 12345
- GROUP_FIELD_NAME: DOCUMENT_TYPE
- GROUP_FIELD_VALUE: KYC
- GROUP_FILE_NAME: DS1652952757340.png`
- We have exposed POST API to upload documents which internally saves in database.
- Scheduler job is configured to run every hour.
- This will read the data from the DB, Generate the original & index file for documents for completed status.
- Once job is completed, It will generate files under specified directory.
- Basic Spring Security auth is used to consume the REST Endpoint.
- Configured proper logging using SL4J & Logback to trace request.
- Complete unit test with
Code coverage > 95%
.
For building and running the application you need:
There are several ways to run a Spring Boot application on your local machine. One way is to execute the main
method in the com.moneyware.bank.documentservice.DocumentServiceApplication
class from your IDE.
Alternatively you can use the Spring Boot Maven plugin like so:
mvn spring-boot:run
Once application started, Below is the API specification for same.
Authorization : Basic dXNlcjoxMjM0NQ==
All required default POST method parameters
- Or, Alternatively in postman we can select
Basic Auth with userName=user & password=12345
customerId :201924
- Any valid non empty stringdocumentType: KYC
- Classified valid document type such as - PERSONAL/KYC/PAN/ADDRESSfile: Multipart file
- Any valid file
{
"fileName": "Resume_AnkurChauhan_Nagarro.docx",
"fileId": "8964052f-3a81-401d-a63b-e13fb555f7a4"
}
{
"error": "Provide all required parameters"
}
Released under the Apache License 2.0. See the LICENSE file.