A modern full-stack real estate marketplace built with the MERN stack
Live Demo β’ Report Bug β’ Request Feature
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
- 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
- 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
- Cloudinary Integration - Cloud-based image storage and optimization
- Multiple Images - Upload multiple property images per listing
- Responsive Images - Automatic image optimization for different devices
- Profile Management - Update user information and preferences
- My Listings - View and manage personal property listings
- Contact Landlord - Direct communication with property owners
- 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
| 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 |
| 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 |
- Vercel - Hosting and serverless functions
- MongoDB Atlas - Cloud database
- Cloudinary - Image storage and CDN
- Firebase - Google OAuth
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
- Node.js (v16 or higher)
- npm or yarn
- MongoDB account (MongoDB Atlas)
- Cloudinary account
- Firebase project (for Google OAuth)
-
Clone the repository
git clone https://github.com/naqvi110k/mern-state.git cd mern-state -
Install backend dependencies
npm install
-
Install frontend dependencies
cd client npm install cd ..
-
Set up environment variables
Create a
.envfile 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
.envfile in theclient/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
-
Run the application
Backend (Terminal 1):
npm run dev
Frontend (Terminal 2):
cd client npm run dev -
Access the application
- Frontend:
http://localhost:5173 - Backend API:
http://localhost:3000
- Frontend:
This project is configured for seamless deployment on Vercel with both frontend and backend in a single monorepo.
-
Push to GitHub
git add . git commit -m "Ready for deployment" git push origin main
-
Import to Vercel
- Go to Vercel Dashboard
- Click "New Project"
- Import your GitHub repository
-
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
-
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 -
Deploy π
- Click "Deploy"
- Vercel will build and deploy your application
- Your app will be live at
https://your-project.vercel.app
- 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
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
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
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
- User signs up with email/password or Google OAuth
- JWT token generated and stored in HTTP-only cookie
- Redux state persisted in localStorage
- Protected routes check authentication status
- Automatic token refresh on page reload
- User navigates to "Create Listing" page
- Fills property details (name, description, address, price)
- Uploads images to Cloudinary
- Submits form β API creates listing in MongoDB
- Redirects to property detail page
- 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
Routes API requests to serverless functions:
{
"rewrites": [
{
"source": "/api/(.*)",
"destination": "/api/index.js"
}
]
}Proxies API requests during development:
export default defineConfig({
server: {
proxy: {
"/api": {
target: 'http://localhost:3000',
changeOrigin: true,
}
}
}
})Contributions make the open-source community an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Naqvi110k
- GitHub: @naqvi110k
- Project Link: https://github.com/naqvi110k/mern-state
β Star this repo if you find it useful!
Made with β€οΈ using MERN Stack