Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

AdamWMorgan/code-exercise-java

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL Shortener Coding Exercise

image

Project Implementation

This project was created using Java 21 on the backend and React for the frontend UI, making use of MaterialUI for faster implementation of the layout.

The pre-existing openapi.yaml is used during the build stage to automatically generate the DTOs and API interfaces.The auto-generation of the objects meant that the context path was used for the objects, i.e. ShortenPost201Response, instead of a more concise name, however I made an assumption that if you were working to a 3rd party spec and this is what was provided, you would need to develop against the source of truth.

Project Testing

Testing for the backend was implemented using Junit, Mockito and the Spring framework's MockMVC for Spring based requests. Integration test, in their own module, were implemented using the Cucumber framework alongside Junit. Features were written in Gherkin.

UTs image
ITs image
Frontend testing was achieved using Jest.

image

Build & Run Project

To build and run the project, you simply need to execute the 'docker-compose up --build' command from the root directory. This will spin up the following:


image
To prevent data loss between sessions, a Docker volume is mapped to the MongoDB data directory.

Issues Faced

  • OpenAPI contract naming, previously mentioned.
  • Reverted to using Flapdoodle's embedded MongoDB to overcome some challenges faced when using Testcontainers. I'd initially implemented the Testcontainers approach to stick with the overall usage of Docker, however it was proving difficult due to some network issues with my Docker settings that was becoming a bit of a time sink to solve.

Productionisation Considerations

A production grade version of this app would require (non-exhaustive) the following:

  • User authentication, with history linked to specific users (which would also help filter on single user history when querying).
  • Rate limiting to avoid spamming of endpoints for malicious purposes.
  • Caching of URLs to avoid unnecessary calls to DB.
  • Improved logging and monitoring.
  • Database indexing as the data eventually grows to a huge number.
  • Concurrency would be ideal here since this is I/O heavy. This project is using Java 21, so it would be quite straightforwards to enable virtual threads.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 68.0%
  • JavaScript 28.1%
  • Gherkin 2.8%
  • Other 1.1%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.