Skip to content

Latest commit

Β 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

✈️ Safariz β€” AI-Powered Travel Planner

An intelligent travel planning application that generates personalized day-by-day itineraries using Google Gemini AI, with dynamic images from Unsplash and persistent storage in MongoDB Atlas.

🌐 Live Demo: https://safariz.vercel.app πŸ“¦ GitHub: https://github.com/peyalhasan/Safariz


πŸš€ Features

  • πŸ€– AI-Powered Plans β€” Generate detailed travel itineraries using Google Gemini API
  • πŸ—ΊοΈ Day-by-Day Itinerary β€” Scheduled activities with times, descriptions, and tips
  • πŸ“Έ Dynamic Images β€” Destination photos fetched from Unsplash API
  • πŸ’Ύ Smart Caching β€” Plans saved to MongoDB Atlas to avoid regenerating the same trip
  • πŸ”— Shareable URLs β€” Slug-based URLs like /plan/thailand-tour-4-days
  • πŸ“˜ Facebook Share β€” Share plans with Open Graph meta tags
  • πŸ“± Responsive Design β€” Works on mobile and desktop
  • πŸ” Destination Highlights β€” Key landmarks, food, travel tips, and budget info

πŸ› οΈ Tech Stack

Technology Usage
Next.js 14 (App Router) Frontend & Backend
MongoDB Atlas Cloud Database
Google Gemini API AI Plan Generation
Unsplash API Travel Photos
Tailwind CSS Styling
Mongoose MongoDB ODM
Lucide React Icons
Vercel Deployment

πŸ“ Project Structure

safariz/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ generate-plan/    # POST: Generate travel plan
β”‚   β”‚   └── plans/            # GET: Fetch latest plans
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ plan/             # Plan page components
β”‚   β”‚   └── prompts/          # Home page components
β”‚   β”œβ”€β”€ plan/[slug]/          # Dynamic plan detail page
β”‚   β”œβ”€β”€ not-found.js          # 404 page
β”‚   β”œβ”€β”€ error.jsx             # Error page
β”‚   β”œβ”€β”€ layout.js
β”‚   └── page.js               # Home page
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ gemini.js             # Gemini AI functions
β”‚   β”œβ”€β”€ mongodb.js            # DB connection
β”‚   └── unsplash.js           # Image fetching
β”œβ”€β”€ models/
β”‚   └── plan.js               # Mongoose schema
β”œβ”€β”€ utils/
β”‚   └── index.js              # Utility functions
└── .env                      # Environment variables

βš™οΈ Getting Started

1. Clone the repository

git clone https://github.com/peyalhasan/Safariz.git
cd safariz

2. Install dependencies

npm install

3. Set up environment variables

Create a .env file in the root directory:

MONGODB_URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/travel-planner
GEMINI_API_KEY=your_gemini_api_key
UNSPLASH_ACCESS_KEY=your_unsplash_access_key
NEXT_PUBLIC_BASE_URL=http://localhost:3000

4. Run the development server

npm run dev

Visit http://localhost:3000


πŸ”‘ API Keys Setup

MongoDB Atlas

  1. Go to mongodb.com/atlas
  2. Create a free M0 cluster
  3. Add database user and whitelist IP 0.0.0.0/0
  4. Copy the connection string

Google Gemini API

  1. Go to aistudio.google.com
  2. Create a new project
  3. Generate an API key

Unsplash API

  1. Go to unsplash.com/developers
  2. Create a new application
  3. Copy the Access Key

πŸ”„ How It Works

User enters prompt
       ↓
Check if travel-related (Gemini)
       ↓
Extract destination & days (Gemini)
       ↓
Check MongoDB for existing plan
       ↓
If not found β†’ Generate plan (Gemini)
       ↓
Fetch images from Unsplash
       ↓
Save to MongoDB Atlas
       ↓
Redirect to /plan/{slug}

πŸ“‘ API Endpoints

POST /api/generate-plan

Generate a new travel plan from a prompt.

Request Body:

{
  "prompt": "3 days trip in Thailand"
}

Response:

{
  "slug": "thailand-tour-3-days"
}

GET /api/plans

Fetch the latest 4 generated travel plans.

Response:

{
  "plans": [...]
}

πŸš€ Deployment

This project is deployed on Vercel.

  1. Push to GitHub
  2. Import project on vercel.com
  3. Add environment variables in Vercel dashboard
  4. Update NEXT_PUBLIC_BASE_URL to your deployed URL

πŸ“„ License

This project was built as an assignment for Learn With Sumit.


Made with ❀️ by Peyal Hasan

About

AI-powered travel planner built with Next.js, MongoDB Atlas, Gemini API & Unsplash. Plan your dream trip in seconds! 🌍✈️

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages