Besedo Microservice Assignment
Explore the Assignment »
Report Bug
Request Feature
Table of Contents
To build 3 rest points to perform following operations:
- One endpoint to ingest an JSON object with the following format. Fields have length constraint on min/max, email is required and only one of title and body is required.
- One endpoint to return this data, considering that the dataset will contain a large number of entries. Filtering should also be possible, by a single field, one of id, email, title or body.
- One endpoint that returns a CSV file that is a report on the ingested items, composed of two columns, the first one being the id of the item and the second one being the amount of vowels contained in the body.
Following are the technologies used to build the framework.
Clone the repository
git clone https://github.com/veerao05/besedo.git
Setting up the workspace
After cloning the Repository it can be placed anywhere on your local hard drive.
For building and running the application you need:
cd <path_of_backend_repo>
mvn clean install
Ex: <MainPath>/besedo/
- Locally
Run BesedoMainApplication.java file
- Docker
To Build the Docker image:
cd <MainPath>/besedo/
docker build --tag=besedo:latest .
To Run the springboot application in container:
docker run --name=besedo -it -e DATABASE_SERVER=jdbc:h2:mem:testdb -dp 8080:8080 -v ${PWD}/logs:/besedo/logs besedo:latest
To see the container logs:
docker logs -f --tail 10 besedo
To enter inside the container:
docker exec -it besedo sh
To stop the container:
docker stop besedo
To delete all the stopped container:
docker container rm $(docker ps -a -q)
To delete the image:
docker rmi <image-id>
To obtain image id:
docker images
Here are some url samples for pagination (with/without filter):
/api/data: using default page and size
/api/data?page=1&size=5: using 1st page and 5 size
/api/data?size=5: using default value for page
/api/data?id=1&page=1&size=3: pagination & filter by id
/api/data?title=Senior Engineer&csv=false: pagination & filter by ‘title’ status
/api/data?csv=true: to generate csv report
. Sorting
. SQL Db
. Error Code Handling
. Additional Junit
. Update and Delete endpoints
- Add any suggestions
See the open issues for a full list of proposed features (and known issues).
Improvements given:
- Exceptions handling using spring
- Global exception handling
- CSV reader null pointer on getBody()
- Load on get mapping can be done using indexing/search DB should be used.
- Load on Post mapping can be done through queues/Spring Batch
- if (data.charAt(i) == 'a' || data.charAt(i) == 'e' || data.charAt(i) == 'i' || data.charAt(i) == 'o' || data.charAt(i) == 'u') { count++; }. Use lamda expression
- Dont try to throw exceptions from Helper class(Bottom class) . How do you handle the exceptions thrown from bottom class in Upper class.
- Why Query is used why not getbyId or getByEmail was used? It can be used , to provide pagination all in one method use query here. Alternative is HSQL/getbyId or getByEmail
- findDataList(String id, String email, String title, String body, Pageable pageable, boolean csv) - could have used all the paramaters in one class object.
- Since @lombok.Data is used , controller could have used controller injection. so use @RequiredArgsConstructor
- Unit test cases for Controller and service/business layer
- Entity is directly exposed . so use view object instead of exposing Entity.
- POST request didnt not return any response message.
- countVowels(data.getBody()) - handle Null pointer exception in case of GetBody null.
- email is required and only one of title and body is required. - Didnt understand the question properly here.
- Exception handling with different codes could have been done better to the clients.
- Handling duplicate records.
- Why inbuilt CSV library was used?
- Why Java8 was used why not JAVA16?
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/SampleFeature
) - Commit your Changes (
git commit -m 'Add some SampleFeature'
) - Push to the Branch (
git push origin feature/SampleFeature
) - Open a Pull Request
Your Name - VeenaRao and Email:veenaraofr@gmail.com
Project Link: https://github.com/veerao05/besedo
List of resources used for project reference.