How krushit1307/stayverse works
1. Overall shape
- StayVerse is a full-stack monorepo with two major application surfaces:
- a Node.js backend at the repository root
- a React + TypeScript frontend in Frontend/Wander-lust-main
- The backend owns authentication, bookings, and data persistence; the frontend is a separate SPA-style client.
2. Backend application boundary
- The root app.js is the backend entry point and likely wires together Express, middleware, routes, and error handling.
- The backend is organized in classic layered form:
- routes define HTTP endpoints
- controllers implement request handling and business logic
- models define domain entities
- middleware handles cross-cutting concerns
- utils contains external integrations
3. Backend domain model
- The core server-side entities are:
- user
- listing
- booking
- review
- otp
- This tells you the app centers on a marketplace/rental workflow with user accounts, property/listing management, reservations, and feedback, plus OTP-based verification or password recovery.
4. Backend request flow
- Requests enter through routes/auth.js and routes/booking.js.
- Those routes dispatch to controllers/auth.js and controllers/booking.js.
- Controllers then interact with the models and supporting utilities, and responses are returned through the Express layer.
- middleware/errorHandler.js suggests centralized error mapping, while middleware/validator.js indicates input validation before controller execution.
5. Authentication and account recovery
- controllers/auth.js, routes/auth.js, models/user.js, and models/otp.js together form the account lifecycle subsystem.
- utils/sendEmail.js indicates email delivery is part of the auth flow, likely for OTP verification and/or forgot-password recovery.
- middleware/auth.js protects authenticated routes, so some endpoints are gated behind session/token-based checks.
6. Booking subsystem
- controllers/booking.js, routes/booking.js, and models/booking.js form the reservation workflow.
- This subsystem likely links users to listings and captures booking state, dates, and related actions.
- In an architecture diagram, booking should be shown as a domain flow that depends on authenticated users and listing records.
7. Listing presentation on the server
- The views/listings/*.ejs files indicate the backend also has a server-rendered listing UI:
- index
- show
- new
- edit
- That means the repo is not purely API-only; it includes an EJS view layer for listing management or fallback pages.
- init/data.js and init/index.js suggest seed/bootstrap data for these listing views and backend storage.
8. Frontend application boundary
- The frontend is a Vite-powered React app with TypeScript.
- Key entry points are src/main.tsx and src/App.tsx.
- This client is structured as a standalone UI with its own routing/pages and reusable components, separate from the root backend.
9. Frontend page and component structure
- src/pages contains the major screens:
- Home
- ListingDetail
- Bookings
- NewListing
- EditListing
- Login/Register/ForgotPassword
- NotFound
- src/components contains shared UI building blocks such as Navbar, Footer, ListingCard, FilterChips, and SplashScreen.
- src/context/AuthContext.tsx indicates shared client-side auth state, while src/hooks/useInView.ts supports UI behavior/animation/visibility logic.
10. Frontend data and domain shaping
- src/constants/amenities.ts and src/data/mockListings.js show the frontend has domain-specific presentation data and mock fallback content.
- This suggests the SPA can render listings even when backend data is unavailable or during early development.
- Styling is split between component/global CSS files, so presentation is mostly client-owned.
11. Infrastructure and delivery
- The repo is container-aware: it has a root Dockerfile, a frontend Dockerfile, .dockerignore files, and docker-compose.yml.
- .github/workflows/ci.yml shows CI automation is part of the delivery pipeline.
- DOCKER_GUIDE.md implies containerized local/dev deployment is a supported workflow.
12. How the pieces connect
- The backend is the system of record for users, listings, bookings, reviews, and OTP/email workflows.
- The frontend consumes that backend for authentication and user-facing listing/booking interactions, while also maintaining its own UI state via AuthContext.
- A useful architecture diagram would show:
- browser/client traffic to the React app
- React app calls into the backend API
- backend routes/controllers talk to models and email utilities
- data persists through the model layer, with seeded initialization supported by init/
- EJS views as a secondary server-rendered listing interface
Main entry points: App.tsx React app · controllers/booking.js Booking controller · auth.js Auth routes · routes/booking.js Booking routes
Components 25
Backend
Node.js server, request flow, and domain persistence
- app.js · Backend entry point wiring server middleware and routes
app.js - Auth routes · Authentication and account recovery endpoints
routes/auth.js - Booking routes · Reservation endpoints
routes/booking.js - Auth controller · Login, register, OTP, and recovery flows
controllers/auth.js - Booking controller · Booking creation and user-listing reservation handling
controllers/booking.js - Auth guard · Protects authenticated server routes
middleware/auth.js - Validator · Validates incoming request data
middleware/validator.js - Error handler · Centralized error mapping and response handling
middleware/errorHandler.js - User · Account identity and authentication data
models/user.js - Listing · Property or rental listing record
models/listing.js - Booking · Reservation state and booking records
models/booking.js - Review · User feedback on listings
models/review.js - OTP · One-time verification or recovery codes
models/otp.js - Send email · Email delivery for OTP and recovery flows
utils/sendEmail.js - Seed data · Initial listing/bootstrap dataset
init/data.js - Init script · Startup seeding and initialization logic
init/index.js - Listing views · Server-rendered listing pages for browse, detail, create, and edit
views/listings/index.ejs
Frontend
React + TypeScript single-page client
- React app · Frontend application shell and routing
Frontend/Wander-lust-main/src/App.tsx - Main entry · Client-side React mount point
Frontend/Wander-lust-main/src/main.tsx - Auth context · Shared frontend authentication state
Frontend/Wander-lust-main/src/context/AuthContext.tsx - Pages · Home, listing detail, bookings, auth, and listing forms
Frontend/Wander-lust-main/src/pages/Home.tsx - Components · Shared UI pieces such as navbar, cards, footer, and splash screen
Frontend/Wander-lust-main/src/components/Navbar.tsx - UI data · Amenity constants and mock listings for presentation fallback
Frontend/Wander-lust-main/src/data/mockListings.js
Delivery
Container and CI pipeline
- Docker · Repository containerization for backend and frontend
docker-compose.yml - CI workflow · Continuous integration pipeline
.github/workflows/ci.yml
Connections 30
- app.js → Auth routes: mounts · Registers authentication routes on the server
- app.js → Booking routes: mounts · Registers booking routes on the server
- app.js → Error handler: uses · Centralized server error handling
- Auth routes → Auth guard: protects · Some auth endpoints require authenticated access
- Auth routes → Validator: validates · Validates auth request payloads
- Auth routes → Auth controller: dispatches · Routes delegate auth requests to controller logic
- Booking routes → Auth guard: protects · Booking operations are gated by auth
- Booking routes → Validator: validates · Validates booking request payloads
- Booking routes → Booking controller: dispatches · Routes delegate reservation requests to controller logic
- Auth controller → User: reads/writes · Manages account records
- Auth controller → OTP: reads/writes · Creates and checks OTP records
- Auth controller → Send email: sends · Delivers OTP or recovery emails
- Booking controller → Booking: reads/writes · Persists booking records
- Booking controller → Listing: reads · Resolves the listing being reserved
- Booking controller → User: reads · Uses authenticated user identity
- Booking controller → Review: relates to · Bookings sit alongside listing feedback data
- Init script → Seed data: loads · Bootstraps seed data
- Init script → Listing: seeds · Initializes listing storage
- Listing views → Listing: renders · Server-rendered listing pages are backed by listing data
- Main entry → React app: boots · Mounts the React application
- React app → Auth context: uses · Shares auth state across the client
- React app → Pages: navigates · Page-level routing and screen composition
- Pages → Components: composes · Screens reuse shared UI building blocks
- Pages → UI data: uses · Supports presentation with mock or static data
- React app → Listing views: alternates with · Backend also exposes server-rendered listing pages
- React app → Auth routes: calls API · Client auth flows depend on backend endpoints
- Pages → Booking routes: calls API · Booking screens depend on reservation endpoints
- Docker → app.js: packages · Containerizes backend service
- Docker → React app: packages · Containerizes frontend service
- CI workflow → Docker: validates · CI supports build and delivery workflow