Skip to content

chayan-1906/Airbnb-Next.js

Repository files navigation

🏠 Airbnb Clone - Full-Stack Property Rental Platform

Next.js React MongoDB Prisma NextAuth Tailwind CSS

Full-stack Airbnb clone built with Next.js 14, featuring property listings, booking system, user authentication, search filters, favorites, and interactive maps. πŸ” NextAuth β€’ πŸ—„οΈ MongoDB β€’ 🎨 Tailwind CSS β€’ πŸ“± Responsive Design

logo

✨ Features

  • 🏠 Property Listings - Create, view, and manage property listings πŸ“
  • πŸ” Advanced Search - Filter by location, dates, guests, and categories 🎯
  • πŸ“… Booking System - Complete reservation management with calendar πŸ“†
  • πŸ’– Favorites - Save and manage favorite properties ❀️
  • πŸ” Authentication - NextAuth with Google, GitHub, and email login πŸ”’
  • πŸ—ΊοΈ Interactive Maps - Leaflet integration for property locations πŸ“
  • πŸ‘€ User Dashboard - Manage trips, properties, and reservations 🏒
  • πŸ“± Responsive Design - Mobile-first approach with Tailwind CSS πŸ“²
  • 🎨 Modern UI - Clean, intuitive interface with smooth animations ✨
  • 🌐 Multi-Provider Auth - Social login integration πŸ”—

πŸ“± Screenshots

Login Modal Listings
Listing Details Trips
Favorites Airbnb Your Home

πŸ—οΈ Tech Stack

πŸ–₯️ Frontend

  • βš›οΈ Next.js 14.2.4 - React framework πŸš€
  • πŸ“˜ React 18 - UI library 🎨
  • 🎯 Tailwind CSS 3.4.1 - Utility-first CSS πŸ’…
  • 🎭 React Icons 5.2.1 - Icon library 🌟

πŸ—„οΈ Backend & Database

  • πŸ”— Prisma 5.15.1 - Database ORM πŸ› οΈ
  • πŸ“Š MongoDB - NoSQL database πŸƒ
  • πŸ” NextAuth 4.24.7 - Authentication πŸ‘€
  • πŸ”’ bcrypt 5.1.1 - Password hashing πŸ”

🌍 Maps & Location

  • πŸ—ΊοΈ Leaflet 1.9.4 - Interactive maps πŸ“
  • βš›οΈ React Leaflet 4.2.1 - React wrapper πŸ—ΊοΈ
  • 🌎 World Countries 5.0.0 - Country data 🌍

🎨 UI Components

  • πŸ“ React Hook Form 7.52.0 - Form management πŸ“‹
  • πŸ“… React Date Range 2.0.1 - Date picker πŸ“†
  • 🎨 React Select 5.8.0 - Select components 🎯
  • πŸ”₯ React Hot Toast 2.4.1 - Toast notifications 🍞
  • πŸŒ€ React Spinners 0.14.1 - Loading indicators ⏳

πŸ“¦ Utilities

  • πŸ”„ Axios 1.7.2 - HTTP client 🌐
  • πŸ“… Date-fns 3.6.0 - Date utilities πŸ•°οΈ
  • πŸ” Query String 9.0.0 - URL parsing πŸ”—
  • πŸͺ Zustand 4.5.2 - State management πŸ“¦
  • ☁️ Cloudinary 6.6.2 - Image hosting πŸ“Έ

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ 🟒
  • MongoDB database πŸ—„οΈ
  • Cloudinary account ☁️
  • NextAuth providers (Google, GitHub) πŸ”

Installation

  1. Clone repository πŸ“₯

    git clone https://github.com/chayan-1906/Airbnb-Next.js.git
    cd Airbnb-Next.js
  2. Install dependencies πŸ“¦

    npm install
  3. Environment setup βš™οΈ

    cp .env.example .env
  4. Configure environment πŸ”§

    DATABASE_URL="mongodb+srv://..."
    NEXTAUTH_SECRET="your-secret-key"
    NEXTAUTH_URL="http://localhost:3000"
    
    GITHUB_ID="your-github-id"
    GITHUB_SECRET="your-github-secret"
    
    GOOGLE_CLIENT_ID="your-google-client-id"
    GOOGLE_CLIENT_SECRET="your-google-client-secret"
    
    NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME="your-cloud-name"
    NEXT_PUBLIC_CLOUDINARY_API_KEY="your-cloudinary-api-key"
    CLOUDINARY_API_SECRET="your-cloudinary-api-secret"
  5. Database setup πŸ—„οΈ

    npx prisma db push
  6. Start development server πŸš€

    npm run dev

πŸ—οΈ Project Structure

app/
β”œβ”€β”€ api/                 # API routes
β”‚   β”œβ”€β”€ auth/           # NextAuth configuration
β”‚   β”œβ”€β”€ listings/       # Property CRUD operations
β”‚   β”œβ”€β”€ reservations/   # Booking management
β”‚   └── favorites/      # Favorites management
β”œβ”€β”€ components/         # Reusable components
β”‚   β”œβ”€β”€ inputs/         # Form components
β”‚   β”œβ”€β”€ listings/       # Property components
β”‚   β”œβ”€β”€ modals/         # Modal components
β”‚   └── navbar/         # Navigation components
β”œβ”€β”€ hooks/              # Custom React hooks
β”œβ”€β”€ libs/               # Utility libraries
β”œβ”€β”€ providers/          # Context providers
β”œβ”€β”€ favorites/          # Favorites page
β”œβ”€β”€ trips/              # User trips
β”œβ”€β”€ properties/         # User properties
└── reservations/       # User reservations

πŸ”§ Core Features

🏠 Property Management

  • Create Listing - Multi-step form with image upload πŸ“Έ
  • Category Selection - Beach, mountain, city, etc. πŸ–οΈ
  • Location Picker - Interactive map integration πŸ—ΊοΈ
  • Pricing & Details - Room count, amenities, description πŸ’°

πŸ” Search & Filtering

  • Location Search - Country/city selection 🌍
  • Date Range - Check-in/out calendar πŸ“…
  • Guest Count - Adults, children, infants πŸ‘₯
  • Category Filter - Property type filtering 🏠

πŸ“… Booking System

  • Calendar Integration - Available dates display πŸ“†
  • Price Calculation - Dynamic pricing with fees πŸ’΅
  • Reservation Management - Book, cancel, view trips 🎫
  • Conflict Prevention - Prevent double bookings ⚠️

πŸ” Authentication

  • NextAuth Integration - Multiple providers πŸ”—
  • User Sessions - Secure session management πŸ”’
  • Protected Routes - Authentication guards πŸ›‘οΈ
  • User Profiles - Profile management πŸ‘€

πŸ—„οΈ Database Schema

User Model

{
  id: String            // MongoDB ObjectId
  name: String?         // User display name
  email: String         // Unique email
  image: String?        // Profile picture URL
  hashedPassword: String? // Encrypted password
  favoriteIds: String[] // Favorite property IDs
  createdAt: DateTime   // Account creation
  updatedAt: DateTime   // Last update
}

Listing Model

{
  id: String            // MongoDB ObjectId
  title: String         // Property title
  description: String   // Property description
  imageSrc: String      // Main image URL
  category: String      // Property category
  roomCount: Int        // Number of rooms
  bathroomCount: Int    // Number of bathrooms
  guestCount: Int       // Max guests
  locationValue: String // Country/location
  price: Int           // Price per night
  userId: String       // Owner ID
  createdAt: DateTime  // Creation date
}

Reservation Model

{
  id: String           // MongoDB ObjectId
  userId: String       // Guest ID
  listingId: String    // Property ID
  startDate: DateTime  // Check-in date
  endDate: DateTime    // Check-out date
  totalPrice: Int      // Total cost
  createdAt: DateTime  // Booking date
}

πŸ› οΈ API Endpoints

Method Endpoint Description Auth
GET /api/listings Get all listings ❌
POST /api/listings Create new listing βœ…
DELETE /api/listings/[id] Delete listing βœ…
GET /api/reservations Get user reservations βœ…
POST /api/reservations Create reservation βœ…
DELETE /api/reservations/[id] Cancel reservation βœ…
POST /api/favorites/[id] Add to favorites βœ…
DELETE /api/favorites/[id] Remove from favorites βœ…
POST /api/register User registration ❌

🎨 UI Components

🏠 Listing Components

  • ListingCard - Property card with image, price, location 🏑
  • ListingHead - Property header with title, location, actions πŸ“‹
  • ListingInfo - Property details, host info, amenities πŸ“
  • ListingReservation - Booking form with calendar πŸ“…

πŸ”§ Input Components

  • Input - Styled form inputs with validation πŸ“
  • Counter - Number input with increment/decrement πŸ”’
  • ImageUpload - Cloudinary image upload πŸ“Έ
  • Calendar - Date range picker πŸ“…
  • CategoryInput - Category selection 🏷️

🎭 Modal Components

  • LoginModal - User authentication πŸ”
  • RegisterModal - User registration πŸ“
  • RentModal - Property creation wizard 🏠
  • SearchModal - Advanced search filters πŸ”

πŸ“± Responsive Design

πŸ“² Mobile Features

  • Touch-friendly interface πŸ‘†
  • Collapsible navigation πŸ“±
  • Optimized images πŸ–ΌοΈ
  • Swipe gestures πŸ‘‹

πŸ–₯️ Desktop Features

  • Hover effects πŸ–±οΈ
  • Keyboard navigation ⌨️
  • Multi-column layouts πŸ“Š
  • Sidebar navigation πŸ“‹

πŸ”’ Security Features

  • Password hashing with bcrypt πŸ”
  • CSRF protection via NextAuth πŸ›‘οΈ
  • Input validation and sanitization πŸ”
  • Rate limiting on API endpoints ⚑
  • Secure headers configuration πŸ”’

πŸ“ˆ Performance

  • Server-side rendering for SEO πŸš€
  • Image optimization with Next.js πŸ–ΌοΈ
  • Code splitting for faster loads πŸ“¦
  • Caching strategies πŸ’Ύ
  • Lazy loading components ⏳

πŸ”§ Development Scripts

# Development server
npm run dev

# Build for production
npm run build

# Start production server
npm start

# Generate Prisma client
npm run prisma:generate

# Run on custom port
npm run serve

πŸš€ Deployment

Vercel Deployment

  1. Connect GitHub repository πŸ”—
  2. Configure environment variables βš™οΈ
  3. Deploy automatically on push πŸš€

Environment Variables

  • DATABASE_URL - MongoDB connection string
  • NEXTAUTH_SECRET - NextAuth secret key
  • NEXTAUTH_URL - Application URL
  • GITHUB_ID - GitHub OAuth app ID
  • GITHUB_SECRET - GitHub OAuth secret
  • GOOGLE_CLIENT_ID - Google OAuth client ID
  • GOOGLE_CLIENT_SECRET - Google OAuth secret
  • NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME - Cloudinary cloud name
  • NEXT_PUBLIC_CLOUDINARY_API_KEY - Cloudinary API Key
  • CLOUDINARY_API_SECRET - Cloudinary API Secret

πŸ“‹ Requirements

  • Node.js: β‰₯18.0.0 🟒
  • MongoDB: β‰₯5.0 πŸ—„οΈ
  • Memory: 1GB RAM minimum πŸ’Ύ
  • Storage: 2GB disk space πŸ’Ώ

🀝 Contributing

  1. Fork repository 🍴
  2. Create feature branch (git checkout -b feature/amazing-feature) 🌟
  3. Commit changes (git commit -m 'Add amazing feature') πŸ’Ύ
  4. Push branch (git push origin feature/amazing-feature) πŸš€
  5. Open Pull Request πŸ“

πŸ› Known Issues

  • Map rendering on mobile devices may be slow πŸ—ΊοΈ
  • Image upload requires stable internet connection πŸ“Έ

πŸ‘¨β€πŸ’» Author

Padmanabha Das

🌟 Show Your Support

Give a ⭐️ if this project helped you! πŸ™


Made with ❀️ by Padmanabha Das

⭐ Star this repo if you found it helpful!

About

🏠 Full-stack Airbnb clone built with Next.js 14, featuring property listings, booking system, user authentication, search filters, favorites, and interactive maps

Topics

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors