Skip to content

itzsouravkumar/LIVIGO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LIVIGO 🏠

Node.js Express MongoDB License

A full-stack property rental platform inspired by Airbnb, built with the MERN stack.

Live Demo: https://livigo.onrender.com


✨ Features

  • User Authentication - Secure registration/login with Passport.js and session management
  • Listing Management - Full CRUD operations with image upload via Cloudinary
  • Advanced Search - Filter by categories (11 types) and location-based search
  • Review System - Star ratings (1-5) with comment functionality
  • Interactive Maps - Leaflet.js integration with OpenStreetMap geocoding
  • Responsive Design - Airbnb-inspired UI with mobile-first approach
  • Authorization - Role-based access control for listings and reviews

πŸ› οΈ Tech Stack

Frontend: EJS, Bootstrap 5.3, Leaflet.js, Font Awesome
Backend: Node.js 22.16, Express.js 5.2, Passport.js
Database: MongoDB 9.0, Mongoose ODM


πŸ—„οΈ Local Development Database Setup

For local development and testing, a separate MongoDB database named Livigo is used and seeded with sample data.

1. Configure Environment

  • Ensure your .env file contains:
    MONGO_URL=mongodb://localhost:27017/Livigo

2. Seed the Database

  • Run the following command to seed the Livigo database with sample listings:
    node init/index.js
    This will clear existing listings and insert sample data.

3. Use in Development/Test

  • In your app, use process.env.MONGO_URL for local/test/dev environments to connect to the seeded Livigo database.

Storage: Cloudinary (images), Connect-Mongo (sessions)
Validation: Joi schema validation


πŸ—οΈ Architecture

System Overview

graph TB
    Client[Web Browser] --> Express[Express Server]
    Express --> Auth[Passport.js Auth]
    Express --> Router[Route Handlers]
    Router --> Controller[Controllers]
    Controller --> Mongo[(MongoDB)]
    Controller --> Cloud[Cloudinary CDN]
    Auth --> Session[Session Store]
    Session --> Mongo
Loading

MVC Pattern

graph LR
    View[EJS Views] --> Controller[Controllers]
    Controller --> Model[Mongoose Models]
    Model --> DB[(MongoDB)]
    DB --> Model
    Model --> Controller
    Controller --> View
Loading

Data Flow

sequenceDiagram
    participant U as User
    participant S as Server
    participant M as Middleware
    participant C as Controller
    participant DB as Database

    U->>S: HTTP Request
    S->>M: Authentication Check
    M->>M: Validate & Authorize
    M->>C: Process Request
    C->>DB: CRUD Operation
    DB->>C: Return Data
    C->>S: Render Response
    S->>U: HTTP Response
Loading

πŸš€ Quick Start

Prerequisites

Node.js 22.16.0+ | MongoDB | Cloudinary Account

Installation

# Clone repository
git clone https://github.com/itssouravkumar/livigo.git
cd livigo

# Install dependencies
npm install

# Configure environment variables
cp .env.example .env
# Edit .env with your credentials

# Seed database (optional)
node init/index.js

# Start development server
npm run dev

Environment Variables

PORT=3000
MONGO_ATLAS_URL=mongodb+srv://username:password@cluster.mongodb.net/livigo
SESSION_SECRET=your_session_secret_key
CLOUD_NAME=your_cloudinary_name
CLOUD_API_KEY=your_cloudinary_key
CLOUD_API_SECRET=your_cloudinary_secret

πŸ“‘ API Endpoints

Authentication

Method Endpoint Description Auth Required
GET /register Show registration form No
POST /register Create new user No
GET /login Show login form No
POST /login Authenticate user No
GET /logout Logout user Yes

Listings

Method Endpoint Description Auth Required
GET /listings Get all listings No
GET /listings/new Show create form Yes
POST /listings Create listing Yes
GET /listings/:id Get listing details No
GET /listings/:id/edit Show edit form Yes (Owner)
PUT /listings/:id Update listing Yes (Owner)
DELETE /listings/:id Delete listing Yes (Owner)

Reviews

Method Endpoint Description Auth Required
POST /listings/:id/reviews Create review Yes
DELETE /listings/:id/reviews/:reviewId Delete review Yes (Author)

πŸ—„οΈ Database Schema

erDiagram
    USER ||--o{ LISTING : creates
    USER ||--o{ REVIEW : writes
    LISTING ||--o{ REVIEW : has

    USER {
        ObjectId _id PK
        string username UK
        string email UK
        string hash
        string salt
    }

    LISTING {
        ObjectId _id PK
        string title
        string description
        object image
        number price
        string location
        string country
        enum category
        ObjectId owner FK
        array reviews
    }

    REVIEW {
        ObjectId _id PK
        number rating
        string comment
        date createdAt
        ObjectId author FK
    }
Loading

Categories: Trending, Rooms, Iconic Cities, Mountains, Castles, Amazing Pools, Camping, Farms, Arctic, Beachfront, Cabins


πŸ“ Project Structure

livigo/
β”œβ”€β”€ app.js                 # Express app configuration
β”œβ”€β”€ controllers/           # Business logic
β”‚   β”œβ”€β”€ listing.js
β”‚   β”œβ”€β”€ review.js
β”‚   └── user.js
β”œβ”€β”€ models/               # Mongoose schemas
β”‚   β”œβ”€β”€ listing.js
β”‚   β”œβ”€β”€ review.js
β”‚   └── user.js
β”œβ”€β”€ routes/               # Express routes
β”‚   β”œβ”€β”€ listing.js
β”‚   β”œβ”€β”€ review.js
β”‚   └── user.js
β”œβ”€β”€ views/                # EJS templates
β”‚   β”œβ”€β”€ components/       # Reusable components
β”‚   β”œβ”€β”€ layouts/          # Page layouts
β”‚   β”œβ”€β”€ listings/         # Listing views
β”‚   └── users/            # User views
β”œβ”€β”€ public/               # Static assets
β”‚   β”œβ”€β”€ css/
β”‚   β”œβ”€β”€ scripts/
β”‚   └── assets/
β”œβ”€β”€ utils/                # Utility functions
β”œβ”€β”€ middlewares.js        # Custom middleware
β”œβ”€β”€ schema.js             # Joi validation
└── cloudConfig.js        # Cloudinary setup

πŸ”„ Key Workflows

User Authentication Flow

User Registration β†’ Hash Password β†’ Save to DB β†’ Auto Login β†’ Create Session
User Login β†’ Validate Credentials β†’ Create Session β†’ Redirect to Dashboard

Listing Creation Flow

Auth Check β†’ Render Form β†’ Upload Image β†’ Store in Cloudinary β†’ Save to MongoDB β†’ Redirect

Review Submission Flow

Auth Check β†’ Validate Data (Joi) β†’ Create Review β†’ Update Listing β†’ Recalculate Rating

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open Pull Request

πŸ“„ License

This project is licensed under the MIT License - see LICENSE file.


πŸ‘¨β€πŸ’» Author

Sourav Kumar
GitHub: @itssouravkumar


πŸ™ Acknowledgments

Design inspiration from Airbnb | Built with Express.js, MongoDB, and Cloudinary


Made with ❀️ | ⭐ Star this repo if you found it helpful!

About

It's a simple clone of AIRBNB.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors