A friendly, light-themed travel planner that builds weather-smart AI itineraries for any city worldwide — with live destination photos as you search.
- Light, travel-friendly UI — green & white theme with soft cards and rounded corners
- Destination photos — real location images from Wikipedia as you search
- Global city search — 200,000+ cities with autocomplete
- Popular getaways — one-click picks with photo cards
- Live weather + forecast — plans adapted to current and upcoming conditions
- Gemini AI itineraries — friendly day-by-day markdown plans
- Trip history — search, revisit, and delete past adventures
smart_weather_check/
├── client/ React + Vite + Tailwind frontend
│ ├── src/
│ │ ├── components/ UI (search, history, itinerary panel)
│ │ ├── hooks/ Location image loading
│ │ └── utils/ Wikipedia image fetcher
│ └── .env VITE_API_URL
├── server/ Express API
│ ├── index.js Routes + MongoDB + OpenWeather + Gemini
│ └── .env API keys & database URI
└── README.md
Before you start, make sure you have:
| Requirement | Link |
|---|---|
| Node.js 18+ | nodejs.org |
| MongoDB Atlas (free) | mongodb.com/cloud/atlas |
| OpenWeatherMap API key (free) | openweathermap.org/register |
| Google Gemini API key (free) | aistudio.google.com/apikey |
git clone <your-repo-url>
cd smart_weather_checkOr, if you already have the folder:
cd smart_weather_checkcd server
npm install- Go to MongoDB Atlas and sign up / log in.
- Create a free cluster (e.g. M0, AWS, region closest to you).
- Database Access → Add New Database User
- Choose a username and password (save these — you need them for
MONGO_URI).
- Choose a username and password (save these — you need them for
- Network Access → Add IP Address
- Click Add Current IP Address, or use Allow Access from Anywhere (
0.0.0.0/0) for local development only.
- Click Add Current IP Address, or use Allow Access from Anywhere (
- Go to Database → click Connect on your cluster.
- Choose Drivers (not Compass, Shell, SQL, or Power BI).
- Select Node.js and copy the connection string.
It looks like:
mongodb+srv://<username>:<password>@cluster0.xxxxx.mongodb.net/?appName=Cluster0
Important:
- Replace
<username>and<password>with your database user credentials. - If your password contains special characters, URL-encode them (e.g.
@→%40,#→%23). - Add the database name
smart-travelbefore the?:
mongodb+srv://YOUR_USER:YOUR_PASSWORD@cluster0.xxxxx.mongodb.net/smart-travel?retryWrites=true&w=majority
Tip: If you see
querySrv ECONNREFUSED, your network may block SRV DNS. In Atlas → Connect → Drivers, use the standard connection string (mongodb://...with shard hostnames) instead ofmongodb+srv://. Seeserver/.env.example.
You do not need to:
- Change cluster tier on the Edit Cluster page (Free is fine).
- Add cluster Tags (optional, for organization only).
- Use Atlas SQL or Power BI connection strings.
- Sign up at OpenWeatherMap.
- Verify your email.
- Open API keys and copy your default key.
- New keys can take up to 2 hours to activate. A 401 error right after signup is normal — wait and retry.
This app uses the free tier: Geocoding, Current Weather, and 5-day Forecast.
- Go to Google AI Studio.
- Sign in with your Google account.
- Click Create API key and copy it.
Gemini keys are usually active immediately.
Copy the example file:
# macOS / Linux / Git Bash
cp .env.example .env# Windows PowerShell
Copy-Item .env.example .envEdit server/.env with your real values:
PORT=5000
CLIENT_URL=http://localhost:5173
MONGO_URI=mongodb+srv://YOUR_USER:YOUR_PASSWORD@cluster0.xxxxx.mongodb.net/smart-travel?retryWrites=true&w=majority
WEATHER_API_KEY=your_openweathermap_key_here
GEMINI_API_KEY=your_google_gemini_key_hereExample (password example@123 must be encoded as example%40123):
MONGO_URI=mongodb+srv://myuser:example%40123@cluster0.abc123.mongodb.net/smart-travel?retryWrites=true&w=majorityNever commit .env — it is gitignored.
cd ../client
npm installCopy the example file (optional — defaults work for local dev):
cp .env.example .envDefault client/.env:
VITE_API_URL=http://localhost:5000Change VITE_API_URL when deploying to point at your production backend URL.
Open Terminal 1:
cd server
npm run devOr, without auto-reload:
npm startYou should see:
MongoDB Connected
Server running on port 5000
Verify the backend (optional):
curl http://localhost:5000/api/healthExpected response:
{ "ok": true, "envConfigured": true, "databaseConnected": true }Open Terminal 2:
cd client
npm run devVite prints the local URL, usually http://localhost:5173. If that port is busy, it may use 5174 or 5175 — open the exact URL shown in the terminal.
- Open the URL Vite printed (e.g.
http://localhost:5173). - Confirm the status banner does not show missing API keys or backend offline.
- Type a city (e.g.
Paris, FRorKodaikanal, IN) — a destination photo appears as you search. - Pick from Popular getaways or select an autocomplete suggestion.
- Set trip length with the slider (1–14 days).
- Click Generate My Itinerary.
- View your weather-smart plan with photos, forecast, and day-by-day details.
- Check Trip history — saved plans are stored in MongoDB.
If dependencies and .env files are already configured:
Terminal 1 — Backend:
cd server
npm run devTerminal 2 — Frontend:
cd client
npm run devThen open the URL Vite prints in your browser.
| Method | Route | Description |
|---|---|---|
GET |
/api/health |
Server & database status |
GET |
/api/locations/search?q= |
Global city autocomplete |
POST |
/api/generate-itinerary |
Generate & save itinerary |
GET |
/api/history?search= |
List past trips (optional filter) |
DELETE |
/api/history/:id |
Delete a saved trip |
| Problem | What to do |
|---|---|
| Amber API keys needed banner | Fill in all three keys in server/.env, restart backend |
MongoDB connection failed / querySrv ECONNREFUSED |
Use the standard URI from Atlas (mongodb://... not mongodb+srv://) — see server/.env.example |
| MongoDB connection failed (other) | Check username/password; URL-encode special chars in password (@ → %40); whitelist your IP in Atlas Network Access |
| Used wrong Atlas connection type | Choose Drivers → Node.js, not Atlas SQL / Power BI / Compass |
| Weather 401 Unauthorized | Verify WEATHER_API_KEY at API keys; wait up to 2 hours if key is new |
| Location not found | Add country code: Paris, FR or pick from suggestions |
| Backend offline banner | Run cd server && npm run dev — confirm MongoDB Connected in terminal |
| Port 5000 already in use | Stop the old Node process, then restart the server |
| Frontend on 5174 / 5175 instead of 5173 | Normal when 5173 is busy — open the URL Vite prints |
| No destination photo | Wikipedia may not have an image; a green fallback is shown |
| Generate fails / Network Error | Ensure backend is running and CLIENT_URL in server/.env matches your frontend origin |
- Push to GitHub (
.envfiles are gitignored — never commit secrets) - Deploy server/ to Render or Railway with all env vars
- Deploy client/ to Vercel with
VITE_API_URL=<your-backend-url> - Update MongoDB Atlas network access for your host
MIT — built for learning and adventure. Happy travels!