Skip to content

Ronn0905/CarRentalApplication

Repository files navigation

Car Rental Application - CSE 412 Group 20

A full-stack car rental management system built with FastAPI (Python) and React, featuring role-based access control for Admins, Agents, and Renters.

Team Members

Sophia Gu, Matthew Fenger, Ronit Khanna, Gautam Mehta

Table of Contents

Features

For Renters

  • Browse Cars: Search and filter available rental cars by location
  • Book Rentals: Reserve cars with start/end dates and dropoff locations
  • Manage Balance: Add funds to account for bookings
  • Rental History: View past and current rentals
  • License Management: Register and view driver's license information
  • Agency Reviews: Rate and review car rental agencies

For Agents

  • Car Management: Add, edit, and delete car listings
  • Track Rentals: View all rentals for agency's vehicles
  • Inventory Control: Monitor car status (Available/Rented)
  • Location Management: Assign cars to different cities

For Administrators

  • Analytics Dashboard: View total revenue, users, agencies, and cars
  • Revenue Tracking: Monitor monthly revenue with interactive charts
  • System Overview: Track total rentals and user statistics
  • Agency Management: Oversee all registered rental agencies

Technology Stack

Backend:

  • FastAPI (Python web framework)
  • SQLAlchemy (ORM)
  • PostgreSQL (Database)
  • JWT Authentication
  • Uvicorn (ASGI server)

Frontend:

  • React 19.2.0
  • React Router DOM 7.9.4
  • Recharts (Data visualization)
  • Axios (HTTP client)

Prerequisites

Before setting up the project, ensure you have the following installed:

Installation & Setup

Step 1: Clone the Repository

git clone https://github.com/helloChlorine/CSE412-Group20-CarRentalApp.git
cd CSE412-Group20-CarRentalApp

Step 2: Set Up the Database

  1. Start PostgreSQL service on your machine

  2. Create a PostgreSQL database (if not already created):

    createdb postgres

    Or use pgAdmin/another PostgreSQL tool to create a database named postgres

  3. Import the Database Dump:

    psql -U postgres -d postgres -f DatabaseDump/DBDump.sql

    Note: Replace postgres with your PostgreSQL username if different

  4. Update Database Configuration (if needed):

    • Open backend/database.py
    • Update the connection string if your PostgreSQL credentials differ:
      SQLALCHEMY_DATABASE_URL = "postgresql://username:password@localhost:5432/postgres"

Step 3: Set Up the Backend

  1. Create a Python virtual environment:

    python -m venv venv
  2. Activate the virtual environment:

    • Windows:
      venv\Scripts\activate
    • macOS/Linux:
      source venv/bin/activate
  3. Install Python dependencies:

    pip install fastapi uvicorn sqlalchemy psycopg2-binary python-jose[cryptography] python-multipart

Step 4: Set Up the Frontend

  1. Navigate to the frontend directory:

    cd frontend/auth-app
  2. Install Node.js dependencies:

    npm install

Step 5: Run the Application

You'll need two terminal windows - one for the backend and one for the frontend.

Terminal 1: Start the Backend Server

# From the project root directory
uvicorn main:app --reload --host 0.0.0.0 --port 8000

The backend API will be available at: http://localhost:8000

API documentation: http://localhost:8000/docs

Terminal 2: Start the Frontend Server

# Navigate to frontend directory
cd frontend/auth-app

# Start React development server
npm start

The application will automatically open at: http://localhost:3000

Usage

Creating an Account

  1. Navigate to http://localhost:3000
  2. Click "Create Account"
  3. Select your account type:
    • Renter: For customers who want to rent cars
    • Agent: For rental agency employees managing inventory
    • Admin: For system administrators (requires credentials)

Renter Workflow

  1. Login with your credentials
  2. Add Funds to your balance from the dashboard
  3. Browse Cars to view available vehicles
  4. Book a Car by selecting dates and dropoff location
  5. View Rental History to track your bookings
  6. Review Agencies to rate your rental experience

Agent Workflow

  1. Login with agent credentials
  2. Post New Cars from the Manage Cars page
  3. View Active Rentals to track customer bookings
  4. Update Car Status or delete available vehicles

Admin Workflow

  1. Login with admin credentials
  2. View Analytics Dashboard for system-wide metrics
  3. Monitor Revenue with monthly breakdown charts
  4. Track User Statistics across all account types

Database Schema

The application uses the following main tables:

  • users: Base table for all user accounts
  • renters: Renter-specific information (balance)
  • agents: Agent-specific information (employee_id, agency_id)
  • admins: Admin user records
  • car: Vehicle inventory with status tracking
  • car_agency: Rental agency information
  • rent: Booking records with pricing
  • license: Driver's license information
  • city / state: Location data
  • rate: Agency reviews and ratings

See databasePopulation/databaseSchemaUpdated.png for the full ER diagram.

API Documentation

Once the backend is running, visit http://localhost:8000/docs for interactive API documentation powered by FastAPI's built-in Swagger UI.

Key Endpoints

Authentication:

  • POST /token - User login
  • POST /users/ - Create new user account

Renters:

  • GET /renter/{user_id}/balance - Get current balance
  • POST /renter/add-funds - Add funds to account
  • GET /renter/{user_id}/rentals - View rental history
  • POST /rentals/book - Book a car

Agents:

  • POST /cars/ - Add new car to inventory
  • GET /agent/{user_id}/cars - View agency cars
  • DELETE /cars/{vin} - Remove car from inventory

Admins:

  • GET /admin/revenue - Total system revenue
  • GET /admin/monthly-revenue - Revenue by month
  • GET /admin/users - Total user count
  • GET /admin/agencies - Total agencies

Project Structure

CSE412-Group20-CarRentalApp/
│
├── backend/
│   ├── __init__.py
│   ├── database.py          # Database configuration
│   └── models.py            # SQLAlchemy models
│
├── frontend/
│   └── auth-app/
│       ├── src/
│       │   ├── Admin.js     # Admin dashboard
│       │   ├── Agent.js     # Agent dashboard
│       │   ├── Renter.js    # Renter dashboard
│       │   ├── Login.js     # Login page
│       │   ├── CreateAccount.js
│       │   ├── BrowseCars.jsx
│       │   ├── ManageCars.js
│       │   ├── RentalHistory.js
│       │   ├── Review.js
│       │   └── ...
│       └── package.json
│
├── DatabaseDump/
│   └── DBDump.sql          # Database dump with sample data
│
├── databasePopulation/
│   ├── populate_car_database.py
│   ├── databaseSchemaUpdated.png
│   └── data/
│
├── main.py                 # FastAPI application entry point
├── package.json            # Root package configuration
└── README.md

Contributing

This project was developed as part of CSE 412 coursework. For questions or contributions, please contact the team members through the repository.

License

This project is for educational purposes as part of CSE 412 at Arizona State University.


Important Notes:

  • Default admin credentials may be in the database dump
  • The application uses JWT tokens for session management
  • Car bookings generate random prices between $77-$555 for demonstration
  • The database password in backend/database.py should be updated for your local setup

Troubleshooting

Backend won't start:

  • Verify PostgreSQL is running
  • Check database connection string in backend/database.py
  • Ensure all Python dependencies are installed

Frontend won't start:

  • Delete node_modules and package-lock.json, then run npm install again
  • Verify Node.js version is 16 or higher
  • Check that port 3000 is not in use

Database connection errors:

  • Confirm PostgreSQL service is active
  • Verify database name, username, and password
  • Check if the database dump was imported successfully

Can't login:

  • Ensure the database has been populated with the dump file
  • Try creating a new account
  • Check browser console for error messages

About

A full-stack Car Rental Application built using React, Node.js, Express, and PostgreSQL with authentication, booking management, and admin features.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors