Introducing the Car Rental Service API - Your Ultimate Car Rental Hub! This project offers a comprehensive car rental service API, powered by Spring Boot, tailored to streamline your car rental experience. Explore its diverse functionalities encompassing user management, robust cars control, seamless rental processing, secure payment handling with Stripe integration, and dynamic notification service via Telegram.
- Technologies Used
- Key Functionalities
- SQL Database Diagram And Architecture
- Setup Instructions
- Challenges Encountered
- Contact
- Java: Programming language used as the foundation for the project.
- Spring Boot: Framework for building robust Java applications.
- Stripe API: Payment processing API used to handle transactions securely and efficiently.
- Telegram API: Messaging API utilized for integrating Telegram's notifications functionalities into applications.
- Spring Security: Provides authentication and authorization capabilities.
- JWT: (JSON Web Token) Standard for securely transmitting information between parties as a JSON object.
- Spring Data JPA: Simplifies the data access layer by abstracting away the boilerplate code.
- Mapstruct: Used for mapping between DTOs and entities.
- Lombok: Library for reducing boilerplate code in Java classes.
- Maven: Build automation tool for managing dependencies and building the project.
- Liquibase: Manages database schema changes over time.
- Jackson: Provides JSON serialization and deserialization capabilities in Java.
- Swagger: Generates interactive API documentation.
- MySQL: Database for storing application data.
- Docker: For containerizing the application.
- JUnit 5: Framework for unit testing.
- Mockito: Framework for mocking objects in tests.
You can explore the Car Rental Service API using my Postman collection. Don't hesitate to reach out if you have any questions or encounter any issues. Happy testing!
Below, I've included detailed explanations for each endpoint in the Postman collection, helping you navigate and understand the functionalities of the Car Rental Service API more effectively.
π© - publicly available
π¨ - for logged-in users
π₯ - for administrators
- π©
POST: /api/auth/registration
- User Registration: New customers can register with their email, password, and personal details. - π©
POST: /api/auth/login
- User Authentication: Secure login mechanism for registered users.
- π¨
GET: /api/users/me
- View Profile: Users can retrieve their own profile information. - π¨
PATCH: /api/users/me
- Update Profile: Users can update their own profile information. - π₯
PUT: /api/users/{userId}/role
- Update User Roles: Admin users can update roles of other users.
- π¨π₯
GET: /api/rentals/?user_id=...&is_active=...
- View Rentals: Users can view their rental history, Admin Users can view all users' rental history. It can also be filtered by activity status and user ID. - π¨
GET: /api/rentals/{rentalId}
- View Rental Details: Users can check details of a specific rental. - π¨
POST: /api/rentals
- Start Rental: Users can initiate a new car rental, reducing available inventory by 1. - π¨
POST: /api/rentals/{rentalId}/return
- Return Car: Users return a rental, increasing available inventory by 1.
- π¨π₯
GET: /api/payments/?user_id=...
- View Payments: Users can view their payment history, and Admin Users can view all users' payment history. - π¨
GET: /api/payments/success/{rentalId}/?type=...
- Check Successful Payment: Check the success of payment based on the rental ID and payment type - Stripe API redirection. - π¨
GET: /api/payments/cancel/{rentalId}
- Cancel Payment: Retrieve a message indicating that the payment cancellation process is paused - Stripe API redirection. - π¨
POST: /api/payments
- Initiate Payment: Users can start the payment process for their car rental.
- π©
GET: /api/cars
- Retrieve Cars: Everyone can browse through the list of available cars. - π©
GET: /api/cars/{carId}
- View Car: Everyone can view detailed information about a specific car. - π₯
POST: /api/cars
- Add Car: Admin users can add new cars to the rental inventory. - π₯
PUT: /api/cars/{carId}
- Update Car: Admin users can modify car details, including inventory management. - π₯
DELETE: /api/cars/{carId}
- Delete Car: Admin users can remove cars from the rental inventory.
- Handles notifications for new rentals, overdue rentals, and successful payments.
- Integrates with Telegram API, facilitating seamless communication with administrators using Telegram Bot and Chat.
Below is a simplified representation of the database schema used in the Car Rental Service API:
This diagram illustrates the relationships between different entities in the database, including tables for users, payments, rentals, cars, and more.
Here is also a very simplified version of the architecture of the project:
Ensure you have Docker and JDK installed
In this project, I've used Docker Desktop 4.28.0 (139021)
and Oracle OpenJDK version 20.0.2
- Clone the repository to your local machine.
- Verify you have Docker Engine running.
- Navigate to the project directory.
- Run
./mvnw clean package
to create a .jar file. - In the .env file you should provide the necessary DB and Docker variables, here is an example:
MYSQLDB_USER=1234
MYSQLDB_PASSWORD=1234
MYSQLDB_DATABASE=1234
JWT_SECRET=1234
TELEGRAM_BOT_TOKEN=1234
STRIPE_SECRET_KEY=1234
MYSQLDB_ROOT_PASSWORD=1234
MYSQLDB_LOCAL_PORT=1234
MYSQLDB_DOCKER_PORT=1234
SPRING_LOCAL_PORT=1234
SPRING_DOCKER_PORT=1234
DEBUG_PORT=1234
(Do you want to fully test my API? Please contact me at: [email protected] for actual .env file)
- Run
docker compose up -d --build
to start the application and MySQL database. - Feel free to test my application using Postman/Swagger.
Postman: Keep in mind that you have to pass the Authorization (Bearer Token) that you receive when logging in.
Do you want to test admin features? Here are the credentials of the sample manager:And also, the credentials of the sample customer:{ "email": "[email protected]", "password": "12345678" }
{ "email": "[email protected]", "password": "12345678" }
- To stop and remove containers use
docker compose down
.
Working with the Stripe API was a bit challenging, requiring careful setup to ensure a proper connection and secure handling of financial data. This project was quite robust, requiring careful management of various components such as user authentication, rental processing, and real-time notifications. Coordinating these different elements while maintaining data consistency and security added complexity. Ultimately, I am proud of this project and the valuable lessons I learned while developing it.
Thank you for taking the time to explore my Car Rental Service API!
π§ Want to get in touch? Please, feel free to send me an email at [email protected]