A full-stack car rental management system built with FastAPI (Python) and React, featuring role-based access control for Admins, Agents, and Renters.
Sophia Gu, Matthew Fenger, Ronit Khanna, Gautam Mehta
- Features
- Technology Stack
- Prerequisites
- Installation & Setup
- Usage
- Database Schema
- API Documentation
- Project Structure
- Contributing
- 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
- 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
- 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
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)
Before setting up the project, ensure you have the following installed:
- Python 3.8+ - Download Python
- Node.js 16+ and npm - Download Node.js
- PostgreSQL 12+ - Download PostgreSQL
- Git - Download Git
git clone https://github.com/helloChlorine/CSE412-Group20-CarRentalApp.git
cd CSE412-Group20-CarRentalApp-
Start PostgreSQL service on your machine
-
Create a PostgreSQL database (if not already created):
createdb postgres
Or use pgAdmin/another PostgreSQL tool to create a database named
postgres -
Import the Database Dump:
psql -U postgres -d postgres -f DatabaseDump/DBDump.sql
Note: Replace
postgreswith your PostgreSQL username if different -
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"
- Open
-
Create a Python virtual environment:
python -m venv venv
-
Activate the virtual environment:
- Windows:
venv\Scripts\activate
- macOS/Linux:
source venv/bin/activate
- Windows:
-
Install Python dependencies:
pip install fastapi uvicorn sqlalchemy psycopg2-binary python-jose[cryptography] python-multipart
-
Navigate to the frontend directory:
cd frontend/auth-app -
Install Node.js dependencies:
npm install
You'll need two terminal windows - one for the backend and one for the frontend.
# From the project root directory
uvicorn main:app --reload --host 0.0.0.0 --port 8000The backend API will be available at: http://localhost:8000
API documentation: http://localhost:8000/docs
# Navigate to frontend directory
cd frontend/auth-app
# Start React development server
npm startThe application will automatically open at: http://localhost:3000
- Navigate to
http://localhost:3000 - Click "Create Account"
- 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)
- Login with your credentials
- Add Funds to your balance from the dashboard
- Browse Cars to view available vehicles
- Book a Car by selecting dates and dropoff location
- View Rental History to track your bookings
- Review Agencies to rate your rental experience
- Login with agent credentials
- Post New Cars from the Manage Cars page
- View Active Rentals to track customer bookings
- Update Car Status or delete available vehicles
- Login with admin credentials
- View Analytics Dashboard for system-wide metrics
- Monitor Revenue with monthly breakdown charts
- Track User Statistics across all account types
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.
Once the backend is running, visit http://localhost:8000/docs for interactive API documentation powered by FastAPI's built-in Swagger UI.
Authentication:
POST /token- User loginPOST /users/- Create new user account
Renters:
GET /renter/{user_id}/balance- Get current balancePOST /renter/add-funds- Add funds to accountGET /renter/{user_id}/rentals- View rental historyPOST /rentals/book- Book a car
Agents:
POST /cars/- Add new car to inventoryGET /agent/{user_id}/cars- View agency carsDELETE /cars/{vin}- Remove car from inventory
Admins:
GET /admin/revenue- Total system revenueGET /admin/monthly-revenue- Revenue by monthGET /admin/users- Total user countGET /admin/agencies- Total agencies
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
This project was developed as part of CSE 412 coursework. For questions or contributions, please contact the team members through the repository.
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.pyshould be updated for your local setup
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_modulesandpackage-lock.json, then runnpm installagain - 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