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.
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
| 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 |
| 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 |
| Technology | |
|---|---|
| Deployment | Vercel (frontend + backend serverless) |
| Database Hosting | MongoDB Atlas |
| Image Storage | Cloudinary |
| Location Data | GeoJSON seed file (Pakistan) |
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
- Email/password signup & login
- Google Sign-In via Firebase Auth
- JWT stored in HTTP-only cookies (
sameSite: strict) - Protected routes via
checkForAuthenticationCookiemiddleware
- 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
- 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
- Update name, phone number & avatar (Cloudinary upload)
- Change password
- Delete account
- 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
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
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
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
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"
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
- Node.js v18+
- MongoDB Atlas account
- Cloudinary account
- Firebase project (for Google OAuth)
git clone https://github.com/fastwithkamran/PAKLANDS.git
cd PAKLANDSbackend/.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=8000frontend/.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# 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:5173Open http://localhost:5173 π
| 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= |
| 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 |
- 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
MIT License β see LICENSE for details.
Kamran Ayaz