How deenmj/flexify works
Purpose and entry points
Flexify is a vehicle marketplace/rental platform with user, owner, staff, admin, and super-admin workflows. It supports vehicle listings, bookings, sales listings, reviews, banking details, notifications, verification, and operational settings.
Primary runtime entry points:
• Backend HTTP server: backend/server.js
• Frontend application bootstrap and routing shell: flexify-app/src/main.tsx, flexify-app/src/App.tsx
• Frontend API boundary: flexify-app/src/api.ts
Client application
The client is a Vite TypeScript React application. App.tsx is the page-composition and route boundary; pages implement public discovery, account, dashboard, listing, booking-adjacent vehicle detail, and administration experiences.
Important UI domains:
• Discovery and listing flow: flexify-app/src/pages/Explore.tsx, flexify-app/src/pages/VehicleDetail.tsx, flexify-app/src/pages/ListVehicle.tsx
• Role-specific operational consoles: flexify-app/src/pages/Dashboard.tsx, flexify-app/src/pages/AdminDashboard.tsx, flexify-app/src/pages/SuperAdminDashboard.tsx
• Sale inventory flow: flexify-app/src/pages/VehicleSalesGallery.tsx, flexify-app/src/pages/VehicleSaleDetails.tsx, flexify-app/src/components/AddVehicleSale.tsx
flexify-app/src/components/ProtectedRoute.tsx forms the client-side access-control boundary.
Identity, authorization, and realtime state
Authentication state is centralized in flexify-app/src/context/AuthContext.tsx; socket lifecycle/state is isolated in flexify-app/src/context/SocketContext.tsx. The backend authenticates requests through backend/middleware/authMiddleware.js and configures passport-based identity integration in backend/config/passport.js.
Authentication endpoints are exposed separately from domain routes in backend/routes/auth.js. Role-oriented administration is partitioned into admin, subadmin, and super-admin route groups:
• backend/routes/adminRoutes.js
• backend/routes/subadminRoutes.js
• backend/routes/superAdminRoutes.js
API and domain orchestration
The backend is a Node.js HTTP API organized as routes → controllers → models. Routes are the public API boundary; controllers coordinate validation, authorization, persistence, and side effects.
Core business areas:
• Vehicle catalog, makes/models, owner management: backend/routes/vehicleRoutes.js, backend/controllers/vehicleController.js, backend/models/Vehicle.js
• Booking lifecycle and availability blackouts: backend/routes/bookingRoutes.js, backend/controllers/bookingController.js, backend/models/booking.js
• Sales inventory: backend/routes/salesRoutes.js, backend/models/VehicleSale.js
• Reviews and feedback: backend/routes/reviewRoutes.js, backend/controllers/reviewController.js, backend/models/Review.js
• Settings and maintenance controls: backend/routes/settingsRoutes.js, backend/middleware/maintenanceGuard.js, backend/models/Settings.js
Persistence and audit boundaries
Persistence configuration is centralized at backend/config/db.js. The model layer represents users/staff, vehicles, bookings, payments, notifications, verification-related banking details, and audit records.
Key records:
• Accounts and staff: backend/models/User.js, backend/models/Staff.js
• Financial and bank data: backend/models/Payment.js, backend/models/BankDetails.js
• Auditable operational actions: backend/models/AuditLog.js, backend/utils/auditLogger.js
External services and asset handling
The service integrates external infrastructure behind utility boundaries:
• Cloud-hosted media: backend/utils/cloudinary.js
• File upload handling and local verification uploads: backend/utils/upload.js, backend/uploads/verification
• Email delivery: backend/utils/sendEmail.js
• Notification dispatch: backend/utils/notifier.js
Frontend deployment is configured for Vercel through flexify-app/vercel.json. Environment-specific backend configuration is expected through backend/.env.development and backend/.env.example.
Main entry points: App.tsx App bootstrap & routes · vehicleController.js Domain controllers · server.js HTTP server · vehicleRoutes.js Marketplace API
Components 19
React client
- App bootstrap & routes · Composes pages and routing.
flexify-app/src/App.tsx - API client
flexify-app/src/api.ts - Auth state
flexify-app/src/context/AuthContext.tsx - Socket state
flexify-app/src/context/SocketContext.tsx - Protected routes
flexify-app/src/components/ProtectedRoute.tsx - Marketplace & listings · Discovery, vehicle detail, and owner listing flow.
flexify-app/src/pages/Explore.tsx - Role dashboards · User, admin, and super-admin operations.
flexify-app/src/pages/Dashboard.tsx - Sales inventory UI
flexify-app/src/pages/VehicleSalesGallery.tsx
Node API
- HTTP server
backend/server.js - Authentication API
backend/routes/auth.js - Marketplace API · Vehicle, booking, sales, review, and settings endpoints.
backend/routes/vehicleRoutes.js - Admin APIs · Admin, subadmin, and super-admin endpoints.
backend/routes/adminRoutes.js - Auth & roles · Authenticates requests and applies role access.
backend/middleware/authMiddleware.js - Domain controllers · Coordinates validation, authorization, persistence, and side effects.
backend/controllers/vehicleController.js - Maintenance guard
backend/middleware/maintenanceGuard.js
Persistence & integrations
- Business records · Users, vehicles, bookings, payments, notifications, and settings.
backend/models/Vehicle.js - Database connection
backend/config/db.js - Audit logging
backend/utils/auditLogger.js - Media, uploads & messaging · Cloud media, verification uploads, email, and notifications.
backend/utils/cloudinary.js
Connections 24
- App bootstrap & routes → Auth state: uses
- App bootstrap & routes → Socket state: uses
- App bootstrap & routes → Protected routes: gates console routes
- App bootstrap & routes → Marketplace & listings: renders
- App bootstrap & routes → Role dashboards: renders
- App bootstrap & routes → Sales inventory UI: renders
- Marketplace & listings → API client: catalog & booking calls
- Role dashboards → API client: operational calls
- Sales inventory UI → API client: sales calls
- API client → HTTP server: HTTP requests
- HTTP server → Authentication API: mounts
- HTTP server → Marketplace API: mounts
- HTTP server → Admin APIs: mounts
- Authentication API → Auth & roles: authenticates
- Marketplace API → Auth & roles: protects endpoints
- Admin APIs → Auth & roles: enforces roles
- Marketplace API → Maintenance guard: checks maintenance
- Authentication API → Domain controllers: dispatches
- Marketplace API → Domain controllers: dispatches
- Admin APIs → Domain controllers: dispatches
- Domain controllers → Business records: reads and writes
- Business records → Database connection: persists through
- Domain controllers → Audit logging: records actions
- Domain controllers → Media, uploads & messaging: uploads and notifies