A production-grade, enterprise-level global weather forecasting platform that provides accurate weather insights for every country, state, and major city worldwide.
- Real-time Weather Data: Live temperature, AQI, humidity, and more
- Location Detection: Automatic user location detection (browser geolocation + IP fallback)
- Comprehensive Forecasts: 24-hour and 7-day forecasts
- Weather Alerts: Real-time extreme weather notifications
- Global Coverage: Weather data for cities worldwide
- Interactive Maps: Visual world weather map
- Responsive Design: Mobile-first, fully responsive UI
- Theme Support: Light, dark, and auto themes
- Framework: Spring Boot 3.x
- Database: MongoDB
- Security: JWT-based authentication
- Caching: Caffeine Cache
- APIs: OpenWeatherMap, WeatherAPI integrations
- Framework: React 18 with TypeScript
- Build Tool: Vite
- Styling: TailwindCSS
- State Management: React Hooks
- Real-time: WebSocket connections
weather-forecast/
βββ backend/ # Java Spring Boot backend
β βββ src/
β β βββ main/
β β β βββ java/com/weatherforecast/
β β β β βββ controller/ # REST controllers
β β β β βββ service/ # Business logic
β β β β βββ repository/ # Database repositories
β β β β βββ model/ # Data models
β β β β βββ dto/ # Data transfer objects
β β β β βββ config/ # Configuration classes
β β β β βββ security/ # Security configurations
β β β β βββ util/ # Utility classes
β β β βββ resources/
β β βββ test/
β βββ pom.xml # Maven configuration
βββ frontend/ # React frontend
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ contexts/ # React contexts
β β βββ hooks/ # Custom React hooks
β β βββ services/ # API services
β β βββ App.tsx # Main application component
β βββ index.html # HTML entry point
β βββ vite.config.js # Vite configuration
βββ README.md # Project documentation
- Java 17+ for backend
- Node.js 16+ for frontend
- MongoDB database
- OpenWeatherMap API key
-
Navigate to the backend directory:
cd backend -
Install dependencies:
mvn clean install
-
Configure environment variables:
# Create application.properties or use environment variables export SPRING_DATA_MONGODB_URI=mongodb://localhost:27017/weather_forecast export OPENWEATHERMAP_API_KEY=your_api_key_here
-
Run the application:
mvn spring-boot:run
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Build for production:
npm run build
- JWT Authentication: Secure user authentication
- Role-based Access: Different permissions for user roles
- Input Validation: Backend validation for all inputs
- CORS Protection: Controlled cross-origin requests
- Rate Limiting: API rate limiting to prevent abuse
POST /api/auth/signin- User loginPOST /api/auth/signup- User registration
GET /api/location/countries- Get all countriesGET /api/location/states/{countryId}- Get states by countryGET /api/location/cities/state/{stateId}- Get cities by stateGET /api/location/cities/search?name={query}- Search cities
GET /api/weather/current/{cityId}- Current weatherGET /api/weather/forecast/hourly/{cityId}?hours={n}- Hourly forecastGET /api/weather/forecast/daily/{cityId}?days={n}- Daily forecastGET /api/weather/alerts/{cityId}- Weather alerts
- Unit Tests: JUnit 5 with Mockito
- Integration Tests: SpringBootTest
- API Tests: Postman collections
- Component Tests: Vitest + React Testing Library
- E2E Tests: Cypress (optional)
Run backend tests:
cd backend
mvn testRun frontend tests:
cd frontend
npm run test- Caching: In-memory caching with Caffeine
- Database Indexes: Optimized MongoDB queries
- Connection Pooling: Efficient database connections
- Async Processing: Non-blocking operations
-
Build the frontend:
cd frontend npm run build -
Package the backend:
cd backend mvn clean package
| Variable | Description | Required |
|---|---|---|
SPRING_DATA_MONGODB_URI |
MongoDB connection URI | Yes |
OPENWEATHERMAP_API_KEY |
OpenWeatherMap API key | Yes |
JWT_SECRET |
Secret for JWT tokens | Yes |
SERVER_PORT |
Application port (default: 8080) | No |
Create a docker-compose.yml:
version: '3.8'
services:
mongodb:
image: mongo:latest
ports:
- "27017:27017"
volumes:
- mongodb_data:/data/db
backend:
build: ./backend
ports:
- "8080:8080"
environment:
- SPRING_DATA_MONGODB_URI=mongodb://mongodb:27017/weather_forecast
- OPENWEATHERMAP_API_KEY=your_api_key_here
depends_on:
- mongodb
frontend:
build: ./frontend
ports:
- "3000:3000"
depends_on:
- backend
volumes:
mongodb_data:- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenWeatherMap for weather data
- ip-api for geolocation services
- React for the frontend framework
- Spring Boot for the backend framework