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