Skip to content
fastwithkamranPublic

About

PakLands is a Full-Stack MERN web real estate listing platform built to buy, sell, and explore properties online.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

274 Commits

Folders and files

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

Repository files navigation

🏠 PakLands β€” Pakistan Real Estate Platform

Full-Stack MERN property listing platform with Google Auth, cascading location filters, and cloud image storage

Live Demo MIT License React Node.js MongoDB


Introduction

PakLands is a full-stack real estate listing platform built for Pakistanis to buy, sell, and explore properties online. Users can register, upload property listings with multiple images, filter by Province β†’ City β†’ Area, and manage their profile β€” all in a fully responsive UI.

Built to simulate real-world property portals like Zameen.com, this project covers the full development lifecycle: REST API design, JWT authentication, Google OAuth via Firebase, Cloudinary image storage, cascading geographic filters seeded from GeoJSON data, and serverless deployment.

πŸŽ“ Built as a first MERN stack portfolio project β€” started as separate repos, later merged into this monorepo.


Problem Statement

Most beginner real estate projects are static or single-page with hardcoded data. They don't reflect the complexity of real property search across a country as geographically diverse as Pakistan.

PakLands solves this by:

  • Seeding province β†’ city β†’ area location data from a real GeoJSON dataset
  • Giving users a dashboard to post, manage, and delete their own listings
  • Providing buyers a powerful search experience with cascading location dropdowns and property filters
  • Supporting both email/password and Google Sign-In authentication flows

Tech Stack

Frontend

Technology
Framework React 19 + Vite 8
State Management Redux Toolkit v2
Persistence Redux Persist v6
Routing React Router v8
Styling Tailwind CSS v4
Forms React Hook Form v7
Auth Firebase v12 (Google OAuth)
Carousel Swiper.js v14
Notifications React Hot Toast v2
Animations Lottie React
Icons React Icons v5

Backend

Technology
Server Node.js + Express 5
Database MongoDB + Mongoose v9
Auth JWT + HTTP-only cookies
Passwords Node.js Crypto (HMAC-SHA256 + salt)
Images Cloudinary + Multer v2
Validation Validator.js v13
Config dotenv v17

Infrastructure

Technology
Deployment Vercel (frontend + backend serverless)
Database Hosting MongoDB Atlas
Image Storage Cloudinary
Location Data GeoJSON seed file (Pakistan)

System Architecture

graph TD
    subgraph Frontend["πŸ–₯️ Frontend (React + Vite)"]
        A[Property Browser]
        B[User Dashboard]
        C[Auth Pages]
    end

    subgraph Proxy["πŸ”€ Vercel Serverless Proxy"]
        P["frontend/api/proxy.js"]
    end

    subgraph API["βš™οΈ Backend (Node.js + Express)"]
        D[REST API + JWT Middleware]
    end

    subgraph DB["πŸ—„οΈ MongoDB Atlas"]
        H[(Users / Properties / Locations)]
    end

    subgraph External["🌐 External Services"]
        K[Firebase Auth]
        L[Cloudinary]
    end

    A & B & C -->|HTTP requests| P
    P -->|Forwarded requests| D
    C -->|Google OAuth| K
    K -->|ID Token| D
    D --> H
    D --> L
Loading

Features

πŸ” Authentication

  • Email/password signup & login
  • Google Sign-In via Firebase Auth
  • JWT stored in HTTP-only cookies (sameSite: strict)
  • Protected routes via checkForAuthenticationCookie middleware

🏑 Property Listings

  • Create listings with up to 5 image uploads (Cloudinary)
  • Browse all properties on the homepage
  • Full property detail page with Swiper image carousel
  • Filter by Province β†’ City β†’ Area (cascading dropdowns)
  • Toggle: For Sale / For Rent, Furnished, Parking
  • Specify bedrooms, bathrooms, price, and street address
  • View and manage your own listings

πŸ“ Location Intelligence

  • Pakistan-wide location data seeded from a GeoJSON dataset
  • Cascading API: provinces β†’ cities (filtered by province) β†’ areas (filtered by city)
  • Location data indexed for fast query performance

πŸ‘€ User Profile

  • Update name, phone number & avatar (Cloudinary upload)
  • Change password
  • Delete account

🎨 UI / UX

  • Fully responsive design (mobile + desktop)
  • Image carousel with Swiper.js
  • Toast notifications via React Hot Toast
  • Lottie animations for loading states
  • Form validation via React Hook Form
  • Persistent auth state via Redux Persist

Workflows

πŸ” User Authentication Flow

sequenceDiagram
    actor User
    participant Frontend
    participant Backend
    participant Database

    User->>Frontend: Enter credentials / Click Google Sign-In
    alt Email and Password
        Frontend->>Backend: POST /api/user/signup or /api/user/login
        Backend->>Database: Find/create user, validate password
        Database-->>Backend: User document
        Backend-->>Frontend: Set HTTP-only JWT cookie
    else Google OAuth
        Frontend->>Firebase: Trigger Google popup
        Firebase-->>Frontend: Google ID token
        Frontend->>Backend: POST /api/user/google (with ID token)
        Backend->>Database: Find or create user
        Backend-->>Frontend: Set HTTP-only JWT cookie
    end
    Frontend-->>User: Redirect to dashboard
Loading

🏑 Create Property Listing

sequenceDiagram
    actor User
    participant Frontend
    participant Backend
    participant Cloudinary
    participant Database

    User->>Frontend: Fill listing form and upload images
    Frontend->>Backend: POST /api/property/createProperty
    Backend->>Backend: Verify JWT cookie (auth middleware)
    Backend->>Cloudinary: Upload up to 5 property images
    Cloudinary-->>Backend: Image URLs
    Backend->>Database: Save property with image URLs and createdBy user
    Backend-->>Frontend: Property created confirmation
    Frontend-->>User: Success toast and redirect
Loading

πŸ” Property Search and Filter

sequenceDiagram
    actor User
    participant Frontend
    participant Backend
    participant Database

    User->>Frontend: Select Province
    Frontend->>Backend: GET /api/location/get-cities?provinceName=...
    Backend->>Database: Location.find province .distinct city
    Database-->>Frontend: Cities list

    User->>Frontend: Select City
    Frontend->>Backend: GET /api/location/get-areas?cityName=...
    Backend->>Database: Location.find city .distinct area
    Database-->>Frontend: Areas list

    User->>Frontend: Apply filters and search
    Frontend->>Backend: GET /api/property/allProperties?province=...&city=...
    Backend->>Database: Query with filters
    Database-->>Frontend: Matching properties
    Frontend-->>User: Display results
Loading

Database Schema

erDiagram
    USER {
        ObjectId id
        string fullName
        string email
        string salt
        string password
        string avator
        date createdAt
        date updatedAt
    }

    PROPERTY {
        ObjectId id
        string type
        string title
        string price
        string description
        string country
        string province
        string city
        string area
        string street
        array propertyImages
        boolean sell
        boolean rent
        boolean parking
        boolean furnish
        number bathrooms
        number bedrooms
        string phone
        ObjectId createdBy
        date createdAt
        date updatedAt
    }

    LOCATION {
        ObjectId id
        string country
        string province
        string city
        string area
    }

    USER ||--o{ PROPERTY : "creates"
Loading

Project Structure

PAKLANDS/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ delete.js            # Delete user account
β”‚   β”‚   β”œβ”€β”€ handleProperties.js  # Get user/all/single properties, delete property
β”‚   β”‚   β”œβ”€β”€ login.js             # Email/password login
β”‚   β”‚   β”œβ”€β”€ property.js          # Create new property listing
β”‚   β”‚   β”œβ”€β”€ signup.js            # Email signup & Google OAuth
β”‚   β”‚   └── updateProfile.js     # Update profile info & password
β”‚   β”œβ”€β”€ middlewares/
β”‚   β”‚   β”œβ”€β”€ authentication.js    # JWT cookie verification middleware
β”‚   β”‚   └── error.js             # Global error handler
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ location.js          # Province/City/Area schema
β”‚   β”‚   β”œβ”€β”€ property.js          # Property listing schema
β”‚   β”‚   └── user.js              # User schema with HMAC password hashing
β”‚   β”œβ”€β”€ routers/
β”‚   β”‚   β”œβ”€β”€ auth.js              # /api/user β€” signup, login, google, verify, logout, delete
β”‚   β”‚   β”œβ”€β”€ location.js          # /api/location β€” provinces, cities, areas
β”‚   β”‚   β”œβ”€β”€ profile.js           # /api/profile β€” update info & password
β”‚   β”‚   └── property.js          # /api/property β€” create, list, detail, delete
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ auth.js              # JWT token creation helper
β”‚   β”‚   β”œβ”€β”€ filter.js            # Property filter & search query handler
β”‚   β”‚   β”œβ”€β”€ seedLocation.js      # GeoJSON β†’ MongoDB location seeder
β”‚   β”‚   └── location.geojson     # Pakistan GeoJSON location data
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ catchAsyncErrors.js
β”‚   β”‚   └── ErrorHandler.js
β”‚   β”œβ”€β”€ multer.js                # Cloudinary + Multer storage configuration
β”‚   β”œβ”€β”€ index.js                 # Express app entry point
β”‚   └── vercel.json              # Vercel serverless config
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   └── proxy.js             # Vercel serverless proxy (hides backend URL)
β”‚   β”œβ”€β”€ public/                  # Static assets
β”‚   └── src/
β”‚       β”œβ”€β”€ api/                 # apiFetch helper (central fetch wrapper)
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   β”œβ”€β”€ Footer.jsx
β”‚       β”‚   β”œβ”€β”€ Loader.jsx
β”‚       β”‚   β”œβ”€β”€ Navbar.jsx
β”‚       β”‚   └── OAuth.jsx        # Google Sign-In button
β”‚       β”œβ”€β”€ pages/
β”‚       β”‚   β”œβ”€β”€ Home.jsx
β”‚       β”‚   β”œβ”€β”€ Search.jsx       # Property browser with filters
β”‚       β”‚   β”œβ”€β”€ Listing.jsx      # Single property detail page
β”‚       β”‚   β”œβ”€β”€ CreateListing.jsx
β”‚       β”‚   β”œβ”€β”€ UserListings.jsx
β”‚       β”‚   β”œβ”€β”€ Profile.jsx
β”‚       β”‚   β”œβ”€β”€ Login.jsx
β”‚       β”‚   β”œβ”€β”€ Signup.jsx
β”‚       β”‚   └── About.jsx
β”‚       β”œβ”€β”€ redux/               # Redux Toolkit store, slices & Redux Persist config
β”‚       β”œβ”€β”€ routes/              # Protected & public route wrappers
β”‚       β”œβ”€β”€ App.jsx              # Root layout (Navbar + Footer + Outlet)
β”‚       β”œβ”€β”€ firebase.js          # Firebase app config
β”‚       └── main.jsx             # React entry point with router & store providers
β”‚
└── README.md

Getting Started

Prerequisites

  • Node.js v18+
  • MongoDB Atlas account
  • Cloudinary account
  • Firebase project (for Google OAuth)

1. Clone

git clone https://github.com/fastwithkamran/PAKLANDS.git
cd PAKLANDS

2. Set up environment variables

backend/.env

MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key

CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret

NODE_ENV=development
PORT=8000

frontend/.env

VITE_FIREBASE_API_KEY=your_firebase_api_key
VITE_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=your_firebase_project_id
VITE_FIREBASE_STORAGE_BUCKET=your_project.appspot.com
VITE_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
VITE_FIREBASE_APP_ID=your_app_id

3. Install & run

# Backend
cd backend && npm install && npm run dev
# Runs on http://localhost:8000

# Frontend (new terminal)
cd frontend && npm install && npm run dev
# Runs on http://localhost:5173

Open http://localhost:5173 πŸŽ‰


API Routes

Module Base Route Endpoints
Auth /api/user POST /signup, POST /login, POST /google, GET /verify-auth, GET /logout, DELETE /delete/:id
Property /api/property POST /createProperty, GET /allProperties, GET /userProperties/:id, GET /propertyInfo/:id, DELETE /delete/:id
Profile /api/profile PATCH /profile-update/:id, PATCH /update-password/:userId
Location /api/location GET /get-provinces, GET /get-cities?provinceName=, GET /get-areas?cityName=

Challenges & Solutions

Challenge Solution
Pakistan-wide location data Seeded province/city/area hierarchy from a real GeoJSON dataset into MongoDB on first request; indexed city and area fields for fast query performance
Serverless incompatibility with file uploads Configured Multer with multer-storage-cloudinary so images stream directly to Cloudinary β€” no local disk writes needed in Vercel's ephemeral environment
Hiding the backend URL in production Implemented a Vercel serverless proxy (frontend/api/proxy.js) β€” all API calls appear first-party from the browser's perspective, keeping the backend URL private
Cross-origin HTTP-only cookies Set sameSite: strict and secure flags on JWT cookies, and configured CORS with an explicit allowedOrigins allowlist and credentials: true
Google OAuth without a backend SDK Used Firebase client-side popup to obtain a Google ID token, then sent it to a custom /api/user/google endpoint that verifies and creates/fetches the user

Key Learnings

  • End-to-end MERN development with a real project structure and clean separation of concerns
  • JWT authentication with HTTP-only cookies and custom middleware for protected routes
  • Google OAuth with Firebase client + custom backend verification endpoint
  • Cloudinary image storage integrated directly via Multer storage engine
  • Seeding structured geographic data from GeoJSON into MongoDB for cascading UI filters
  • Serverless deployment on Vercel with a proxy pattern to secure the backend API URL

License

MIT License β€” see LICENSE for details.


Author

Kamran Ayaz

GitHub Live Demo


⭐ Star this repo if you found it helpful!

About

PakLands is a Full-Stack MERN web real estate listing platform built to buy, sell, and explore properties online.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages