Skip to content

komalkajal/Full_Stack_Project

Repository files navigation

Airbnb Clone (Major Project)

Brief full-stack Node.js/Express application implementing an Airbnb-like listing platform using the MVC (Model-View-Controller) pattern. Uses EJS for server-side views, MongoDB/Mongoose for persistence, Cloudinary for image uploads, and Joi for request validation.

Key Features

  • User registration, login, and session-based authentication
  • Create / Read / Update / Delete listings
  • Reviews with 1–5 star ratings
  • Image upload support (Cloudinary)
  • Server-side validation with Joi
  • Flash messages and basic responsive UI (EJS + CSS)
  • Custom error handling and async wrapper utilities

Architecture

  • Models: Mongoose schemas (models/)
  • Views: EJS templates (views/, views/includes/, views/layouts/)
  • Controllers: Business logic (controllers/)
  • Routes: Route definitions mapping to controllers (routes/)
  • Public assets: CSS, client JS (public/)
  • Utilities: custom middleware, ExpressError, validation schemas (utils/, middleware.js, schema.js)

Prerequisites

  • Node.js (v16+ recommended)
  • npm
  • MongoDB (local or Atlas)
  • Cloudinary account (optional for image uploads)

Installation

  1. Clone the repo / place project in a working folder.
  2. From project root: npm install

Environment (.env)

Create a .env file at project root. Typical variables:

PORT=3000
DATABASE_URL=mongodb://localhost:27017/your-db
CLOUDINARY_CLOUD_NAME=...
CLOUDINARY_API_KEY=...
CLOUDINARY_API_SECRET=...
SESSION_SECRET=your_session_secret

Run

  • Development: npm run dev
  • Production: npm start

(Ensure script entries in package.json map to your start/dev commands, e.g. using nodemon for dev.)

Seed / Init Data

If present, run the init script that seeds sample data (check init/index.js). Example: node init/index.js

Validation Schemas

Validation implemented with Joi in schema.js. Key schemas:

  • listingSchema — validates title, price (>=0), location, description (10–500 chars), image (optional), country.
  • reviewSchema — validates rating (1–5) and comment.

Important Files & Folders

  • app.js — Express app setup, middleware, route registration
  • models/ — Mongoose models (listing.js, review.js, user.js)
  • controllers/ — Controller logic (listings.js, reviews.js, users.js)
  • routes/ — Route definitions (listing.js, review.js, user.js)
  • views/ — EJS templates (index, show, new, edit, users)
  • public/ — CSS & client-side JS
  • cloudConfig.js — Cloudinary configuration
  • middleware.js — Auth, authorization, validation middleware
  • utils/ — ExpressError, wrapAsync, helpers
  • schema.js — Joi validation schemas (listingSchema, reviewSchema)

Routes (summary)

  • Listings
    • GET /listings
    • GET /listings/new
    • POST /listings
    • GET /listings/:id
    • GET /listings/:id/edit
    • PUT /listings/:id
    • DELETE /listings/:id
  • Reviews
    • POST /listings/:id/reviews
    • DELETE /listings/:id/reviews/:reviewId
  • Users
    • GET /signup, POST /signup
    • GET /login, POST /login
    • GET /logout

Testing

  • No automated tests included by default. Add unit/integration tests (Jest, Supertest) for controllers and routes.

Deployment

  • Provide NODE_ENV=production and set DATABASE_URL to production DB.
  • Configure Cloudinary env vars and SESSION_SECRET.
  • Use process manager (pm2) or deploy on a platform that supports Node apps.

Contributing

  • Follow MVC separation
  • Add tests for new features
  • Keep .env secrets out of repo

License

Specify project license in LICENSE file (e.g., MIT) if required.


For schema details, see schema.js (Joi schemas for listings and reviews).
For initialization and seed data, see init/ folder.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors