This repository is organized into two top-level workspaces:
Backend/- Node.js + Express + MongoDB API server, authentication, listing/review services, AI services, and data scripts.Frontend/- React + Vite client application (Frontend/client) with modern UI, routing, auth context, map integrations, and AI UI flows.
StayNJoy is an Airbnb-inspired full-stack web application where users can discover places to stay, view detailed property information, leave reviews, and plan trips with AI assistance.
The project combines a modern MERN architecture with travel-focused AI features. It is designed as both:
- a practical booking/listing platform prototype, and
- a capstone-style showcase of full-stack engineering (auth, CRUD, maps, AI, and responsive UI).
- User accounts and authentication
- Signup/login, JWT-based API auth, protected routes, and authenticated actions.
- Listing management
- Create, view, edit, and delete listings with ownership checks.
- Rich listing details such as price, location, amenities, host info, and image galleries.
- Reviews system
- Users can post and delete their own reviews with author-level permissions.
- Search and discovery
- Category filters, price/sort controls, and natural-language smart search.
- Maps and location features
- Mapbox-powered listing maps and route visualization for trip plans.
- AI-powered travel tools
- AI assistant chat for listing-related questions using data-grounded responses.
- AI trip planner with day-by-day itinerary generation and mapped stops.
- Modern frontend experience
- React + Vite app with responsive layout, improved UI consistency, and reusable component-driven design.
This project evolved in multiple phases instead of being built in one shot:
-
Original stack (EJS + Express + MongoDB)
The app started as a server-rendered Airbnb-style project with EJS views, listing CRUD, reviews, image uploads, and MongoDB models. -
MERN migration
The UI was ported to React + Vite (Frontend/client) while the backend was kept and modernized into JSON-first API routes underBackend/routes/api. -
UX/UI modernization
The frontend was redesigned with Tailwind + shadcn-style components, larger layout widths, better hierarchy, responsive navigation, improved forms, and smoother interactions. -
AI feature rollout
The project added three major AI capabilities:- Natural-language listing smart search
- AI trip planner with day-wise itinerary + Mapbox route/stops
- Data-grounded assistant chat for listing questions
-
Reliability and correctness hardening
Several production-grade fixes were applied:- Better agent context handling across chat turns
- Tool-call fallback behavior for provider errors
- Stricter geocoding/validation to reduce wrong-city map pins
- Route protection and ownership checks on sensitive operations
-
Security and architecture cleanup
JWT-based auth was enforced for protected APIs, CORS/auth flow was aligned, ownership middleware was tightened, and secrets were moved to environment-based handling. -
Repository reorganization
The codebase was restructured into top-levelBackend/andFrontend/folders with this root architecture overview for easier onboarding and maintenance.
- User interacts with React client in
Frontend/client. - Client calls backend APIs under
/api/*. - Express routes in
Backend/routes/apiprocess requests. - MongoDB models in
Backend/modelsprovide data persistence. - AI routes/services in
Backend/routes/api/ai.jsandBackend/services/*enrich search/planning/chat features.
- Entry point:
Backend/app.js- Express bootstrap, MongoDB connection, CORS, JSON parsing.
- Mounts auth/listings/reviews/AI/agent routes.
- Serves SPA build (
client/dist) when present.
- Auth & authorization:
- JWT auth middleware in
Backend/middleware/apiAuth.js. - Ownership checks for listing/review write operations.
- JWT auth middleware in
- Core API routes:
routes/api/auth.js- register/login/me.routes/api/listings.js- listing CRUD + filtering.routes/api/reviews.js- nested review operations.routes/api/ai.js- itinerary planning + smart search.routes/api/agentChat.js- session-aware assistant chat endpoint.
- Models:
staynenjoy_schema.js,reviewSchema.js,userSchema.js.
- Services:
services/aiService.js(Groq itinerary/search logic).services/mcpAgent.js(tool-driven data-grounded assistant).
- Scripts:
scripts/seedListings.js,backfillListings.js,viewListings.jsfor data setup and maintenance.
- Entry & shell:
src/main.jsx-> Router + auth provider.src/App.jsx-> routes + protected routes.src/components/Layout.jsx-> navbar/mobile nav/global chat mount.
- Pages:
- Listings browse/detail/form, login/signup, trip planner.
- State/auth:
src/context/AuthContext.jsxstores user/token and auth lifecycle.
- API layer:
src/api.jswraps fetch, injects JWT Authorization headers, handles 401 logout.
- UI system:
- Tailwind CSS + shadcn UI primitives + custom theme tokens.
- Mapbox components for listing and itinerary maps.
- Smart search (
/api/ai/smart-search): natural language query -> structured filters -> listing results. - Trip planner (
/api/ai/itinerary): tool-assisted place retrieval + validated map stops. - Assistant chat (
/api/agent/chat): data-grounded listing assistant with session memory.
- API auth uses JWT (
Authorization: Bearer <token>). - AI endpoints are protected behind auth middleware.
- Keep secrets in
.envonly; never commit real API keys.
cd Backend
npm install
npm run devcd Frontend/client
npm install
npm run devFrontend dev server proxies
/apito backend. Configure backendFRONTEND_URLand environment variables as needed.
AirBnb-Project/
Backend/
Frontend/