Introduction ♦ Technologies ♦ Models ♦ How run this project ♦ Project architecture ♦ Database structure ♦ Controllers ♦ Contacts
Welcome to Car Sharing Service App! 👋
Our Car Sharing Service App is a convenient and secure app which will definitely be the best solution for you and your renting car services. We use authorization via JWT to protect access to the app. All users are divided into managers and customers which provides them with certain rights in the app. We created Telegram bot which sends messages when rental is created, paid or overdue. In future these notifications may be adjusted to your requirements (e.g. they may be sent to only managers, only to customers or to both). We used the Stripe API as a convenient payment system. All payments are secure and in case some error occurs a transaction will be rollbacked.
- Java 17
- Maven
- Spring boot, Spring JPA, Spring Security
- Lombok
- MapStruct
- MySql 8
- Hibernate
- Liquibase
- JUnit5 (+ Mockito)
- Docker
- Swagger
- Telegram API
- Stripe API
The Car model is a structured representation of a vehicle available
in a car sharing service, encompassing key attributes for effective
management and user interaction.
It includes the following attributes:
- Model: A distinctive identifier denoting the specific name or label of the car model.
- Brand: The brand or manufacturer responsible for producing the car, providing insight into its origin.
- Type: An enumeration capturing the body type of the car. It can take values from the set {SEDAN, SUV, HATCHBACK, UNIVERSAL}, elucidating the vehicle's structural category.
- Inventory: An integer reflecting the current availability of this particular car within the car sharing service. This attribute aids in real-time tracking of the car's stock.
- Daily Fee: A decimal value in $USD, indicating the cost users incur per day when renting this car. This information facilitates transparent pricing for potential renters.
- Image URL: A string representing a URL pointing to an image of the car. This visual aid allows users to preview the car's appearance before making a rental selection.
This model is a basic representation of customer information
and is commonly used in user management systems for applications.
The password field is securely hashed and stored.
It includes the following attributes:
- Email: String, representing the user's email address.
- First name: String, representing the user's first name.
- Last name: String, representing the user's last name.
- Password: String, representing the user's password.
Provides the possible roles, including CUSTOMER and MANAGER. This model is commonly used for managing user roles and permissions.
- CUSTOMER - default role for all registered users
- MANAGER - with this role you can manage cars and rentals
The Rental model encapsulates information related to a car rental transaction.
It includes the following attributes:
- Rental date: Represents the date when the car was rented.
- Return date: Signifies the expected date for the car to be returned.
- Actual return date: Records the actual date when the car was returned.
- Car ID: A unique identifier associated with the specific car involved in the rental.
- User ID: A unique identifier corresponding to the user who initiated the rental.
The Payment model represents a financial transaction.
It encompasses the following attributes:
- Status: An enumeration with possible values PENDING, PAID or CANCELED, indicating the current status of the payment.
- Type: An enumeration with possible values PAYMENT or FINE, specifying whether the transaction is related to a regular payment or a fine.
- Rental: A unique identifier associated with the specific car rental to which the payment or fine is related.
- Session URL: A URL pointing to the payment session with a stripe, facilitating online payment processing.
- Session ID: A String representing the unique identifier of the payment session.
- Amount to Pay: A decimal value (in $USD) representing the calculated total price for the rental or fine.
- Make sure you have installed next tools
- Clone project
git clone https://github.com/The-Champions-JV/Car-Sharing-Service.git
-
Create
.env
file in the root of project and populate variables from.env.sample
file -
Run the following command to build and start the Docker containers
docker-compose up --build
- The application should now be running at http://localhost:8081.
Unauthorized customers can access endpoints to see all cars or info on one certain car. After registration and login customer can create a new rental, see info on their rental history, and pay for rental. Manager can modify data: add a new car, update info on an existing one, update customer's role.
HTTP method | Endpoint | Role | Function |
---|---|---|---|
POST | /api/auth/registration | ALL | Allows a new customer to register |
POST | /api/auth/login | ALL | Authenticates a customer and returns JWT token |
HTTP method | Endpoint | Role | Function |
---|---|---|---|
GET | /api/users/me | CUSTOMER | Enables customers to get info about themselves |
PATCH | /api/users/update | CUSTOMER | Enables customers to update their firstname and lastname |
PUT | /api/users/{id}/role | MANAGER | Enables managers to update user's role |
HTTP method | Endpoint | Role | Function |
---|---|---|---|
GET | /api/cars | ALL | Enables even unauthorized users to get all cars |
GET | /api/cars/{id} | ALL | Enables even unauthorized users to get info on a specific car |
POST | /api/cars | MANAGER | Enables manager to add a new car to DB |
PUT | /api/cars/{id} | MANAGER | Enables managers to update info on an existing in DB car |
DELETE | /api/categories/{id} | MANAGER | Enables managers to delete a car from DB |
HTTP method | Endpoint | Role | Function |
---|---|---|---|
GET | /api/payments | CUSTOMER | Enables customers to get all their payments |
GET | /api/payments/search/?status= | CUSTOMER | Enables customers to get all their payments by status (PAID/PENDING/CANCELED) |
POST | /api/payments/pay | CUSTOMER | Enables customers to create session to use Stripe |
HTTP method | Endpoint | Role | Function |
---|---|---|---|
POST | /api/rentals | CUSTOMER | Enables customers to create new rental |
GET | /api/rentals | CUSTOMER | Enables customers to get all their rentals |
GET | /api/rentals/?is_active= | CUSTOMER | Enables customers to get all their rentals by activeness (true/false) |
GET | /api/rentals/search/?user_id=&is_active= | MANAGER | Enables managers to search rentals using userId and activeness |
POST | /api/rentals/{id}/return | MANAGER | Enables managers to return rental by setting actual return date |