The Car Rental System is a web application built with Node.js and MongoDB, designed to facilitate the rental of cars by customers.
- Car Management: Perform CRUD operations for cars, including adding, updating, and deleting car information. Cars are marked as rented when rented out.
- Customer Management: Manage customers through CRUD operations, including signing up, signing in, updating, and deleting customer profiles.
- Rental Management: Handle the rentals, including creating new rentals, updating rental information, and deleting rentals once returned.
- Special Queries: Includes specialized API endpoints to retrieve specific information about cars based on their model and rental status.
name
: Stringmodel
: Stringrental_status
: String (Status of the car, either 'available' or 'rented')
name
: Stringpassword
: Stringemail
: Stringphone
: Stringrole
: String ('customer' or 'admin')
car
: ObjectId (Reference to Car model)customer
: ObjectId (Reference to Customer model)rental_date
: Datereturn_date
: Date
-
Signup
POST /users/signup
- Request Body:
{ name, password, email, phone }
- Creates a new customer account in the system.
-
Login
POST /users/login
- Request Body:
{ email, password }
-
Get a specific user
GET /users/:user_id
- Retrieves details of a specific user by user ID.
-
Get all users
GET /users/
- Retrieves a list of all registered users.
-
Update user (owner only)
PUT /users/:user_id
- Request Body:
{ customer_id, name, email, phone }
- Updates details of a specific user. Access restricted to owner/administrator.
-
Delete user (owner only)
DELETE /users/:user_id
- Deletes a specific user from the system. Access restricted to owner/administrator.
-
Add car
POST /cars/
- Request Body:
{ name, model, rental_status }
- Adds a new car to the system.
-
Get a specific car
GET /cars/:car_id
- Retrieves details of a specific car by car ID.
-
Get all cars
GET /cars/
- Retrieves a list of all cars available in the system.
-
Update a car
PUT /cars/:car_id
- Request Body:
{ name, model, rental_status }
- Updates details of a specific car in the system.
-
Delete a car
DELETE /cars/:car_id
- Deletes a specific car from the system.
-
Create Rental
POST /rentals/
- Request Body:
{ customer, rental_date, return_date, car }
- Creates a new rental transaction for a customer to rent a car.
-
Update Rental
PUT /rentals/:rental_id
- Request Body:
{ customer, rental_date, return_date, car }
- Updates details of a specific rental transaction.
-
Delete Rental
DELETE /rentals/:rental_id
- Deletes a specific rental transaction from the system.
-
Get all Rentals
GET /rentals
- Retrieves a list of all rental transactions in the system.
-
Get a specific Rental
GET /rentals/:rental_id
- Retrieves details of a specific rental transaction by rental ID.
-
Get all cars whose model is ‘Honda’ and ‘Toyota’
GET /cars/special?models=Honda,Toyota
- Retrieves a list of all cars with models 'Honda' or 'Toyota'.
-
Get Available Cars of a Specific Model
GET /cars/available?model=Honda
- Retrieves a list of available cars of a specific model.
-
Get Cars that are Either rented or of a Specific Model
GET /cars/rentedOrSpecific?model=Honda
- Retrieves a list of cars that are either rented or of a specific model.
-
Get Available Cars of Specific Models or Rented Cars of a Specific Models
GET /cars/available-or-rented?availableModel=Toyota&rentedModel=Honda
- Retrieves a list of available cars of specific models or rented cars of a specific models.