StayNest is a full-stack, responsive web application designed to simplify the discovery and booking of homestays. Built with a focus on scalability and user experience, it supports role-based access for guests and property managers, secure JWT-based authentication, real-time availability checks, and robust CRUD operations for listings and bookings. Whether you're implementing features for hosts or enhancing the guest booking flow, StayNest offers a modular, API-driven architecture that makes extension and maintenance straightforward.
-
Smart Property Search
Filter stays by location, price, amenities, eco-friendly tags, and more. -
Real-Time Availability
Live booking availability with instant confirmation. -
Secure Payments & Verified Reviews
Trustworthy bookings with secure payment gateways and real guest reviews. -
Role-Based Access
Separate experiences for Guests and Hosts. -
Booking Notifications
Email confirmations for guests and alerts for property managers. -
Dynamic Pricing & Discounts
Automatic discounts for long stays (weekly/monthly). -
Host Dashboard
Manage your listings, view bookings, and track property performance.
- Next.js 14 with App Router
- Tailwind CSS for styling
- React Hook Form for form handling
- React Hot Toast for notifications
- Node.js, Express
- MongoDB with Mongoose
- JWT for authentication
- Cloudinary for image uploads
- Nodemailer for email notifications
/
├── frontend/
│ ├── app/ # Next.js pages and routes
│ ├── components/ # Reusable UI components (e.g., Hero, FeatureCard)
│ ├── lib/api/ # Centralized API handler and modules
│ ├── public/images/ # Static images
│ └── styles/ # Global styles
└── backend/
├── models/ # Mongoose schemas
├── routes/ # Express API routes
├── controllers/ # Business logic
├── middlewares/ # Auth, validation, etc.
└── utils/ # Utility functions (email, price calculation)
git clone https://github.com/sourabhaprasad/staynest.git
cd staynestFrontend
cd frontend
npm installBackend
cd ../backend
npm installCreate a .env file in both frontend/ and backend/ folders.
Backend .env
PORT=5000
MONGO_URI=your_mongodb_uri
JWT_SECRET=your_jwt_secret
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
EMAIL_USER=your_email@example.com
EMAIL_PASS=your_email_password
Frontend .env.local (optional)
NEXT_PUBLIC_API_BASE_URL=http://localhost:5000/api
Backend
npm run devFrontend
npm run devVisit: http://localhost:3000
Guest
Email: guest@example.com
Password: 123456
Manager
Email: manager@example.com
Password: 123456
POST /api/auth/signup– Register userPOST /api/auth/signin– Login and get tokenPOST /api/properties– Create property (Manager only)GET /api/properties– List all propertiesGET /api/properties/:id– Get property by IDGET /api/bookings/host– Host’s received bookingsPOST /api/bookings– Book property (Guest only)GET /api/bookings/guest– Guest's bookings
Planning to add more features or scale the project? Follow these proven patterns:
Organize API logic into:
routes/– defines endpointscontrollers/– handles logicservices/– reusable business logicutils/– helpers (e.g. price calculation, email)
Example: Want to add wishlist functionality?
- Create:
routes/wishlist.js,controllers/wishlistController.js,models/Wishlist.js
Use middleware to restrict routes:
// checkRole.js
export const checkRole = (allowedRoles) => (req, res, next) => {
if (!allowedRoles.includes(req.user.role)) {
return res.status(403).json({ error: "Forbidden" });
}
next();
};Centralize all API calls:
lib/api/
├── endpoints/ # e.g., bookings.js, auth.js
├── modules/ # exports grouped functionality
├── client.js # fetch wrapper
└── index.js # re-exports all modules
To add new endpoints:
- Define in
endpoints/wishlist.js - Use in components via
import { createWishlist } from "@lib/api"
Create shared components like:
<Button />,<Card />,<PropertyCard /><BookingSection />,<DateRangePicker />
DRY (Don’t Repeat Yourself) design helps in scaling and maintaining UI logic.
- Payment gateway integration (e.g., Stripe)
- Host earnings analytics
- Wishlists and Reviews
- AI Integrations