How chillingturtl/rentwise works
Purpose and Entry Surface
RentWise is a TypeScript API for car-rental operations: authentication, car catalog management, image uploads, and booking-related domain logic. The application assembly point is api/src/app.ts; HTTP entry surfaces are organized under api/src/routes/auth.route.ts and api/src/routes/car.routes.ts.
HTTP and Request Pipeline
Routes dispatch requests to controller handlers, with middleware enforcing cross-cutting concerns before domain execution. Authentication, request validation, upload handling, and centralized failures are separated in:
• api/src/middleware/authenticator.ts
• api/src/middleware/auth.validator.ts
• api/src/middleware/car.validator.ts
• api/src/middleware/errorHandler.ts
This establishes the boundary between untrusted HTTP input and application services.
Identity and Authorization
Authentication is layered as route/controller/service logic:
• api/src/controllers/auth.controller.ts
• api/src/services/auth.service.ts
• api/src/types/auth.types.ts
Authenticated request state is likely carried through Express type augmentation in api/src/types/express.d.ts, then consumed by protected car or booking operations through authenticator.ts.
Car Catalog and Media Lifecycle
Car management is the primary exposed business area. Controllers handle car and image endpoints, services own workflow decisions, and query modules isolate persistence access:
• api/src/controllers/car.controller.ts
• api/src/controllers/carImage.controller.ts
• api/src/services/car.service.ts
• api/src/queries/car.queries.ts
• api/src/queries/carImage.queries.ts
Image ingestion crosses an infrastructure boundary: multipart processing is configured through api/src/config/multer.ts and api/src/middleware/upload.middleware.ts; cloud media storage is configured in api/src/config/cloudinary.ts and invoked through api/src/services/upload.service.ts. Image public IDs are represented in database migrations, including api/prisma/migrations/20260802183840_added_public_id_to_car_images/migration.sql.
Booking Domain
Booking rules are represented as a dedicated service/query/type layer:
• api/src/services/booking.service.ts
• api/src/queries/booking.queries.ts
• api/src/middleware/booking.validator.ts
• api/src/types/booking.types.ts
Database evolution indicates booking status defaults to pending and booking notes can be optional. Booking persistence therefore forms a relational boundary with cars and other entities, rather than being embedded solely in HTTP handlers.
Persistence and Data Model
Prisma is the persistence abstraction. The canonical schema and client boundary are:
• api/prisma/schema.prisma
• api/src/db/prismaClient.ts
• api/prisma/migrations/20260715182403_init/migration.sql
Migrations capture evolving relations, rental-rate optionality, car-image identifiers, and booking semantics. Query modules should be the main callers of the Prisma client, keeping controllers and services insulated from direct ORM details. api/src/db/seed.ts supports initializing development or baseline data.
Runtime and External Dependencies
The API runs on Node.js with TypeScript, Express-oriented middleware/types, Prisma-managed relational storage, Multer for uploads, and Cloudinary as the external image-hosting service. Runtime environment validation/configuration is centralized in api/src/env.ts; application startup wiring and dependency composition belong in api/src/app.ts.
Main entry points: car.routes.ts Car routes · app.ts Application assembly · auth.route.ts Auth routes · prismaClient.ts Prisma client
Components 20
HTTP boundary
Express routes, middleware, and controllers.
- Application assembly · Composes runtime configuration and HTTP surfaces.
api/src/app.ts - Auth routes
api/src/routes/auth.route.ts - Car routes
api/src/routes/car.routes.ts - Authentication middleware · Establishes authenticated request state for protected operations.
api/src/middleware/authenticator.ts - Request validation · Auth, car, and booking validators reject invalid input.
api/src/middleware/auth.validator.ts - Central error handler
api/src/middleware/errorHandler.ts - Auth controller
api/src/controllers/auth.controller.ts - Car controller
api/src/controllers/car.controller.ts - Car image controller
api/src/controllers/carImage.controller.ts
Application domain
Authentication, catalog, media, and booking workflows.
- Authentication service · Implements identity workflows using auth types.
api/src/services/auth.service.ts - Car service · Owns car catalog workflows.
api/src/services/car.service.ts - Booking service · Owns booking rules and status semantics.
api/src/services/booking.service.ts
Persistence
Prisma-backed relational data access.
- Car data access · Includes car and car-image persistence queries.
api/src/queries/car.queries.ts - Booking data access
api/src/queries/booking.queries.ts - Prisma client · Shared relational persistence boundary.
api/src/db/prismaClient.ts - Relational schema · Defines cars, images, bookings, and their relations.
api/prisma/schema.prisma
Media infrastructure
Multipart ingestion and external image storage.
- Upload service · Transfers car media to cloud storage.
api/src/services/upload.service.ts - Multipart upload handling · Uses Multer to process incoming image files.
api/src/middleware/upload.middleware.ts - Cloudinary client
api/src/config/cloudinary.ts
Other components
- Runtime environment · Validates centralized runtime configuration.
api/src/env.ts
Connections 20
- Runtime environment → Application assembly: configures
- Application assembly → Auth routes: mounts
- Application assembly → Car routes: mounts
- Application assembly → Central error handler: registers
- Auth routes → Request validation: validates
- Auth routes → Auth controller: dispatches
- Car routes → Authentication middleware: protects
- Car routes → Request validation: validates
- Car routes → Multipart upload handling: processes images
- Car routes → Car controller: dispatches
- Car routes → Car image controller: dispatches
- Auth controller → Authentication service: uses
- Car controller → Car service: uses
- Car image controller → Upload service: uploads through
- Car service → Car data access: persists through
- Booking service → Booking data access: persists through
- Car data access → Prisma client: queries via
- Booking data access → Prisma client: queries via
- Prisma client → Relational schema: models
- Upload service → Cloudinary client: stores media via