How leaopedro/car-rental-app works
Project type and purpose
• This is a full-stack MVP for a car-rental platform (“Carental”) with a React/Vite frontend and a Node.js/Express backend.
• The backend exposes REST endpoints for availability, booking and user management and can run with either an in-memory DB (for demos) or PostgreSQL (for production).
• The frontend is a single-page React application using a BookingContext and an API layer to interact with the backend.
File structure
Top level:
• backend/ – Node.js & Express API
– src/app.ts – Express app bootstrap
– src/routes/ – route handlers (availability, booking, users)
– src/services/ – business-logic layer
– src/models/ – data models (Booking, Car, User, types)
– src/db/ – DBClient interface and two implementations: inMemoryDb & postgresDb, plus migrations/seeds
– src/external/emailService.ts – integration point for sending emails
– tests/ – unit & integration tests for each layer
– knexfile.ts & docker-compose.yml – DB config & local Postgres container
• frontend/ – React + Vite SPA
– src/api/index.ts – thin fetch/axios wrapper targeting VITE_API_URL
– src/context/BookingContext.tsx – global state for booking flows
– src/components/ & src/pages/ – presentational and page components
– setupTests.ts & tests/ – component, page, context, and API layer tests
– Vite config & TypeScript configs
README for additional insights
• Emphasis on two interchangeable DB clients via a shared DBClient interface, enabling quick demos or real Postgres integration.
• The backend and frontend each have their own environment files and startup instructions, reinforcing the CI/CD separation.