Skip to content

akhil16-svg/Real-Estate-Platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏠 RealEstatePro β€” Full-Stack Property Listing Platform

A full-stack web application where users can browse, list, save, and chat about real estate properties. Built with React, Node.js, MongoDB, Socket.io, and Leaflet maps.


πŸ“‹ Table of Contents


✨ Features

  • User Authentication β€” Register, log in, and log out securely using JWT (stored in HTTP-only cookies)
  • Create Property Listings β€” Add properties with title, price, address, city, bedrooms, bathrooms, coordinates, and images
  • Image Upload β€” Upload multiple property images via Cloudinary
  • Search & Filter β€” Search properties by city, type (buy/rent), property kind, price range, and number of bedrooms
  • Interactive Map β€” View all matching properties on a Leaflet map with clickable pins and popups
  • Save Properties β€” Logged-in users can save and unsave favourite listings
  • Real-Time Chat β€” Message other users in real time using Socket.io
  • User Profile β€” View and update your profile, see your own listings and saved posts

πŸ›  Tech Stack

Layer Technology
Frontend React 18, React Router v6, Vite
Backend Node.js, Express.js
Database MongoDB (via Prisma ORM)
Authentication JWT (JSON Web Tokens) + HTTP-only cookies
Real-Time Chat Socket.io
Maps Leaflet, React-Leaflet
Image Upload Cloudinary
Styling Plain CSS (modular per component)

πŸ“ Project Structure

Real-Estate-Platform/
β”‚
β”œβ”€β”€ frontend/                          # React client (Vite)
β”‚   β”œβ”€β”€ public/                        # Static assets (logo, placeholder images)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/                # Reusable UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ card/                  # Property card shown in listings
β”‚   β”‚   β”‚   β”œβ”€β”€ chat/                  # Real-time chat UI
β”‚   β”‚   β”‚   β”œβ”€β”€ filter/                # Search filter bar
β”‚   β”‚   β”‚   β”œβ”€β”€ layout/                # Page layout wrapper (Navbar + Outlet)
β”‚   β”‚   β”‚   β”œβ”€β”€ map/                   # Leaflet map wrapper
β”‚   β”‚   β”‚   β”œβ”€β”€ navbar/                # Top navigation bar
β”‚   β”‚   β”‚   β”œβ”€β”€ pin/                   # Map pin / popup
β”‚   β”‚   β”‚   β”œβ”€β”€ requireAuth/           # Route guard (redirect if not logged in)
β”‚   β”‚   β”‚   β”œβ”€β”€ searchBar/             # Home page search bar
β”‚   β”‚   β”‚   └── slider/                # Image slider / lightbox
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”‚   β”œβ”€β”€ AuthContext.jsx        # Global auth state (currentUser)
β”‚   β”‚   β”‚   └── SocketContext.jsx      # Socket.io connection & online users
β”‚   β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”‚   β”œβ”€β”€ apiRequest.js          # Axios instance with base URL & credentials
β”‚   β”‚   β”‚   └── loaders.js             # React Router data loaders
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ homePage/              # Landing page with search
β”‚   β”‚   β”‚   β”œβ”€β”€ listPage/              # Property list + map
β”‚   β”‚   β”‚   β”œβ”€β”€ singlePage/            # Single property detail
β”‚   β”‚   β”‚   β”œβ”€β”€ profilePage/           # User profile, listings, saved posts, chat
β”‚   β”‚   β”‚   β”œβ”€β”€ profileUpdatePage/     # Edit profile form
β”‚   β”‚   β”‚   β”œβ”€β”€ newPostPage/           # Create new property listing
β”‚   β”‚   β”‚   β”œβ”€β”€ updatePostPage/        # Edit existing listing
β”‚   β”‚   β”‚   β”œβ”€β”€ login/                 # Login form
β”‚   β”‚   β”‚   └── register/              # Registration form
β”‚   β”‚   β”œβ”€β”€ App.jsx                    # Route definitions
β”‚   β”‚   β”œβ”€β”€ main.jsx                   # React entry point
β”‚   β”‚   └── index.css                  # Global CSS variables and resets
β”‚   β”œβ”€β”€ .env.example                   # Frontend env template
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js
β”‚
β”œβ”€β”€ backend/                           # Express API server
β”‚   β”œβ”€β”€ controllers/                   # Business logic
β”‚   β”‚   β”œβ”€β”€ auth.controller.js         # Register, login, logout
β”‚   β”‚   β”œβ”€β”€ post.controller.js         # CRUD for property listings
β”‚   β”‚   β”œβ”€β”€ user.controller.js         # User profile, saved posts, notifications
β”‚   β”‚   β”œβ”€β”€ chat.controller.js         # Chat rooms
β”‚   β”‚   └── message.controller.js      # Messages within chats
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   └── verifyToken.js             # JWT verification middleware
β”‚   β”œβ”€β”€ routes/                        # Express routers
β”‚   β”‚   β”œβ”€β”€ auth.route.js
β”‚   β”‚   β”œβ”€β”€ post.route.js
β”‚   β”‚   β”œβ”€β”€ user.route.js
β”‚   β”‚   β”œβ”€β”€ chat.route.js
β”‚   β”‚   └── message.route.js
β”‚   β”œβ”€β”€ prisma/
β”‚   β”‚   └── schema.prisma              # Database schema (MongoDB via Prisma)
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   └── prisma.js                  # Prisma client singleton
β”‚   β”œβ”€β”€ socket/
β”‚   β”‚   └── index.js                   # Socket.io server setup
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   └── cloudinary.js              # Cloudinary configuration & upload helper
β”‚   β”œβ”€β”€ .env.example                   # Backend env template
β”‚   β”œβ”€β”€ app.js                         # Express app entry point
β”‚   └── package.json
β”‚
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── ci.yml                     # GitHub Actions CI (install + build)
β”‚
β”œβ”€β”€ .gitignore
└── README.md

βš™οΈ How It Works

User Authentication

  1. A new user fills in the Register form (username, email, password).
  2. The backend hashes the password with bcrypt and stores the user in MongoDB.
  3. On Login, the backend verifies the password, creates a JWT, and sends it in an HTTP-only cookie.
  4. The frontend stores the user object in localStorage via AuthContext.
  5. Protected routes are guarded by the RequireAuth component β€” if no user is logged in, they are redirected to /login.
  6. The JWT cookie is verified on every protected API call by the verifyToken middleware.

Creating a Property Listing

  1. A logged-in user opens the Add Property page.
  2. They fill in details (title, price, address, bedrooms, etc.) and upload images.
  3. Images are uploaded directly to Cloudinary from the browser; the returned secure URLs are stored.
  4. The form data is sent as a POST /api/posts request.
  5. The backend creates a Post and a linked PostDetail in MongoDB via Prisma.

Uploading Images

  • The frontend sends each image file directly to Cloudinary's upload API using an unsigned upload preset.
  • Cloudinary returns a secure_url which is stored in the post's images array.
  • No image files are stored on the server.

Searching & Filtering Properties

  1. The user types a city or selects filters (type, property kind, price range, bedrooms) on the List page.
  2. Filter values are stored as URL query parameters.
  3. React Router's data loader fetches GET /api/posts?city=...&type=... with those params.
  4. The backend queries MongoDB using Prisma's where clauses and returns matching posts.

Showing Properties on the Map

  • Every property stores latitude and longitude fields.
  • The Map component renders a Leaflet MapContainer and places a Marker (pin) for each property.
  • Clicking a pin shows a popup with the property image, title, and price linking to the detail page.

Real-Time Chat

  1. When a logged-in user opens their Profile, existing chats are loaded from the API.
  2. Clicking a chat opens the Chat component and loads the message history.
  3. On mount, the client emits newUser to the Socket.io server with their user ID.
  4. Sending a message calls POST /api/messages/:chatId and then emits sendMessage over the socket.
  5. The receiver's client listens for getMessage events and appends the new message instantly.

πŸš€ Setup Instructions

Prerequisites

  • Node.js v22 LTS (use nvm: nvm install && nvm use β€” the .nvmrc pins v22)
  • A MongoDB Atlas cluster (free tier works)
  • A Cloudinary account (free tier works)

Note on Node version: This project targets Node.js v22 LTS. The backend uses bcryptjs (pure-JS) instead of bcrypt so there are no native binary dependencies and no url.parse() deprecation warnings on Node 24+.

1. Clone the repository

git clone https://github.com/akhil16-svg/Real-Estate-Platform.git
cd Real-Estate-Platform

2. Set up the Backend

cd backend
npm install

Copy the example environment file and fill in your values:

cp .env.example .env

Generate the Prisma client:

npx prisma generate

Start the backend server:

npm run dev      # development (nodemon, auto-restart)
# -- or --
npm start        # production

# Server + Socket.io both run on http://localhost:8800

3. Set up the Frontend

Open a new terminal:

cd frontend
npm install

Copy the example environment file:

cp .env.example .env

Start the frontend dev server:

npm run dev
# App runs on http://localhost:5173

πŸ” Environment Variables

backend/.env

Variable Description
DATABASE_URL MongoDB connection string from Atlas
JWT_SECRET_KEY A long, random secret string for signing JWTs and CSRF tokens
CLOUDINARY_CLOUD_NAME Your Cloudinary cloud name
CLOUDINARY_API_KEY Your Cloudinary API key
CLOUDINARY_API_SECRET Your Cloudinary API secret
CLIENT_URL Frontend URL for CORS (e.g. http://localhost:5173)
PORT Port for the backend server (default: 8800)

frontend/.env

Variable Description
VITE_API_URL Backend API base URL (e.g. http://localhost:8800/api)
VITE_SOCKET_URL Backend Socket.io URL (e.g. http://localhost:8800)
VITE_CLOUDINARY_NAME Your Cloudinary cloud name
VITE_CLOUDINARY_PRESET Your Cloudinary unsigned upload preset name

πŸ”Œ API Overview

All routes are prefixed with /api.

Auth β€” /api/auth

Method Endpoint Description Auth required
POST /register Create a new user account No
POST /login Log in and receive a JWT cookie No
POST /logout Clear the JWT cookie No

Posts β€” /api/posts

Method Endpoint Description Auth required
GET / Get all posts (supports query filters) No
GET /:id Get a single post with details No
POST / Create a new property listing βœ… Yes
PUT /:id Update a listing (owner only) βœ… Yes
DELETE /:id Delete a listing (owner only) βœ… Yes

Users β€” /api/users

Method Endpoint Description Auth required
GET /:id Get user info βœ… Yes
PUT /:id Update profile (own account only) βœ… Yes
DELETE /:id Delete account (own account only) βœ… Yes
POST /save Save or unsave a post βœ… Yes
GET /profilePosts Get own posts and saved posts βœ… Yes
GET /notification Get unread chat count βœ… Yes

Chats β€” /api/chats

Method Endpoint Description Auth required
GET / Get all chats for current user βœ… Yes
GET /:id Get a single chat with messages βœ… Yes
POST / Start a new chat βœ… Yes
PUT /:id Mark chat as read βœ… Yes

Messages β€” /api/messages

Method Endpoint Description Auth required
POST /:chatId Send a message in a chat βœ… Yes

πŸ“Έ Screenshots

🏠 Home Page

Home Page

πŸ“‹ Property List + Map

Property List

🏒 Property Detail

Property Detail

πŸ‘€ User Profile + Real-time Chat

User Profile

πŸ” Login & Register

Login and Register

βž• Add New Property

Add New Property

Page Preview
Home coming soon
Property List coming soon
Property Detail coming soon
User Profile coming soon
Real-Time Chat coming soon

πŸ”­ Future Improvements

  • Pagination β€” Load properties in batches instead of all at once
  • Advanced filters β€” Add floor count, furnished/unfurnished, parking, etc.
  • Image compression β€” Compress images before uploading to Cloudinary
  • Admin dashboard β€” Manage all users and listings
  • Email notifications β€” Notify users when they receive a new message
  • Deployment β€” Deploy frontend to Vercel and backend to Railway or Render
  • Unit & integration tests β€” Add test coverage with Vitest and Supertest

πŸ“„ License

This project is open source and available under the MIT License.

About

Full-stack real estate platform for property listings, search workflows, and responsive web experiences.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages