A full-stack car rental management system with intelligent cost calculation, modern UI, and comprehensive API, and persistence in data. Built as an OOP course project implementing design patterns, monolith architecture, and best practices.
Backend: FastAPI REST API with modular monolith and service layer pettern, Strategy/Decorator patterns for rental cost calculation, PostgreSQL-based repository pattern, ORM for data manipulation, and CLI interface.
Frontend: React + TypeScript SPA with shadcn/ui components, React Query for data fetching, Zod validation, and comprehensive testing.
Key Features:
- π Complete car inventory management with image uploads
- π₯ Client management system
- π Rental creation and tracking
- π° Smart cost calculation (SUV premium, long-term discounts, holiday deals)
- π Dashboard with real-time statistics
- ποΈ Soft delete with recovery archives
- β‘ Optimized queries with bulk fetching to prevent N+1 problems
- π³ Docker containerization for easy deployment
- π₯οΈ CLI for system management
- π§ͺ Full test coverage (Pytest + Vitest)
- π JWT-based authentication
| π± Mobile Flow | π₯οΈ Desktop Flow |
|---|---|
![]() |
![]() |
| π± Rental Workflow (Logic) | π₯οΈ Car Creation (UX/Validation) |
|---|---|
![]() |
![]() |
| Stage-based selection: Car search β Client lookup β Confirmation |
Inventory Flow: Zod validation & Drag-and-drop upload |
Experience the system in action without installing anything!
- Docker 21+
- Docker Compose
# Clone repository
git clone https://github.com/M4sayev/car-rental-system.git
cd car-rental-system
# Configure environment
cp .env.example .env
# Edit .env with your database credentials
# Start all services
docker-compose up --build
# View logs
docker-compose logs -fπ Frontend: http://localhost π API Docs: http://localhost:8000/docs π§ Direct Backend: http://localhost:8000
- Python 3.9+
- Node.js 22+
- PostgreSQL 18+
- pip & npm
git clone https://github.com/M4sayev/car-rental-system.git
cd car-rental-system# Install Python dependencies
pip install -r requirements.txt
# Configure database connection in .env or environment variables
(follow .env.example ensure the DB_NAME is localhost)
# Start API server
python run_api.pyAPI runs at: http://localhost:8000
Docs: http://localhost:8000/docs
cd frontend
# Install dependencies
npm install
# Start dev server
npm run devApp runs at: http://localhost:5173
car-rental-system/
β
βββ api/ # FastAPI application
β βββ main.py # App entry with CORS & static files
β βββ routes/ # API endpoints (cars, clients, rentals, dashboard)
β βββ schemas/ # Pydantic validation models
β βββ utils/ # utility and helper functions (deserialize(), save_image(),...)
β ...
β βββ collections/ # Postman test collections (4 collections)
β
βββ src/ # Core business logic
β βββ models/ # Domain models
β β βββ car.py
β β βββ client.py
β β βββ rental.py
β β βββ strategies/ # Cost calculation (Strategy + Decorator patterns)
β βββ repositories/ # Data access layer (Postgresql storage)
β βββ db/ # Seed DB, connection to DB, table creation
β βββ types/ # Reusable types for type aliasing
β βββ services/ # Business logic (car, client, rental services)
β
βββ frontend/ # React + TypeScript SPA
β βββ src/
β β βββ components/ # UI components (shadcn/ui + custom + test for each scoped component folder)
β β βββ pages/ # Pages (dashboard, cars, clients, rentals)
β β βββ hooks/ # React Query hooks
β β ...
β β βββ constants/ # Model templates, Zod validation schemas, and reusable constants
β β βββ utils/ # Utilities formatStringToISO, getStatusColor,...
β βββ test/ # Mock values for testing (MockClient, MockCar,...)
β
βββ data/ # JSON data for seeding database
β βββ cars.json
β βββ clients.json
β βββ rentals.json
β
βββ deleted_data/ # Soft-deleted records archive for seeding database
β
βββ media/ # Uploaded car images
β βββ cars/
βββ nginx/ # Nginx configuration file
β βββ nginx.conf
βββ docs/ # Documentation
β βββ UML.png
β βββ ER (for db).png
β βββ technical_documentation.md
β ...
β βββ user_guide.md
β
βββ tests/ # Backend tests (Pytest)
β
βββ cli.py # Command-line interface
βββ run_api.py # API launcher
βββ run.py # CLI launcher
βββ docker-compose.yml # Docker orchestration configuration
βββ .env.example # Environment variables template
βββ .dockerignore # Docker ignore patterns
βββ requirements.txt # Python dependencies
Navigate to http://localhost:5173 for the full UI:
- Dashboard with statistics
- Manage cars (CRUD + image upload)
- Manage clients (CRUD + validation)
- Manage Rentals (CRUD + search option + validation)
- handle login form authentication
Access http://localhost:8000/docs for interactive API documentation with:
- 8 car endpoints (including cost calculator)
- 6 client endpoints
- 5 rental endpoints
- 2 dashboard endpoints
- 2 authentication endpoints (login and signup)
Quick operations via CLI:
# List cars (list-available / list-deleted for available / deleted respectively)
python cli.py car list
# Add a car interactively
python cli.py car add
# Delete a car (select from list)
python cli.py car delete
# List all clients (list-deleted for deleted clients)
python cli.py client list
# Add a client
python cli.py client add
# Create a rental
python cli.py rental create C001 CL001
# Complete a rental
python cli.py rental complete R001
# List active rentals
python cli.py rental listDifferent cost strategies based on car type:
StandardCarCost # Base daily rate
SUVRentalCost # 20% premium for SUVsStackable discounts:
LongTermRentalCost # 15% off for 7+ days
HolidayDiscount # 10% off on Azerbaijan holidaysExample: SUV rented for 10 days on a holiday = base Γ 1.2 Γ 0.85 Γ 0.9
The repository layer implements bulk fetching to avoid N+1 query problems:
- Rentals are hydrated using bulk
get_by_ids()operations - Cars and clients are fetched in batches and mapped using hashmaps
- Result: Single query per entity type instead of N queries per rental
Example: Loading 100 rentals requires only 3 queries (rentals, cars, clients) instead of 201.
pytest # Run all tests
pytest --cov=src # With coveragecd frontend
npm run test # Run all tests
npm run test:coverage # With coverageDetailed documentation available:
- API Documentation - Endpoints, examples, Postman collections, design patterns
- Frontend Documentation - Setup, components, testing, architecture
- Technical Docs - System design and architecture
- User Guide - End-user instructions
- Backend API with microservices
- Intelligent cost calculation
- Cars & Clients & Rentals full CRUD
- Create rental step-by-step selection stage
- Dashboard with statistics
- Frontend UI with React + TypeScript
- Form validation (Zod)
- Image uploads
- Soft delete with archives
- CLI interface
- Comprehensive testing
- Database migration (PostgreSQL)
- Dockerization
- Authentication (JWT)
- Dashboard analytics charts
- AI integration
Backend:
- FastAPI - High-performance async API framework
- Python 3.9+ - Core language
- Pydantic - Data validation
- Pytest - Testing framework
- Click - CLI framework
- Docker 29+ - containeraziation
Frontend:
- React 18 - UI library
- TypeScript - Type safety
- Vite - Build tool
- TailwindCSS - Styling
- shadcn/ui - Component library
- React Query - Data fetching
- React Hook Form + Zod - Form validation
- Vitest - Testing framework
Data Storage:
- PostgreSQL - database
- psycopg2 ORM - data manipulation
- Bulk select operations preventing N+1 query issues
- Configurable history tracking for deleted items
- Media storage for uploaded images
Contributions welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
Ensure all tests pass before submitting:
# Backend
pytest
# Frontend
cd frontend && npm run test && npm run lintThis project is licensed under the MIT License.
Built as part of an OOP course project, demonstrating:
- Object-oriented programming principles
- Design patterns (Strategy, Decorator, Repository)
- Microservices architecture
- Modern web development practices
- Test-driven development
- Persisting data in the database



