π
Live Weather App
β οΈ Note: The backend is hosted on Render's free tier, which may take a few seconds to wake up when you first access the app. Thanks for your patience! π
This version of the project is a full-stack weather application that allows users to search for the current weather of a city. It fetches weather data from the OpenWeatherMap API and displays it in a user-friendly interface.
If you would like to check out the legacy command-line interface version, please refer to the feature/legacy-weather-cli branch.
The application consists of:
- A backend built with Node.js and Express to handle API requests and serve weather data.
- A frontend built with React to provide a dynamic and interactive user interface.
- Fetches weather data from the OpenWeatherMap API.
- Handles API requests with Express.
- Implements dynamic CORS for local and production environments.
- Provides detailed weather information, including:
- Temperature
- Feels like temperature
- Weather conditions
- Humidity
- Wind speed
- Sunrise and sunset times
- Cloud cover and visibility
- Allows users to search for weather by city name.
- Displays weather data in a clean and responsive UI.
- Handles loading states and error messages gracefully.
- Uses environment variables to dynamically connect to the backend.
- Node.js installed on your machine.
- Basic understanding of JavaScript, React, and terminal commands.
git clone https://github.com/<your-username>/weather-app.git
cd weather-app
-
Navigate to the
backend
folder:cd backend
-
Install dependencies:
npm install
-
Create a
.env
file for environment variables:
plaintext
KEY=your_actual_api_key_here
PORT=3003
FRONTEND_URL=http://localhost:5173
- Start the backend server:
npm start
-
Navigate to the
frontend
folder:cd ../frontend
-
Install dependencies:
npm install
-
Create a
.env
file for environment variables:REACT_APP_BACKEND_URL=http://localhost:3003/weather
-
Start the frontend development server:
npm start
weather-cli/
βββ backend/
β βββ .env # Backend-specific environment variables
β βββ package.json
β βββ server.js
β βββ modules/
β β βββ weatherModule.js
β βββ README.md
βββ frontend/
β βββ .env.development # Frontend environment variables for development
β βββ .env.production # Frontend environment variables for production
β βββ public/
β β βββ index.html
β βββ src/
β β βββ components/
β β β βββ WeatherFetcher.jsx
β β β βββ Btn.jsx
β β β βββ BtnSvg.jsx
β β βββ App.jsx
β β βββ index.jsx
β β βββ index.css
β βββ package.json
β βββ README.md
βββ .gitignore
βββ README.md
βββ package.json
- GET
/weather/:city
- Fetches weather data for the specified city.
- Query Parameters:
unit
(optional):metric
(default) orimperial
.
- The frontend is deployed on GitHub Pages and connects to:
- the backend hosted on Render
- the OpenWeatherMap API for weather data
π Try it live β
β οΈ Note: The backend is hosted on Renderβs free tier and may take a few seconds to spin up when first accessed.
- Frontend runs at:
http://localhost:5173/
- Deploy the backend to a service like Render, Heroku, or AWS.
- Set the
FRONTEND_URL
in the backend.env
file to match your deployed frontend URL.
- Build the frontend:
npm run build
- Start the backend server.
- Start the frontend development server.
- Open the frontend in your browser (default:
http://localhost:5173
). - Enter a city name in the search bar to fetch and display weather data.
-
Add Forecast Data
- Extend the backend to fetch and display multi-day weather forecasts.
-
User Preferences
- Allow users to save their preferred cities and units (metric/imperial).
-
Authentication
- Implement user authentication to save user-specific settings.
-
Database Integration
- Store user preferences and weather data in a database like MongoDB or PostgreSQL.
-
Full-Stack Deployment
- Combine the frontend and backend into a single deployment for simplicity.
- Node.js Documentation
- React Documentation
- OpenWeatherMap API
- Express Documentation
- dotenv Documentation
- Styled Components Documentation
- Tailwind CSS Documentation
This project was developed as a learning exercise to integrate external APIs, build a full-stack application, and deploy it for public use. Contributions and suggestions are welcome!
If you would like to check out the legacy command-line interface version, please refer to the feature/legacy-weather-cli branch.
- Updated Overview: Reflects the full-stack nature of the project.
- Added Backend and Frontend Setup Instructions: Includes
.env
setup and running both servers. - Updated Project Structure: Reflects the current folder structure.
- Added Deployment Instructions: Explains how to deploy both the backend and frontend.
- Added Future Enhancements: Lists potential improvements for the project.
Thanks for smiling ! π