A full-stack weather application that provides real-time weather data for any city. The application features a React frontend and a Node.js/Express backend, and is fully containerized with Docker and configured for deployment on Kubernetes and Render.
- City-based Weather Search: Search for current weather conditions by entering a city name
- Detailed Weather Information: Displays temperature, humidity, wind speed, and weather description
- Dynamic Weather Icons: Visual representation of current weather conditions
- Responsive Design: Clean, modern UI that works on both desktop and mobile devices
- Dark/Light Mode: Toggle between dark and light themes for user comfort
- Backend API: Simple Express API that proxies requests to OpenWeatherMap
π Frontend: https://weather-frontend-7mo5.onrender.com
π Backend API: https://weather-backend-dde1.onrender.com
β οΈ Note: First request may take 30+ seconds due to Render's cold start.
- React 18
- TypeScript
- Vite
- Tailwind CSS
- Lucide React (icons)
- Node.js
- Express.js
- CORS
- node-fetch
- Docker & Docker Compose
- Kubernetes
- Nginx
- GitHub Actions (CI/CD)
- Render
- SonarCloud (code quality)
- OWASP Dependency Check
- Nexus Repository
- Node.js 18+ (for local development)
- Docker & Docker Compose (for containerized deployment)
- OpenWeatherMap API key (Get one free here)
-
Clone the repository:
git clone https://github.com/lavash2310/weather-app.git cd weather-app -
Install dependencies:
npm install
-
Create environment file:
Create a
.envfile in the root directory:API_KEY=your_openweathermap_api_key_here PORT=5001
-
Run the backend server:
npm run dev
Backend will start at
http://localhost:5001 -
Run the frontend (in a separate terminal):
npm run build npm run preview
Frontend will start at
http://localhost:4173
-
Clone the repository:
git clone https://github.com/kubezen-stack/weather-app.git cd weather-app -
Create environment file:
Create a
.envfile in the root directory:VITE_API_KEY=your_openweathermap_api_key_here
-
Update docker-compose.yaml:
Replace the hardcoded API key in
docker-compose.yaml:environment: - VITE_API_KEY=${VITE_API_KEY}
-
Build and run containers:
docker-compose up --build
-
Access the application:
- Frontend: http://localhost:8080
- Backend API: http://localhost:5001
-
Setup Minikube (if using locally):
minikube start
-
Create Kubernetes secret:
kubectl create secret generic my-app-secret \ --from-literal=api-key="your_api_key_here" \ --from-literal=backend-url="https://weather-backend-dde1.onrender.com"
-
Apply Kubernetes manifests:
kubectl apply -f kubernetes/
-
Check deployment status:
kubectl get pods,svc,ingress -n default
The backend server provides the following endpoints:
| Method | Endpoint | Description | Example |
|---|---|---|---|
GET |
/ |
Welcome message and API info | - |
GET |
/health |
Health check with status and uptime | - |
GET |
/api/weather?q=<city> |
Get weather data for specified city | /api/weather?q=London |
{
"temperature": 15,
"humidity": 72,
"windSpeed": 20,
"description": "partly cloudy",
"city": "London",
"country": "GB",
"icon": "02d"
}| Variable | Description | Required | Default |
|---|---|---|---|
API_KEY |
OpenWeatherMap API key | β Yes | - |
PORT |
Backend server port | No | 5001 |
NODE_ENV |
Environment mode | No | development |
| Variable | Description | Required | Default |
|---|---|---|---|
VITE_BACKEND_URL |
Backend API URL | No | http://localhost:5001 |
weather-app/
βββ .github/
β βββ workflows/ # CI/CD pipelines
β βββ ci.yaml # Continuous Integration
β βββ cd.yaml # Continuous Deployment
β βββ hourly_weather.yaml # Scheduled weather reports
βββ kubernetes/ # Kubernetes manifests
β βββ deployment.yaml # Pod deployments
β βββ service-backend.yaml
β βββ service-frontend.yaml
β βββ ingress.yaml # Traffic routing
β βββ role.yaml # RBAC permissions
β βββ role-binding.yaml
β βββ service-account.yaml
βββ src/ # Frontend source code
β βββ App.tsx # Main React component
β βββ main.tsx # Entry point
β βββ index.css # Global styles
βββ index.js # Backend Express server
βββ Dockerfile.backend # Backend container
βββ Dockerfile.frontend # Frontend container
βββ docker-compose.yaml # Multi-container orchestration
βββ nginx.conf # Nginx configuration
βββ package.json # Dependencies & scripts
βββ README.md # This file
The project uses GitHub Actions for automated CI/CD:
- β Dependency installation and build
- β SonarCloud static code analysis
- β OWASP dependency vulnerability scanning
- β NPM package publishing to Nexus
- π³ Docker image build and push to Docker Hub
- βοΈ Automatic deployment to Render
- βΈοΈ Kubernetes deployment with image updates
- π§ Email notifications for deployment status
- π Runs every hour via cron schedule
- π¨ Sends weather report emails for Kyiv, UA
npm run dev # Start backend with nodemon (development)
npm run start # Start backend (production)
npm run build # Build frontend for production
npm run preview # Preview production build
npm run lint # Run ESLint
npm run sonar # Run SonarQube analysisIf ports 5001 or 8080 are already in use:
# Stop Docker containers
docker-compose down
# Kill process on port (Linux/Mac)
lsof -ti:5001 | xargs kill -9
lsof -ti:8080 | xargs kill -9
# Kill process on port (Windows)
netstat -ano | findstr :5001
taskkill /PID <PID> /FEnsure the backend URL in src/App.tsx matches your deployment:
const BACKEND_URL = 'https://weather-backend-dde1.onrender.com';For local development, update to:
const BACKEND_URL = 'http://localhost:5001';Clear Docker cache and rebuild:
docker-compose down --volumes
docker system prune -a
docker-compose up --build- Verify your API key at OpenWeatherMap
- Wait a few hours after creating new API key (activation delay)
- Check if API key is properly set in environment variables
- First request to Render deployment may take 30+ seconds (cold start)
- Docker compose contains hardcoded API key (should use
.envfile) - No automated tests implemented yet
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create your feature branch:
git checkout -b feature/AmazingFeature
- Commit your changes:
git commit -m 'Add some AmazingFeature' - Push to the branch:
git push origin feature/AmazingFeature
- Open a Pull Request
- Use TypeScript for frontend code
- Follow ESLint configuration
- Use Prettier for formatting
- Write meaningful commit messages
This project is licensed under the MIT License - see the LICENSE file for details.
Kubezen-stack
- GitHub: @kubezen-stack
- Repository: kubezen-stack
- OpenWeatherMap for weather data API
- Lucide for beautiful icons
- Tailwind CSS for styling
- Render for hosting
If you have any questions or need help, please open an issue on GitHub.
β Star this repository if you find it helpful!