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
- π€ 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
| 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 |
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
git clone https://github.com/peyalhasan/Safariz.git
cd safariznpm installCreate 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:3000npm run devVisit http://localhost:3000
- Go to mongodb.com/atlas
- Create a free M0 cluster
- Add database user and whitelist IP
0.0.0.0/0 - Copy the connection string
- Go to aistudio.google.com
- Create a new project
- Generate an API key
- Go to unsplash.com/developers
- Create a new application
- Copy the Access Key
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}
Generate a new travel plan from a prompt.
Request Body:
{
"prompt": "3 days trip in Thailand"
}Response:
{
"slug": "thailand-tour-3-days"
}Fetch the latest 4 generated travel plans.
Response:
{
"plans": [...]
}This project is deployed on Vercel.
- Push to GitHub
- Import project on vercel.com
- Add environment variables in Vercel dashboard
- Update
NEXT_PUBLIC_BASE_URLto your deployed URL
This project was built as an assignment for Learn With Sumit.
Made with β€οΈ by Peyal Hasan