Car rental platform - agencies list vehicles, customers book them.
Stack: React + Vite, Node/Express, MySQL
Requirements: Node.js, MySQL
# install deps
npm install
# setup db
mysql -u root -p < database.sql
# configure env
cp server/.env.example server/.env
# edit server/.env with your db credentials
# run backend
cd server && node server.js
# run frontend (separate terminal)
cd client && npm run devBackend runs on http://localhost:4000
Frontend runs on http://localhost:5173
car-rental/
├── client/ # React frontend
│ ├── src/
│ │ ├── api.js
│ │ ├── pages/
│ │ ├── components/
│ │ └── context/
│ └── public/img/
├── server/ # Express backend
│ ├── routes/
│ │ ├── auth.js
│ │ ├── cars.js
│ │ └── bookings.js
│ ├── server.js
│ └── db.js
└── database.sql
Agencies:
- Add/edit cars (model, plate, seats, daily rate)
- View all bookings
Customers:
- Browse available cars
- Book by date + duration
- Cars become unavailable after booking
Auth:
- Separate registration for customers/agencies
- Session-based auth with express-session
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_PORT=3306
DB_NAME=car_rental
SESSION_SECRET=random_secret_here
PORT=4000
CLIENT_URL=http://localhost:5173
SESSION_COOKIE_SECURE=false
SESSION_COOKIE_SAMESITE=lax- Import
database.sqlto create tables (no seed data) - Sessions expire after 24h
- Vite proxy handles
/apirequests to backend
- Create database/user and run
database.sqlinto it (tables:customers,agencies,cars,bookings). - Ensure you have TiDB MySQL connection details:
host,port,username,password, and database name (default:car_rental).
Deploy car-rental/server as a Render Web Service.
Environment variables to set:
DB_HOST=<tidb_host>
DB_PORT=<tidb_mysql_port>
DB_USER=<tidb_username>
DB_PASSWORD=<tidb_password>
DB_NAME=car_rental
SESSION_SECRET=<random_string>
CLIENT_URL=<your_render_frontend_url> # e.g. https://your-frontend.onrender.com
SESSION_COOKIE_SECURE=true # required when SESSION_COOKIE_SAMESITE=none
SESSION_COOKIE_SAMESITE=noneDeploy the car-rental/client build to Render.
You must set VITE_API_BASE_URL at build time so the frontend knows where the API is:
VITE_API_BASE_URL=<your_render_backend_url> # e.g. https://your-backend.onrender.comThe frontend will call: ${VITE_API_BASE_URL}/api/...