This is a REST API using Spring boot, MongoDB and Docker. The application the backend part of a AirBnB-like living space rental platform on which users can publish, book and leave reviews on listings
- MongoDB
- Docker
- Postman
-
clone the repository and open your IDE of choice
git clone https://github.com/simonrintala/Backend-Project.git -
re-name the application.properties file to application.yml (in /src/main/resources) and insert relevant code to connect to your mongoDB database. Below is an example to use if connecting to a MongoDB Atlas cluster (replace information in "{}" with your chosen database and jwt token information)
spring: data: mongodb: uri: {mongoDB Atlas uri} database: {your database name} jwt: secret: {jwt secret key} expirationMs: {jwt token expiration time in milliseconds}
- start a detached instance of docker by running the "docker-compose up -d" command in the folder of the cloned repository
- run the AirBnBPlatform application from your IDE
- test the application using Postman
Link to Postman documentation: https://documenter.getpostman.com/view/40844842/2sAYkGLem6
The booking process has been refactored to better follow the structure of a Java project. A couple of design patterns and principles has been followed as a result of that. The goal is to make the code more maintainable and also easier to continue develop.
Starting out our BookingService was responsible for a lot of operations which we would seperate to make it so it only have one resposibility. The end goal was for it to oversee the booking-operations and only assign instructions for other classes for them to handle.
The newly refactored operations should be possible to extend but without altering the existing source code.
We're making classes depend on interfaces instead of eachother, making them easier to modify and maintain.
We wanted to expand on the different types of pricing so that depending on season or weekend the price would alternate. Strategy pattern let us better pick what strategy will be used in the price calculation and also make it easier for future implementation of different pricings.
The booking process has a bunch of different status options that we want to separate in to multiple state-classes. These classes will have less possible operations to handle and should be easier to use. This will also make the implementation of adding future statuses simpler.
The template method pattern is used to create general scaffolds of methods for different types of API endpoint commands. Using this pattern and grouping the methods under different template methods maximizes on code reusability and makes it easier to add logic behind new API endpoints in the future, should they conform to the structure of an existing template.
Diagrams created while planning can be found here.
https://drive.google.com/file/d/1vjZqXoIeQTIFehQvcYVYt8CMpKg8pMNV/view?usp=sharing