Skip to content

ranulgamage/ClimaVue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ClimaVue β˜€οΈ

Forecast with Precision

A production-ready weather forecast web application built with React and Next.js, featuring real-time weather data, hourly and 7-day forecasts, dark mode, and beautiful weather-based backgrounds.

ClimaVue Logo


✨ Features

🌀️ Current Weather

  • Real-time temperature with "feels like" indicator
  • Weather condition with animated icons
  • Humidity, wind speed, and atmospheric pressure
  • Sunrise and sunset times
  • City name and country display
  • Last updated timestamp

⏰ Hourly Forecast

  • Next 24 hours weather prediction
  • Temperature trends
  • Precipitation probability
  • Scrollable horizontal layout
  • Clean visual separation per hour

πŸ“… 7-Day Forecast

  • Daily high/low temperatures
  • Weather condition icons
  • Rain probability
  • Humidity levels
  • Compact, readable layout

πŸ” Location Search

  • Search by city name
  • Auto-detect current location on first visit
  • One-click current location button
  • Keyboard-friendly (Enter to search)
  • Recent searches stored in localStorage
  • Error handling for invalid locations
  • Geolocation permission handling
  • Clear search functionality

🎨 UI/UX Features

  • Dark Mode: Toggle between light and dark themes
  • Unit Toggle: Switch between Celsius and Fahrenheit
  • Modern Header: Permanent dark theme with blue gradient accents and glow effects
  • Responsive Design: Mobile-first, works on all devices
  • Weather Backgrounds: Dynamic gradients based on conditions (sunny, cloudy, rainy, night, etc.)
  • Skeleton Loaders: Smooth loading states with enhanced loading screen
  • Animations: Smooth transitions, hover effects, and glassmorphism UI
  • Auto-Location: Detects your location automatically on first visit
  • Offline Fallback: Shows cached data when offline

πŸ› οΈ Tech Stack

  • Framework: Next.js 16 (React 19)
  • Language: TypeScript
  • Styling: CSS Modules (no UI frameworks)
  • API: OpenWeatherMap API
  • Data Fetching: Native Fetch API
  • State Management: React Hooks
  • Storage: localStorage for preferences and caching

πŸ“ Project Structure

climavue/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ components/          # React components
β”‚   β”‚   β”œβ”€β”€ Header.tsx
β”‚   β”‚   β”œβ”€β”€ SearchBar.tsx
β”‚   β”‚   β”œβ”€β”€ CurrentWeather.tsx
β”‚   β”‚   β”œβ”€β”€ HourlyForecast.tsx
β”‚   β”‚   β”œβ”€β”€ DailyForecast.tsx
β”‚   β”‚   β”œβ”€β”€ LoadingScreen.tsx
β”‚   β”‚   β”œβ”€β”€ ErrorMessage.tsx
β”‚   β”‚   β”œβ”€β”€ SkeletonLoader.tsx
β”‚   β”‚   └── Footer.tsx
β”‚   β”œβ”€β”€ hooks/              # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ useWeather.ts
β”‚   β”‚   β”œβ”€β”€ useLocalStorage.ts
β”‚   β”‚   β”œβ”€β”€ useDarkMode.ts
β”‚   β”‚   └── useGeolocation.ts
β”‚   β”œβ”€β”€ services/           # API services
β”‚   β”‚   └── weatherService.ts
β”‚   β”œβ”€β”€ types/              # TypeScript types
β”‚   β”‚   └── weather.ts
β”‚   β”œβ”€β”€ utils/              # Utility functions
β”‚   β”‚   └── formatters.ts
β”‚   β”œβ”€β”€ styles/             # CSS Modules
β”‚   β”‚   β”œβ”€β”€ Header.module.css
β”‚   β”‚   β”œβ”€β”€ SearchBar.module.css
β”‚   β”‚   β”œβ”€β”€ CurrentWeather.module.css
β”‚   β”‚   β”œβ”€β”€ HourlyForecast.module.css
β”‚   β”‚   β”œβ”€β”€ DailyForecast.module.css
β”‚   β”‚   β”œβ”€β”€ LoadingScreen.module.css
β”‚   β”‚   β”œβ”€β”€ ErrorMessage.module.css
β”‚   β”‚   β”œβ”€β”€ SkeletonLoader.module.css
β”‚   β”‚   └── Footer.module.css
β”‚   β”œβ”€β”€ globals.css         # Global styles
β”‚   β”œβ”€β”€ layout.tsx          # Root layout
β”‚   └── page.tsx            # Main page
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ climavue_logo.png   # App logo
β”‚   └── logo-rgdev.png      # Company logo
β”œβ”€β”€ .env.example            # Environment variables template
β”œβ”€β”€ package.json
└── README.md

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ and npm
  • OpenWeatherMap API key (Get it here)

Installation

  1. Clone the repository

    git clone <your-repo-url>
    cd climavue
  2. Install dependencies

    npm install
  3. Set up environment variables

    Create a .env file in the root directory:

    cp .env.example .env

    Edit .env and add your OpenWeatherMap API key:

    NEXT_PUBLIC_OPENWEATHER_API_KEY=your_api_key_here
  4. Run the development server

    npm run dev
  5. Open the app

    Navigate to http://localhost:3000 in your browser.


πŸ”‘ Getting an API Key

  1. Visit OpenWeatherMap
  2. Sign up for a free account
  3. Navigate to API Keys section
  4. Generate a new API key
  5. Copy the key and paste it in your .env file

Note: Free tier allows 1,000 API calls per day, which is sufficient for development and personal use.


πŸ“¦ Build for Production

# Create production build
npm run build

# Start production server
npm start

🎯 Features in Detail

State Management

  • Custom hooks for weather data fetching and geolocation
  • localStorage integration for persistence and user preferences
  • Auto-detect user location on first visit
  • Optimistic UI updates
  • Error handling with fallback to cached data

Performance Optimizations

  • Code splitting with Next.js
  • Lazy loading of components
  • Optimized images with Next.js Image
  • Minimal re-renders with proper memoization

Accessibility

  • Semantic HTML elements
  • ARIA labels on interactive elements
  • Keyboard navigation support
  • Sufficient color contrast ratios
  • Focus visible states

Responsive Design

  • Mobile-first approach
  • Breakpoints: 480px, 768px, 1024px
  • Flexible grid layouts
  • Touch-friendly interface

🌐 Environment Variables

Variable Description Required
NEXT_PUBLIC_OPENWEATHER_API_KEY OpenWeatherMap API key Yes

🎨 Customization

Weather Backgrounds

Weather backgrounds are defined in globals.css. You can customize gradients for different conditions:

body.sunny {
  background: linear-gradient(135deg, #fef3c7 0%, #fcd34d 50%, #f59e0b 100%);
}

Color Scheme

Primary colors and theme variables are in globals.css:

:root {
  --primary-color: #3b82f6;
  --primary-color-dark: #2563eb;
  /* ... more variables */
}

πŸ› Troubleshooting

API Key Issues

  • Ensure your API key is correctly added to .env
  • Make sure the key starts with NEXT_PUBLIC_
  • Restart the dev server after adding the key

Location Not Found

  • Check spelling of city name
  • Try adding country code (e.g., "London, UK")
  • Some small towns may not be in the database

Dark Mode Not Working

  • Clear localStorage: localStorage.clear()
  • Check browser console for errors

πŸ“„ License

This project is open source and available for educational and personal use.


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

Ranul Gamage

Developed by Ranul Gamage

RGDev Logo

Company: RGDev


πŸ™ Acknowledgments


πŸ“ž Support

For issues, questions, or feature requests, please open an issue on the repository.


ClimaVue - Forecast with Precision β˜€οΈπŸŒ€οΈβ›ˆοΈ

About

A production-ready weather forecast web application built with React and Next.js, featuring real-time weather data, hourly and 7-day forecasts, dark mode, and beautiful weather-based backgrounds.

Resources

Stars

Watchers

Forks

Contributors