How pikolosan/car-rental-website---college-project- works
Project type and purpose
• Project Type: Full-stack monolithic web application
• Purpose: A car rental management system (“RentACar”) that lets customers browse and book vehicles, and allows administrators to manage inventory, bookings, and users.
File structure
• Top-level files
• app.js – main Express application entry point
• cloudConfig.js – cloud service configuration (e.g., image uploads)
• schema.js – database connection and schema initialization
• deletedata.js / loadData.js / init/… – data seeding and initialization
• middleware.js – global middleware (e.g., authentication, error handling)
• Directories
• controllers/ – business logic for listings, reviews, users
• routes/ – Express routing modules matching controllers
• models/ – Mongoose models (Booking, Listing, Review, User)
• views/ – EJS templates, organized by feature (layouts, includes, listings, users)
• public/ – Static assets (CSS, JS, images)
• utils/ – helper classes (ExpressError, wrapAsync)
• Configuration files
• package.json / package-lock.json – dependencies
• .gitignore
Main components
a. Client (Browser)
• Requests HTML, CSS, JavaScript
• Sends form submissions / AJAX to server
b. Web Server (Express.js)
• app.js
• Routes layer → Controllers → Models
• Middleware (authentication, error handling)
c. Database (MongoDB / MySQL)
• Collections / tables: Users, Listings, Reviews, Bookings
d. Cloud Service (e.g., Cloudinary)
• Image upload & storage via cloudConfig.js
e. Initialization & Admin CLI
• Scripts: init/index.js, loadData.js, deletedata.js
Relationships and interactions
• Client → HTTP Request → Express Routes
• Route Handler → Controller Function
• Controller → Model CRUD → Database
• Controller → Renders EJS views + data → Client
• Client → Static Assets served from /public
• Image uploads flow: Client → Express → Cloud Service → URL stored in DB
• Admin scripts → Direct DB connection to seed or delete data
Architectural patterns and design principles
• MVC (Model-View-Controller):
• Model: Mongoose schemas (models/)
• View: EJS templates (views/)
• Controller: controllers/
• Layered architecture: routing → business logic → data access
• Modularization: one route/controller per feature (users, listings, bookings, reviews)
• Separation of concerns:
• utils for shared helpers
• middleware for cross-cutting concerns
• init scripts for one-time tasks
Key technologies and frameworks
• Node.js, Express.js
• MongoDB (via Mongoose) or MySQL
• EJS templating
• Client-side JS & CSS in public/
• JWT (authentication – in middleware.js)
• Cloudinary/S3 (cloudConfig.js) for image storage
• Rectangle: Client Browser
• Rounded rectangle: Express App
• Frontend/UI (light blue)
• Backend/API (light green)
• Data layer (light orange)
• External services (light gray)
• HTTP/HTTPS
• JSON (API responses)
• EJS rendering