A modern, full-stack weather application built with Spring Boot and vanilla HTML/CSS/JavaScript. Features intelligent city name correction, geolocation support, rate limiting, and a beautiful responsive design.
- 🌍 City Weather Search - Get weather for any city worldwide
- 📍 Geolocation Support - Use your current location for weather data
- 🔧 Smart City Correction - Handles typos using Levenshtein distance algorithm
- 📱 Responsive Design - Works on desktop and mobile devices
- Java 17 or higher
- Maven 3.6+
- OpenWeatherMap API Key (free at openweathermap.org)
-
Clone the repository
git clone https://github.com/tvdxr/weather_app_java.git cd weather_app_java/demo -
Configure API Key
Option A: Using application-local.properties (Recommended for development)
# Copy the example configuration cp src/main/resources/application.properties.example src/main/resources/application-local.properties # Edit application-local.properties and add your API key weather.api.key=YOUR_OPENWEATHERMAP_API_KEY_HERE
Option B: Using Environment Variable
# Set environment variable (Windows) set WEATHER_API_KEY=your_api_key_here # Set environment variable (Linux/Mac) export WEATHER_API_KEY=your_api_key_here
-
Run the application
mvn spring-boot:run
-
Open your browser
Navigate to
http://localhost:8080
- WeatherService - Core business logic with API integration
- WeatherController - REST API endpoints (
/api/weather/*) - Smart City Correction - Levenshtein distance algorithm for typos
- Responsive HTML5 - Semantic structure with accessibility
- Modern CSS3 - Grid/Flexbox layout with gradient themes
- ES6 JavaScript - Fetch API, async/await, geolocation
GET /api/weather/{city}- Get weather by city nameGET /api/weather/coordinates?lat={lat}&lon={lon}- Get weather by coordinates
The application can be configured through application.properties or environment variables:
# Server Configuration
server.port=8080
# API Configuration
weather.api.key=${WEATHER_API_KEY:}
weather.api.url=https://api.openweathermap.org/data/2.5/weather
## 🙏 Acknowledgments
- [OpenWeatherMap](https://openweathermap.org/) for the weather API
- [Spring Boot](https://spring.io/projects/spring-boot) for the awesome framework
---