A React-based weather application that integrates with the OpenWeatherMap API to display current weather conditions for any city.
- Search weather by city name
- Display current temperature, conditions, humidity, and wind speed
- Google Material Design 3 theme with modern UI/UX
- Responsive design for mobile, tablet, and desktop
- Real-time weather data from OpenWeatherMap API
- Comprehensive error handling
- Loading states and user feedback
- Smooth animations and transitions
- Accessible design with ARIA labels
- React 18 with TypeScript
- Vite for fast development and building
- Tailwind CSS with Material Design 3 color system
- Material Icons for consistent iconography
- Jest and React Testing Library for unit testing
- fast-check for property-based testing
weather-app/
├── src/
│ ├── components/ # React components
│ ├── services/ # API client services
│ ├── types/ # TypeScript type definitions
│ ├── utils/ # Utility functions
│ ├── App.tsx # Root component
│ ├── main.tsx # Application entry point
│ └── index.css # Global styles with Tailwind
├── .env # Environment variables (not committed)
├── .env.example # Environment variables template
└── package.json # Project dependencies
- Node.js 18+ and npm
-
Clone the repository
-
Install dependencies:
npm install
-
Set up your OpenWeatherMap API key:
- Copy
.env.exampleto.env - Get a free API key from OpenWeatherMap
- Add your API key to
.env:VITE_OPENWEATHER_API_KEY=your_api_key_here
- Copy
Run the development server:
npm run devRun all tests:
npm testRun tests in watch mode:
npm run test:watchBuild for production:
npm run buildPreview production build:
npm run previewThis application uses the OpenWeatherMap API to fetch real-time weather data. Follow these steps to configure your API key:
- Visit OpenWeatherMap and click "Sign In" or "Sign Up"
- Create a free account (no credit card required)
- After logging in, navigate to your API keys page
- You'll see a default API key already generated, or you can create a new one by:
- Entering a name for your API key
- Clicking "Generate"
- Copy your API key (it looks like:
4b2b5c4542ee7064gg87fc4g8733c083)
Note: New API keys may take a few minutes to activate. If you get a 401 error initially, wait 10-15 minutes and try again.
-
In the project root directory, copy the
.env.examplefile to create a new.envfile:cp .env.example .env
-
Open the
.envfile in your text editor -
Replace the placeholder API key with your actual OpenWeatherMap API key:
VITE_OPENWEATHER_API_KEY=your_actual_api_key_here -
Save the file
Important Security Notes:
- Never commit your
.envfile to version control (it's already in.gitignore) - Never share your API key publicly
- If you accidentally expose your API key, regenerate a new one immediately from the OpenWeatherMap dashboard
After setting up your API key:
- Start the development server:
npm run dev - Open the app in your browser
- Search for any city (e.g., "London")
- If configured correctly, you should see weather data
- If you see an "Invalid API key" error, double-check that:
- Your API key is correctly copied to the
.envfile - There are no extra spaces or quotes around the API key
- Your API key has been activated (wait 10-15 minutes after generation)
- Your API key is correctly copied to the
This application follows Google Material Design 3 (Material You) principles:
- Primary: Purple/Blue tones for main actions and key UI elements
- Secondary: Teal/Cyan for accents and supporting elements
- Error: Red tones for error states and warnings
- Surface: Light backgrounds with subtle variations
- Background: Soft gradients for visual depth
Material Design typography scale is used throughout:
- Display: Large headings (display-large, display-medium, display-small)
- Headline: Section headings (headline-large, headline-medium, headline-small)
- Title: Subsection titles (title-large, title-medium, title-small)
- Body: Regular text (body-large, body-medium, body-small)
- Label: UI labels and buttons (label-large, label-medium, label-small)
Material Design elevation system (shadow-md-1 through shadow-md-5) provides depth and hierarchy.
- Duration: Short (75-150ms), Medium (200-300ms), Long (400-500ms)
- Easing: Material motion curves for natural feel
- Transitions: Smooth state changes and hover effects
Material Icons are used consistently throughout the application for a cohesive visual language.
The application uses a dual testing approach:
- Unit Tests: Test specific examples, edge cases, and component behavior
- Property-Based Tests: Verify universal properties hold across all inputs using fast-check
All tests are located alongside their source files with .test.ts or .test.tsx extensions.
- Chrome/Edge (latest)
- Firefox (latest)
- Safari (latest)
- Mobile browsers (iOS Safari, Chrome Mobile)
MIT