Skip to content

0-zagar-0/StaySwift-Effortless-Accommodation-Booking

Repository files navigation

book logo

StaySwift: Effortless Accommodation Booking

Welcome to the StaySwift: Effortless Accommodation Booking! Our platform is revolutionizing the rental process, providing a convenient and efficient experience for both seekers and administrators. For users, it's a straightforward journey from registration to booking their chosen accommodation. The user-friendly interface offers detailed information about each property, including type, location, size, amenities, daily rates, and real-time availability. For administrators, a powerful toolkit streamlines the management of the housing inventory. Adding, updating, and removing properties is a breeze, with instant availability information. Forget about paperwork – now everything is on your screen in real-time. Booking is under user control. From creating and managing bookings to modifications – it's all in the hands of the user. Administrators also easily access booking information for effective management. This is just a glimpse of how our service transforms the rental experience. Thank you for your understanding.

Technologies used <> How to use <> Entities <> Database Structure <> Endpoints <> Swagger <> Notification

Technologies used

  • java logo Java 17+
  • maven logo
  • spring boot logo Spring Boot
  • spring boot logo Spring Data JPA
  • spring boot logo Spring Boot Security
  • spring boot logo JSON Web Token
  • Lombok
  • MapStruct
  • Liquibase
  • MySql 8
  • Hibernate
  • JUnit5
  • Testcontainers
  • Docker
  • Swagger
  • Stripe API
  • Telegram API
  • Postman

How to use the project

1. Before you start, make sure you have installed:
  • java logo JDK 17+
  • docker logo Docker
  • If you wish, you can test the application in Postman: Postman

If you use Postman, go to the postman folder and import the file into Postman, you will have all the endpoints that are in the application.

2. Clone repository
git clone https://github.com/0-zagar-0/booking-app.git
3.Create an .env file in the root directory

See an example of a sample .env-sample

4.Run these commands to create a docker container and run the image
docker-compose build
docker-compose up
5. Now whatever port you specified in SPRING_LOCAL_PORT, the program will run on that port
example - http://localhost:8081

General use

6.There are already 2 users saved in the database:

User with role CUSTOMER

email - [email protected]
password - User=123456789

User with role MANAGER
email - [email protected]
password - User=123456789

to use the endpoints, can you register a new user.

7.How to use payment endpoints

When you go to the session initialization endpoint, you will need to pass your card for payment, in test mode we use card_token, for that follow this link

https://stripe.com/docs/testing?testing-method=tokens#pagos-rechazados

select the card you like and go to the Tokens tab, maybe something like this: tok_visa

You can use these provided card tokens:

tok_visa
tok_mastercard
tok_visa_chargeDeclined

Entities

User

The user entity represents detailed information about registered users. 
At this stage, there are only 2 roles that grant certain access rights to users, these are: customer and manager.
        

Accommodation

The Accommodation entity holds crucial information about available living spaces. 
It includes details such as accommodation type (e.g., HOUSE, APARTMENT), location, size (e.g., STUDIO, ONE_BEDROOM), amenities, daily rental rate, and availability count. 
Soft deletion is implemented, allowing accommodations to be marked as deleted without permanent removal. 
This entity is fundamental to efficiently managing and offering diverse housing options within the system.
        

Address

The Address entity serves as a cornerstone for storing location information within the system.
        

Amenity

The Amenity entity represents various amenities available within the system. 
It incorporates fields for unique identification, amenity name, and a soft deletion flag.
        

Booking

The Booking entity represents a reservation made within the system. 
It includes information such as a unique identifier, check-in and check-out dates, the associated accommodation, 
the user making the booking, booking status, and a soft deletion flag.
        

Payment

The Payment entity encapsulates information about a financial transaction. It includes a unique identifier, payment status (e.g., PENDING, PAID), 
associated booking ID, session URL for payment processing, session ID, payment amount, and a soft deletion flag for improved data management.
        

Database structure

database structure

Endpoints

Authentication Management

HTTP Request Endpoints Security requirement Description
POST /api/auth/register None Allows users to register a new account.
POST /api/auth/login None Login with email and password. Response - JWT token

User Management

HTTP Request Endpoints Security requirement Description
GET /api/users/me CUSTOMER, MANAGER Retrieves the profile information for the currently logged-in user.
PUT /api/users/{id}/role MANAGER Enables users to update their roles, providing role-based access.
PUT /api/users/me CUSTOMER, MANAGER Allows users to update their profile information.

Accommodation Management

HTTP Request Endpoints Security requirement Description
POST /api/accommodations MANAGER Permits the addition of new accommodations.
GET /api/accommodations/all NONE Provides a list of available accommodations.
GET /api/accommodations/{id} CUSTOMER, MANAGER Retrieves detailed information about a specific accommodation.
PATCH /api/accommodations/{id} MANAGER Allows updates to accommodation details, including inventory management.
DELETE /api/accommodations/{id} MANAGER Enables the removal of accommodations.

Booking Management

HTTP Request Endpoints Security requirement Description
POST /api/bookings CUSTOMER, MANAGER Permits the creation of new accommodation bookings.
GET /api/bookings/?user_id=...&status=... MANAGER Retrieves bookings based on user ID and their status.
GET /api/bookings/my CUSTOMER, MANAGER Retrieves user bookings
GET /api/bookings/{id} CUSTOMER, MANAGER Provides information about a specific booking.
PATCH /api/bookings/{id}/td> CUSTOMER, MANAGER Allows users to update their booking details.
DELETE /api/bookings/{id} CUSTOMER, MANAGER Enables the cancellation of bookings.

Payment Management

HTTP Request Endpoints Security requirement Description
GET /api/payments/?user_id=... MANAGER Retrieves payment information for users.
POST /api/payments CUSTOMER, MANAGER Initiates payment sessions for booking transactions.
GET /api/payments/success CUSTOMER, MANAGER Handles successful payment processing through Stripe redirection.
GET /api/payments/cancel/ CUSTOMER, MANAGER Manages payment cancellation and returns payment paused messages during Stripe redirection.

Swagger-ui usages

If you will test the application locally in swagger, then after launching the application, follow this link. Use the port specified in the .env file

http://localhost:8080/api/swagger-ui/index.html#

This project is also uploaded to AWS server, you can follow this link and use Swagger to test the application without installing anything

http://ec2-18-208-193-98.compute-1.amazonaws.com/api/swagger-ui/index.html#/

Notification Service

A telegram bot was created for managers to notify them about newly created reservations and paid or canceled payments. You can join the bot when you test the application.

https://t.me/Booking_Application_test_bot

The video shows how the application works

Watch video loom

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published