How hamza9021/roam-roster works
Project type and purpose
• From the file tree and README, “ROAM ROSTER” is a full-stack MVC web application built with Node.js/Express, EJS templating for server-side rendering, MongoDB for data storage, and Cloudinary for image hosting.
• Purpose: a room-booking platform with secure user authentication, property listings, reviews, and advanced search.
File structure
• Top-level files:
• app.js (Express application entrypoint)
• cloudConfig.js (Cloudinary configuration)
• schema.js (Mongoose connection/config)
• middleware.js (global middleware)
• init/ (data seeding scripts)
• package.json (dependencies & scripts)
• MVC directories:
• models/ (Mongoose schemas: User, Listing, Review, OTP)
• controllers/ (business logic: user actions, listing CRUD, reviews)
• routes/ (Express routers mapping HTTP endpoints to controllers)
• views/ (EJS templates for pages & layouts)
• Public assets:
• public/CSS, public/js (static CSS/JS served to client)
• Utilities:
• utils/CustomError.js, wrapAsync.js (error handling helpers)
README for additional insights
• Technology stack: Express, EJS, MongoDB, Cloudinary
• Features: RESTful APIs, MVC, secure authentication, search filters
• Deployment/config: environment variables for DB & Cloudinary credentials
Main components & their interactions
a. Client / Browser (UI)
• Requests HTML via routes, submits forms (login, signup, new listing, reviews).
• Static assets (CSS/JS) served from public/.
b. Express Server (app.js)
• Loads cloudConfig, connects to MongoDB (schema.js).
• Applies middleware (middleware.js), mounts routers (routes/).
• Handles errors via utils and renders views.
c. Routing Layer (routes/*.js)
• Maps HTTP methods and URLs to controller methods.
• Example: POST /listings → controllers/listing.createListing.
d. Controller Layer (controllers/*.js)
• Validates input, calls Models, invokes Cloudinary for image uploads, applies business rules.
e. Data Layer (models/*.js)
• Mongoose schemas define data structures: Listing, User, Review, OTP.
• Interact with MongoDB for CRUD operations.
f. External Services
• MongoDB Atlas (NoSQL data store).
• Cloudinary (media hosting/upload).
g. Utilities
• CustomError & wrapAsync manage error flow across async middleware.
Architectural patterns & design principles
• MVC separation: Views (EJS) ↔ Controllers ↔ Models
• RESTful routing
• Centralized error handling
• Configuration abstraction (cloudConfig.js, .env)
• Seed data module (init/) for demo or testing