Skip to content

About

A comprehensive real estate platform that enables users to browse, list, and manage properties with a seamless user experience. Built with modern technologies and best practices, this application features secure authentication, cloud-based image management, and a responsive design.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏑 Real Estate Marketplace

MERN Stack React Node.js MongoDB Vercel

A modern full-stack real estate marketplace built with the MERN stack

Live Demo β€’ Report Bug β€’ Request Feature


🌟 Overview

A comprehensive real estate platform that enables users to browse, list, and manage properties with a seamless user experience. Built with modern technologies and best practices, this application features secure authentication, cloud-based image management, and a responsive design.

πŸ”— Live Application: https://sman-state.vercel.app


✨ Key Features

πŸ” Authentication & Security

  • JWT-based Authentication - Secure token-based login system
  • Google OAuth Integration - Quick sign-in with Google accounts
  • Protected Routes - Private routes for authenticated users only
  • Password Encryption - Bcrypt hashing for secure password storage

🏘️ Property Management

  • Create Listings - Add new properties with detailed information
  • Edit & Delete - Full CRUD operations on user's own listings
  • Advanced Search - Filter by location, price, type, and amenities
  • Property Details - Comprehensive property information pages

πŸ–ΌοΈ Media Handling

  • Cloudinary Integration - Cloud-based image storage and optimization
  • Multiple Images - Upload multiple property images per listing
  • Responsive Images - Automatic image optimization for different devices

πŸ‘€ User Dashboard

  • Profile Management - Update user information and preferences
  • My Listings - View and manage personal property listings
  • Contact Landlord - Direct communication with property owners

🎨 Modern UI/UX

  • Responsive Design - Mobile-first approach with Tailwind CSS
  • Swiper Carousel - Beautiful image galleries
  • Toast Notifications - Real-time feedback with react-hot-toast
  • Loading States - Smooth loading indicators and transitions

πŸ› οΈ Tech Stack

Frontend

Technology Purpose
React 18 UI library with modern hooks
Vite Fast build tool and dev server
Redux Toolkit State management
Redux Persist Persist Redux state across sessions
React Router v7 Client-side routing
Tailwind CSS Utility-first CSS framework
Axios HTTP client for API requests
Firebase Google authentication
Swiper Modern touch slider
Lucide React Beautiful icon library

Backend

Technology Purpose
Node.js JavaScript runtime
Express.js Web application framework
MongoDB NoSQL database
Mongoose MongoDB ODM
JWT JSON Web Token authentication
Bcrypt Password hashing
Cookie Parser Parse cookies in requests
Dotenv Environment variable management

Cloud Services

  • Vercel - Hosting and serverless functions
  • MongoDB Atlas - Cloud database
  • Cloudinary - Image storage and CDN
  • Firebase - Google OAuth

πŸ“ Project Structure

mern-state/
β”œβ”€β”€ api/                      # Backend source code
β”‚   β”œβ”€β”€ controllers/          # Route controllers
β”‚   β”‚   β”œβ”€β”€ auth.controller.js
β”‚   β”‚   β”œβ”€β”€ listing.controller.js
β”‚   β”‚   └── user.controller.js
β”‚   β”œβ”€β”€ models/              # Database models
β”‚   β”‚   β”œβ”€β”€ user.model.js
β”‚   β”‚   └── listing.model.js
β”‚   β”œβ”€β”€ routes/              # API routes
β”‚   β”‚   β”œβ”€β”€ auth.route.js
β”‚   β”‚   β”œβ”€β”€ listing.route.js
β”‚   β”‚   └── user.route.js
β”‚   β”œβ”€β”€ utils/               # Utility functions
β”‚   β”‚   β”œβ”€β”€ error.js
β”‚   β”‚   └── verifyUser.js
β”‚   └── index.js             # Express app entry point
β”œβ”€β”€ client/                  # Frontend source code
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ Component/       # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ Header.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ OAuth.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ PrivateRoute.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ListingItem.jsx
β”‚   β”‚   β”‚   └── Contact.jsx
β”‚   β”‚   β”œβ”€β”€ pages/           # Page components
β”‚   β”‚   β”‚   β”œβ”€β”€ Home.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ SignIn.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ SignUp.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Profile.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ CreateListing.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ UpdateListing.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Listing.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Search.jsx
β”‚   β”‚   β”‚   └── About.jsx
β”‚   β”‚   β”œβ”€β”€ redux/           # Redux store
β”‚   β”‚   β”‚   β”œβ”€β”€ store.js
β”‚   β”‚   β”‚   └── user/
β”‚   β”‚   β”‚       └── userSlice.js
β”‚   β”‚   β”œβ”€β”€ App.jsx          # Main app component
β”‚   β”‚   β”œβ”€β”€ main.jsx         # Entry point
β”‚   β”‚   β”œβ”€β”€ firebase.js      # Firebase config
β”‚   β”‚   └── index.css        # Global styles
β”‚   β”œβ”€β”€ public/              # Static assets
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ vite.config.js       # Vite configuration
β”‚   β”œβ”€β”€ tailwind.config.js   # Tailwind configuration
β”‚   └── package.json
β”œβ”€β”€ vercel.json              # Vercel deployment config
β”œβ”€β”€ package.json             # Root package.json
β”œβ”€β”€ .gitignore
└── README.md

πŸš€ Getting Started

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • MongoDB account (MongoDB Atlas)
  • Cloudinary account
  • Firebase project (for Google OAuth)

Installation

  1. Clone the repository

    git clone https://github.com/naqvi110k/mern-state.git
    cd mern-state
  2. Install backend dependencies

    npm install
  3. Install frontend dependencies

    cd client
    npm install
    cd ..
  4. Set up environment variables

    Create a .env file in the root directory:

    # MongoDB
    MONGO=your_mongodb_connection_string
    
    # JWT
    JWT_SECRET=your_jwt_secret_key
    
    # Cloudinary (Backend)
    CLOUDINARY_CLOUD_NAME=your_cloudinary_name
    CLOUDINARY_API_KEY=your_cloudinary_api_key
    CLOUDINARY_API_SECRET=your_cloudinary_api_secret

    Create a .env file in the client/ directory:

    # Firebase (Google OAuth)
    VITE_FIREBASE_API_KEY=your_firebase_api_key
    VITE_FIREBASE_AUTH_DOMAIN=your_firebase_auth_domain
    VITE_FIREBASE_PROJECT_ID=your_firebase_project_id
    VITE_FIREBASE_STORAGE_BUCKET=your_firebase_storage_bucket
    VITE_FIREBASE_MESSAGING_SENDER_ID=your_firebase_sender_id
    VITE_FIREBASE_APP_ID=your_firebase_app_id
  5. Run the application

    Backend (Terminal 1):

    npm run dev

    Frontend (Terminal 2):

    cd client
    npm run dev
  6. Access the application

    • Frontend: http://localhost:5173
    • Backend API: http://localhost:3000

☁️ Deployment

Deploy to Vercel

This project is configured for seamless deployment on Vercel with both frontend and backend in a single monorepo.

Quick Deploy

  1. Push to GitHub

    git add .
    git commit -m "Ready for deployment"
    git push origin main
  2. Import to Vercel

  3. Configure Build Settings

    • Framework Preset: Vite (auto-detected)
    • Root Directory: Leave as root
    • Build Command: cd client && npm install && npm run build
    • Output Directory: client/dist
    • Install Command: npm install
  4. Add Environment Variables

    In Vercel Dashboard β†’ Settings β†’ Environment Variables, add:

    MONGO=your_mongodb_connection_string
    JWT_SECRET=your_jwt_secret_key
    CLOUDINARY_CLOUD_NAME=your_cloudinary_name
    CLOUDINARY_API_KEY=your_cloudinary_api_key
    CLOUDINARY_API_SECRET=your_cloudinary_api_secret
    VITE_FIREBASE_API_KEY=your_firebase_api_key
    VITE_FIREBASE_AUTH_DOMAIN=your_auth_domain
    VITE_FIREBASE_PROJECT_ID=your_project_id
    VITE_FIREBASE_STORAGE_BUCKET=your_storage_bucket
    VITE_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
    VITE_FIREBASE_APP_ID=your_app_id
    
  5. Deploy πŸš€

    • Click "Deploy"
    • Vercel will build and deploy your application
    • Your app will be live at https://your-project.vercel.app

How It Works

  • Frontend: Built with Vite and served from client/dist
  • Backend: Runs as Vercel serverless functions at /api/*
  • Routing: Configured in vercel.json
  • API Requests: Frontend /api/* routes automatically proxy to backend

πŸ“š API Endpoints

Authentication

POST   /api/auth/signup      - Register new user
POST   /api/auth/signin      - Login user
POST   /api/auth/google      - Google OAuth login
GET    /api/auth/signout     - Logout user

User

GET    /api/user/:id         - Get user profile
POST   /api/user/update/:id  - Update user profile
DELETE /api/user/delete/:id  - Delete user account
GET    /api/user/listings/:id - Get user's listings

Listings

POST   /api/listing/create   - Create new listing
DELETE /api/listing/delete/:id - Delete listing
POST   /api/listing/update/:id - Update listing
GET    /api/listing/get/:id  - Get single listing
GET    /api/listing/get      - Search listings with filters

🎯 Features in Detail

User Authentication Flow

  1. User signs up with email/password or Google OAuth
  2. JWT token generated and stored in HTTP-only cookie
  3. Redux state persisted in localStorage
  4. Protected routes check authentication status
  5. Automatic token refresh on page reload

Property Listing Flow

  1. User navigates to "Create Listing" page
  2. Fills property details (name, description, address, price)
  3. Uploads images to Cloudinary
  4. Submits form β†’ API creates listing in MongoDB
  5. Redirects to property detail page

Search & Filter

  • Text Search: Property name and description
  • Type Filter: Rent, Sale, Offer
  • Amenities: Parking, Furnished
  • Sort Options: Price (high/low), Latest, Oldest
  • Pagination: Load more results

πŸ”§ Configuration Files

vercel.json

Routes API requests to serverless functions:

{
  "rewrites": [
    {
      "source": "/api/(.*)",
      "destination": "/api/index.js"
    }
  ]
}

vite.config.js

Proxies API requests during development:

export default defineConfig({
  server: {
    proxy: {
      "/api": {
        target: 'http://localhost:3000',
        changeOrigin: true,
      }
    }
  }
})

🀝 Contributing

Contributions make the open-source community an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

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


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

Naqvi110k


πŸ™ Acknowledgments


⭐ Star this repo if you find it useful!

Made with ❀️ using MERN Stack

About

A comprehensive real estate platform that enables users to browse, list, and manage properties with a seamless user experience. Built with modern technologies and best practices, this application features secure authentication, cloud-based image management, and a responsive design.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages