A modern, responsive weather application built with React and TypeScript that provides real-time weather information for cities across Poland. Features a clean, intuitive interface with weather comparison capabilities and server-side rendering for optimal performance.
Here you can see deployed version: Preview
Here you can find fresh CWV score: PageSpeed Insights
- π Real-time Weather Data: Get current weather conditions for any city in Poland
- π Weather Comparison: Compare weather data between different cities side-by-side
- π¨ Modern UI/UX: Beautiful, responsive design built with TailwindCSS
- β‘ Server-Side Rendering: Fast loading times with SSR implementation
- π± Mobile-First: Fully responsive design that works on all devices
- π State Management: Robust state management with Redux Toolkit
- π― Type Safety: Full TypeScript implementation for better development experience
- π Performance Optimized: Efficient data caching and loading states
- π Security: Comprehensive security headers and CSP policies
- React 19 - Modern React with latest features
- TypeScript - Type-safe JavaScript development
- TailwindCSS - Utility-first CSS framework
- React Router DOM - Client-side routing
- Redux Toolkit - State management
- Axios - HTTP client for API requests
- Express.js - Node.js web framework
- Vite - Fast build tool and development server
- Node.js - JavaScript runtime
- Compression - Response compression middleware
- ESLint - Code linting
- Prettier - Code formatting
- PostCSS - CSS processing
- Autoprefixer - CSS vendor prefixing
- OpenWeather API - Weather data provider
- Node.js (version 18 or higher)
- npm package manager
- OpenWeather API key
-
Clone the repository
git clone <repository-url> cd weather-app
-
Install dependencies
npm install
-
Environment Setup
Create a
.env
file in the root directory:VITE_OPENWEATHER_API_KEY=your_openweather_api_key_here
To get an OpenWeather API key:
- Visit OpenWeather API
- Sign up for a free account
- Generate an API key
- Add it to your
.env
file
-
Start the development server
npm run dev
-
Open your browser
Navigate to
http://localhost:5173
to view the application.
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Run linting
npm run lint
# Fix linting issues
npm run lint:fix
# Format code
npm run format
# Check code formatting
npm run format:check
Script | Description |
---|---|
dev |
Start development server with hot reload |
build |
Build both client and server for production |
build:client |
Build only client-side code |
build:server |
Build only server-side code |
preview |
Preview production build locally |
lint |
Run ESLint to check code quality |
lint:fix |
Automatically fix ESLint issues |
format |
Format code with Prettier |
format:check |
Check code formatting |
Variable | Description | Required |
---|---|---|
VITE_OPENWEATHER_API_KEY |
Your OpenWeather API key | Yes |
PORT |
Server port (default: 5173) | No |
BASE |
Base URL path (default: /) | No |
NODE_ENV |
Environment mode (development/production) | No |
File | Purpose | Description |
---|---|---|
tsconfig.json |
Main client configuration | Base TypeScript config for React app, IDE, and linting |
tsconfig.server.json |
Server configuration | Server-side compilation for SSR, excludes React components |
tsconfig.node.json |
Build tools configuration | Vite config compilation, enables project references |
File | Purpose | Description |
---|---|---|
vite.config.ts |
Client build | Vite configuration for client-side React app |
vite.config.ssr.ts |
SSR build | Vite configuration for server-side rendering bundle |
postcss.config.js |
CSS processing | PostCSS configuration with TailwindCSS and Autoprefixer |
tailwind.config.js |
CSS framework | TailwindCSS configuration and custom theme settings |
File | Purpose | Description |
---|---|---|
server.ts |
Main server | Express server with SSR, security headers, and Vite integration |
src/config/security.ts |
Security policies | Centralized security configuration (CSP, headers, policies) |
vercel.json |
Deployment | Vercel deployment configuration with security headers |
File | Purpose | Description |
---|---|---|
eslint.config.js |
Code linting | ESLint configuration with React and TypeScript rules |
.prettierrc |
Code formatting | Prettier configuration for consistent code style |
.prettierignore |
Format exclusions | Files and directories to exclude from formatting |
weather-app/
βββ π src/ # Source code
β βββ π components/ # React components
β β βββ π ComparisonPanel/ # Weather comparison feature
β β βββ π icons/ # SVG icon components
β β βββ ReduxDevTools.tsx # Development Redux state viewer
β β βββ WeatherDataCard.tsx # Weather data display component
β β βββ ...
β βββ π pages/ # Page components
β βββ π store/ # Redux store configuration
β βββ π services/ # API services
β βββ π hooks/ # Custom React hooks
β βββ π types/ # TypeScript type definitions
β βββ π utils/ # Utility functions
β βββ π config/ # Configuration files
β β βββ security.ts # Security policies and headers
β βββ π styles/ # Global styles
β βββ App.tsx # Main React application
β βββ entry-client.tsx # Client-side entry point
β βββ entry-server.tsx # Server-side rendering entry point
βββ π public/ # Static assets
βββ π dist/ # Build output
β βββ π client/ # Client-side build
β βββ π server/ # Server-side build
βββ π scripts/ # Build and utility scripts
βββ π .vercel/ # Vercel deployment cache
βββ π server.ts # Express server with SSR
βββ π vite.config.ts # Client build configuration
βββ π vite.config.ssr.ts # SSR build configuration
βββ π tsconfig.json # Main TypeScript configuration
βββ π tsconfig.server.json # Server TypeScript configuration
βββ π tsconfig.node.json # Build tools TypeScript configuration
βββ π postcss.config.js # CSS processing configuration
βββ π tailwind.config.js # TailwindCSS configuration
βββ π eslint.config.js # ESLint configuration
βββ π .prettierrc # Prettier configuration
βββ π vercel.json # Deployment configuration
βββ π vite-env.d.ts # Vite type declarations
βββ π package.json # Dependencies and scripts
βββ π README.md # This file
-
Client Build (
npm run build:client
)- Vite builds React app to
dist/client/
- Generates optimized HTML, CSS, and JavaScript
- Vite builds React app to
-
Server Build (
npm run build:server
)- Vite builds SSR bundle to
dist/server/entry-server.js
- TypeScript compiles server code to
dist/server/server.js
- Vite builds SSR bundle to
-
Production Server (
npm run preview
)- Runs compiled server from
dist/server/server.js
- Serves SSR-rendered HTML with security headers
- Runs compiled server from
-
Install Vercel CLI
npm i -g vercel
-
Deploy
vercel
-
Set Environment Variables
- Go to your Vercel dashboard
- Add
VITE_OPENWEATHER_API_KEY
to environment variables
-
Build the project
npm run build
-
Deploy to Netlify
- Drag and drop the
dist
folder to Netlify - Or connect your GitHub repository
- Drag and drop the
-
Set Environment Variables
- Go to Site settings > Environment variables
- Add
VITE_OPENWEATHER_API_KEY
-
Create Dockerfile
FROM node:18-alpine WORKDIR /app COPY package*.json ./ RUN npm ci --only=production COPY . . RUN npm run build EXPOSE 5173 CMD ["npm", "run", "preview"]
-
Build and run
docker build -t weather-app . docker run -p 5173:5173 -e VITE_OPENWEATHER_API_KEY=your_key weather-app
-
Build the project
npm run build
-
Upload files
- Upload the
dist
folder to your web server - Ensure your server supports Node.js
- Upload the
-
Start the server
npm run preview
The application implements comprehensive security measures:
- Content Security Policy (CSP): Restricts resource loading to trusted sources
- Security Headers: X-Frame-Options, X-XSS-Protection, HSTS, and more
- Input Validation: Server-side validation of all user inputs
- Rate Limiting: Protection against abuse (configurable)
- CORS Policies: Controlled cross-origin resource sharing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenWeather API for weather data
- TailwindCSS for the styling framework
- React for the frontend framework
- Vite for the build tool
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Include your environment details and error messages
Happy coding! π