Skip to content

PR2309/Weather-App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

****# 🌦️ Weather App

A sleek and responsive Weather Web Application that provides real-time weather updates for any city worldwide using the OpenWeather API. It features a dynamic UI that adapts visually based on current weather conditions.


πŸš€ Features

  • 🌍 Search weather by city name
  • 🌑️ Real-time temperature (Kelvin, Celsius, Fahrenheit)
  • πŸ’§ Humidity tracking
  • 🌬️ Wind speed with multiple unit conversions
  • 🌫️ Atmospheric pressure with unit switching
  • πŸ•’ Local time with 12/24-hour format toggle
  • πŸŒ… Day/Night phase detection (Morning, Evening, Night, etc.)
  • 🎨 Dynamic background & weather icons based on conditions
  • ⚑ Keyboard shortcuts (Enter to search, Space to focus input)
  • πŸ“± Responsive UI with smooth animations

πŸ› οΈ Tech Stack

  • Frontend: HTML, CSS, JavaScript
  • API: OpenWeather API
  • Icons & UI: Bootstrap Icons, Font Awesome

βš™οΈ How It Works

  • User enters a city name
  • App sends request to OpenWeather API
  • Weather data is fetched using fetch()
  • UI updates dynamically based on response
  • Background and icons change based on weather conditions

πŸ“š Concepts Used

  • API Integration (Fetch API)
  • DOM Manipulation
  • Event Handling
  • Async/Await
  • Unit Conversion Logic
  • Dynamic UI Rendering

❗ Error Handling

  • Shows error UI for invalid city names
  • Handles API failures using try-catch
  • Prevents empty input search

πŸ“‚ Project Structure

   Weather-App/                                 # Root directory
      β”‚
      β”œβ”€β”€ index.html                            # Entry point - UI structure
      β”œβ”€β”€ style.css                             # Styles (layout, animations)
      β”œβ”€β”€ app.js                                # Core logic (API, DOM, events)
      β”œβ”€β”€ server.js                             # Express dev server / API proxy (optional)
      β”‚
      β”œβ”€β”€ manifest.json                         # PWA configuration
      β”œβ”€β”€ robots.txt                            # SEO crawling rules
      β”œβ”€β”€ sitemap.xml                           # SEO sitemap
      β”‚
      β”œβ”€β”€ Preview.png                           # Project preview screenshot
      β”‚
      β”œβ”€β”€ README.md                             # Documentation (setup, usage, features)
      β”œβ”€β”€ LICENSE                               # MIT license
      β”œβ”€β”€ CHANGELOG.md                          # Version history
      β”œβ”€β”€ CONTRIBUTING.md                       # Contribution guide
      β”œβ”€β”€ CODE_OF_CONDUCT.md                    # Community guidelines
      β”œβ”€β”€ SECURITY.md                           # Security policy
      β”‚
      β”œβ”€β”€ .env.example                          # Env template (API key placeholder)
      β”œβ”€β”€ .gitignore                            # Git ignored files
      β”‚
      β”œβ”€β”€ .editorconfig                         # Editor consistency rules
      β”œβ”€β”€ .prettierrc                           # Code formatting rules
      β”œβ”€β”€ .prettierignore                       # Ignore formatting
      β”œβ”€β”€ .eslintrc.json                        # JS linting rules
      β”œβ”€β”€ .eslintignore                         # Ignore linting
      β”œβ”€β”€ .stylelintrc                          # CSS linting rules
      β”‚
      β”œβ”€β”€ .babelrc                              # Babel config (if used)
      β”œβ”€β”€ .npmrc                                # NPM config
      β”œβ”€β”€ jsconfig.json                         # JS project config (intellisense)
      β”‚
      β”œβ”€β”€ .vscode/                              # VS Code settings
      β”œβ”€β”€ .git/                                 # Git internals (auto-generated)
      β”‚
      └── media/                                # All assets (cleaned structure)
            β”‚
            β”œβ”€β”€ logo1.png                       # Project Logo
            β”‚
            β”œβ”€β”€ Icons/                          # UI icons
            β”‚     β”œβ”€β”€ air-quality-icon.png
            β”‚     β”œβ”€β”€ day-and-night-icon.png
            β”‚     β”œβ”€β”€ humidity-icon.png
            β”‚     β”œβ”€β”€ pressure-gauge-icon.png
            β”‚     β”œβ”€β”€ search.png
            β”‚     β”œβ”€β”€ temperature-icon.png
            β”‚     β”œβ”€β”€ time-icon.png
            β”‚     β”œβ”€β”€ uv-icon.png
            β”‚     └── wind-icon.png
            β”‚
            β”œβ”€β”€ GIFs/                   # Animated backgrounds
            β”‚     β”œβ”€β”€ clear.gif
            β”‚     β”œβ”€β”€ clouds.gif
            β”‚     β”œβ”€β”€ drizzle.gif
            β”‚     β”œβ”€β”€ haze.gif
            β”‚     β”œβ”€β”€ mist.gif
            β”‚     β”œβ”€β”€ rain.gif
            β”‚     β”œβ”€β”€ smoke.gif
            β”‚     β”œβ”€β”€ snow.gif
            β”‚     └── thunderstorm.gif
            β”‚
            └── images/                  # Static weather icons
                  β”œβ”€β”€ clear.png
                  β”œβ”€β”€ clouds.png
                  β”œβ”€β”€ default.png
                  β”œβ”€β”€ drizzle.png
                  β”œβ”€β”€ haze.png
                  β”œβ”€β”€ mist.png
                  β”œβ”€β”€ rain.png
                  β”œβ”€β”€ smoke.png
                  β”œβ”€β”€ snow.png
                  └── thunderstorm.png

βš™οΈ Setup & Usage

Option 1: Direct Browser Opening (Simple)

  1. Clone the repository:
   git clone https://github.com/your-username/Weather-App.git
  1. Navigate into the project folder:
   cd Weather-App
  1. Open index.html in your browser or use a local server

Option 2: Using Development Server (Recommended)

  1. Install Node.js dependencies:
   npm install express dotenv
  1. Set up environment variables:
   cp .env.example .env
   # Edit .env and add your OpenWeather API key
  1. Start the development server:
   node server.js
  1. Open http://localhost:3000 in your browser

API Key Setup

  1. Get a free API key from OpenWeather API
  2. Replace YOUR_API_KEY in app.js or set it in your .env file
  3. The app will work with real weather data once the API key is configured

πŸ”‘ API Configuration

Replace the API key inside app.js:

   const apiKey = "YOUR_API_KEY";

⚠️ Do NOT expose your API key in public repositories. Important: Use .env in production.


πŸ“Έ Preview

Dynamic UI based on weather (rain, clear, snow, etc.) Smooth transitions and animated backgrounds

⚠️ Known Limitations

API key is currently exposed (for demo purposes only) No backend (pure frontend app) Error handling can be improved for edge cases

πŸ”’ Security Notes

Add .env for API keys in production Avoid committing sensitive data Consider rate limiting if scaling

🌱 Future Improvements

🌐 Add geolocation support πŸ“Š 7-day weather forecast πŸŒ™ Dark/Light theme toggle πŸ“ Auto-detect user location ⚑ Performance optimization

πŸ“„ License

This project is open-source and available under the MIT License.


πŸ‘¨β€πŸ’» Author

Piyush Rana