An intelligent chatbot that combines real-time weather data with AI-powered music recommendations using Google's Gemini AI and Spotify API.
Features โข Demo โข Installation โข API Keys โข Usage โข Architecture
- Overview
- Tech Stack
- Architecture
- Prerequisites
- Installation
- Environment Variables
- Project Structure
- How It Works
WeatherTunes AI is a full-stack web application that revolutionizes how users discover music based on weather conditions. By combining real-time weather data from WeatherAPI.com, Google's Gemini AI for intelligent music curation, and Spotify's vast music library, the app creates a personalized and contextual music experience.
- ๐ค AI-Powered Recommendations: Uses Google Gemini 2.0 Flash to intelligently select songs that match weather moods
- ๐ต Spotify Integration: Direct links to songs on Spotify with album art and previews
- ๐ Global Weather Data: Real-time weather information for any city worldwide
- ๐ฌ Conversational AI: Natural language processing for casual conversations
- ๐ Multilingual Support: Full English and Japanese language support
- ๐จ Beautiful UI: Modern, responsive design with dark/light mode and 3D animations
- โก Real-Time Updates: Instant weather and music recommendations
- React 18.3.1 - UI framework
- Vite 5.4.21 - Build tool and dev server
- Tailwind CSS 3.4.18 - Utility-first CSS framework
- Three.js 0.163.0 - 3D graphics and animations
- Lucide React - Beautiful icon library
- Axios - HTTP client for API calls
- Node.js - JavaScript runtime
- Express 4.21.2 - Web application framework
- Google Generative AI 0.24.1 - Gemini AI integration
- Spotify Web API Node 5.0.2 - Spotify API wrapper
- Axios - HTTP client
- CORS - Cross-Origin Resource Sharing
- dotenv - Environment variable management
- Google Gemini AI - AI-powered music curation
- Spotify Web API - Music data and playback links
- WeatherAPI.com - Real-time weather data
โโโโโโโโโโโโโโโโโโโ
โ Frontend โ
โ (React + UI) โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โ HTTP/HTTPS
โ
โโโโโโโโโโผโโโโโโโโโ
โ Backend โ
โ (Express) โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โโโโโโดโโโโโฌโโโโโโโโโโฌโโโโโโโโโโโ
โ โ โ โ
โโโโโผโโโโ โโโโผโโโ โโโโโโผโโโโโ โโโโโผโโโโ
โGemini โ โSpot โ โWeather โ โ Chat โ
โ AI โ โ ify โ โ API โ โ Logic โ
โโโโโโโโโ โโโโโโโ โโโโโโโโโโโ โโโโโโโโโ
- User Input โ Frontend (React)
- API Request โ Backend (Express)
- Weather Data โ WeatherAPI.com
- AI Processing โ Google Gemini AI (song recommendations)
- Spotify Search โ Spotify API (track links and metadata)
- Response โ Backend formats and sends to Frontend
- Display โ React renders weather + music cards
Before installing, ensure you have:
- Node.js (v18.0.0 or higher)
- npm (v9.0.0 or higher) or yarn
- Git (for cloning the repository)
- API keys for:
- Google Gemini AI
- Spotify Web API
- WeatherAPI.com
git clone https://github.com/yourusername/weathertunes-ai.git
cd weathertunes-ai# Install all dependencies (frontend + backend)
npm installCreate a .env file in the root directory:
touch .envAdd your API keys (see API Keys Setup section):
# Google Gemini AI
GEMINI_API_KEY=your_gemini_api_key_here
# Spotify API
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
# Weather API
WEATHERAPI_KEY=your_weatherapi_key_here
# Server Port (optional)
PORT=3001- Express API server
- Handles weather, music, and chat endpoints
- Manages Spotify token refresh
- Integrates Gemini AI for song recommendations
- Bulletproof JSON parsing for AI responses
- Main React component
- UI/UX logic and state management
- Three.js animated background
- Handles user input and API calls
- Multilingual support (EN/JP)
- React DOM rendering entry point
- Global styles and Tailwind directives
- Custom scrollbar styles
- Animation keyframes
User Types: "What's the weather in Paris?"
โ
Frontend extracts city name
โ
POST /api/weather { city: "Paris" }
โ
Backend calls WeatherAPI.com
โ
Returns: temp, condition, humidity, wind
โ
Frontend displays weather card
Weather data received
โ
POST /api/music { condition, city, temp }
โ
Backend sends context to Gemini AI
โ
Gemini returns 5 song suggestions (JSON)
โ
Backend searches each song on Spotify (3 strategies)
โ
Returns songs with: name, artist, album, image, Spotify link
โ
Frontend displays music cards with play buttons
The backend sends a carefully crafted prompt to Gemini:
`You are an expert music curator. Based on the weather conditions below,
suggest EXACTLY 5 popular songs that perfectly match the mood.
Weather Information:
- City: Tokyo
- Temperature: 25ยฐC
- Condition: Sunny
Instructions:
1. Choose WELL-KNOWN songs from FAMOUS artists (must exist on Spotify)
2. Match the mood based on weather:
- Sunny/Clear: Upbeat, happy, energetic songs
- Rainy: Melancholic, cozy, reflective songs
...
3. Use EXACT song titles and artist names as they appear on Spotify
Return ONLY valid JSON array with EXACTLY 5 songs.`To ensure high-quality matches, the backend uses 3 search strategies:
Strategy 1: Precise Search
track:"Here Comes the Sun" artist:"The Beatles"Strategy 2: Broader Search
Here Comes the Sun The Beatles
// Matches partial artist namesStrategy 3: Name-Only Fallback
Here Comes the Sun
// Takes best matchIf Gemini AI or Spotify fail, the app has weather-appropriate fallback songs:
- Rainy: "Purple Rain", "November Rain", etc.
- Sunny: "Here Comes the Sun", "Walking on Sunshine", etc.
- Cloudy: "Both Sides Now", "A Sky Full of Stars", etc.
- Snowy: "Let It Snow", "Winter Wonderland", etc.
Toggle between themes with smooth transitions:
- Dark Mode: Blue gradient background, white text
- Light Mode: Light blue gradient, dark text
- Persistent across sessions (localStorage)
Full English and Japanese translations:
- All UI text translated
- Weather conditions translated
- Conversation responses translated
- Voice input supports both languages
Powered by Web Speech API:
- Click microphone icon to start
- Speaks your query aloud
- Automatically fills input field
- Supports EN/JP recognition
Three.js particle system:
- 1000 animated particles
- Rotating sphere with emissive glow
- Dynamic lighting effects
- Theme-aware colors
Mobile-first approach:
- Works on phones, tablets, desktops
- Touch-optimized controls
- Adaptive layouts
- Smooth scrolling
-
Create Render Account: render.com
-
Create Web Service:
- Connect GitHub repo
- Build Command:
npm install - Start Command:
node backend/server.js
-
Add Environment Variables:
- Go to Environment tab
- Add all keys from
.env
-
Deploy: Render will auto-deploy
-
Get Backend URL:
https://your-app.onrender.com
-
Create Vercel Account: vercel.com
-
Import Project:
- Connect GitHub repo
- Framework: Vite
- Build Command:
npm run build - Output Directory:
dist
-
Add Environment Variable:
VITE_API_URL=https://your-render-backend.onrender.com -
Deploy: Auto-deploys on push
// In src/App.jsx
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3001';- User accounts and saved preferences
- Playlist creation and export to Spotify
- Historical weather trends
