A modern, responsive weather application built with React and Node.js that provides real-time weather data and forecasts. The app features a clean Material UI interface and supports both guest browsing and user authentication for personalized experiences.
- Real-time Weather Data: Current weather conditions with temperature, humidity, and weather icons
- 5-Day Forecast: Detailed weather predictions with daily breakdowns
- Geolocation Support: Automatic weather detection based on user location
- Responsive Design: Mobile-first design that works seamlessly across all devices
- Guest Access: Browse weather data without creating an account
- Clean UI: Modern interface built with Material UI components
- Temperature Units: Support for both Celsius and Fahrenheit
- Fast Performance: Optimized API calls and efficient data caching
- React 18.2 - Modern UI library with hooks
- Vite 5.2 - Fast build tool and development server
- Material UI 5.15 - Professional component library
- React Router DOM 7.9 - Client-side routing
- Axios - HTTP client for API requests
- Node.js - JavaScript runtime
- Express.js 4.19 - Web application framework
- dotenv - Environment variable management
- CORS - Cross-origin resource sharing
- OpenWeatherMap API - Weather data provider
- Current Weather API (2.5)
- 5-Day Forecast API (2.5)
- Node.js v18.0.0 or higher
- npm v9.0.0 or higher
- OpenWeatherMap API Key (free tier available)
git clone https://github.com/taizhenc/weather_mobile.git
cd weather_mobilecd backend
npm install
# Create environment file
cp .env.example .env
# Edit .env and add your OpenWeatherMap API key
# OPENWEATHER_API_KEY=your_api_key_herecd ..
npm install
# Create environment file
echo "VITE_API_BASE_URL=http://localhost:5000/api" > .env- Sign up at OpenWeatherMap
- Navigate to API Keys section
- Copy your API key
- Paste it in
backend/.envfile
Terminal 1 - Backend:
cd backend
npm run devTerminal 2 - Frontend:
npm run devThe app will be available at:
- Frontend: http://localhost:5173
- Backend: http://localhost:5000
weather_mobile/
βββ backend/ # Backend API server
β βββ src/
β β βββ controllers/ # Request handlers
β β βββ routes/ # API routes
β β βββ services/ # Business logic
β β βββ server.js # Express app entry
β βββ .env.example # Environment template
β βββ package.json
β
βββ src/ # Frontend React app
β βββ contexts/ # React Context providers
β βββ features/ # Feature-based components
β β βββ auth/ # Login & registration
β β βββ home/ # Home page
β β βββ forecast/ # Forecast page
β βββ hooks/ # Custom React hooks
β βββ services/ # API services
β βββ ui/ # Reusable UI components
β
βββ .gitignore
βββ package.json
βββ README.md
GET /api/weather/current?lat={latitude}&lon={longitude}&units={metric|imperial}GET /api/weather/forecast?lat={latitude}&lon={longitude}&units={metric|imperial}GET /health- RESTful API design
- Environment-based configuration
- CORS middleware for cross-origin requests
- Error handling middleware
- API key security (hidden from frontend)
- Component-based architecture
- Custom hooks for data fetching
- Context API for state management
- Protected routing
- Responsive Material UI design
- ES6+ JavaScript features
- Async/await for asynchronous operations
- Clean code structure and separation of concerns
- Reusable components and hooks
NODE_ENV=development
PORT=5000
OPENWEATHER_API_KEY=api_key
CORS_ORIGIN=http://localhost:5173VITE_API_BASE_URL=http://localhost:5000/api- Railway - Easy Node.js deployment
- Render - Free tier available
- Heroku - Popular PaaS platform
- DigitalOcean App Platform - Managed deployment
- Vercel - Optimized for Vite apps
- Netlify - Easy continuous deployment
- GitHub Pages - Free static hosting
- Cloudflare Pages - Fast CDN distribution
- Update
VITE_API_BASE_URLin frontend.envto your deployed backend URL - Update
CORS_ORIGINin backend.envto your deployed frontend URL - Build frontend:
npm run build - Deploy
dist/folder to your frontend hosting - Deploy backend to your Node.js hosting platform
# Start both servers and verify:
# 1. Frontend loads at http://localhost:5173
# 2. Backend responds at http://localhost:5000/health
# 3. Weather data loads with geolocation
# 4. Forecast page displays 5-day prediction- Verify API key is active (can take up to 2 hours after signup)
- Check API key is correctly set in
backend/.env - Restart backend server after changing
.env
- Ensure
CORS_ORIGINin backend matches your frontend URL - Check both servers are running on correct ports
- Allow browser location access when prompted
- Check browser console for error messages
- Verify backend is running and healthy
This project is open source and available under the MIT License.
Taizhen Chen
- GitHub: @taizhenc
- Portfolio: [https://taizhenc.github.io/]
- LinkedIn: [https://www.linkedin.com/in/taizhen-cheung-6a3852290/]
- Weather data provided by OpenWeatherMap
- UI components from Material UI
- Icons from Material Icons
Built with β€οΈ using React and Node.js