A real-time weather forecasting application with current conditions and 5-day forecasts.
- Current weather conditions display
- Hourly forecast (8 hours)
- 5-day weather forecast
- Unit toggle (Celsius/Fahrenheit)
- Recent searches history with PostgreSQL persistence
- Dark/Light mode theme toggle
- Responsive design for mobile, tablet, and desktop
- ⚛️ React
- 🔷 TypeScript
- 🔄 TanStack React Query
- 🎨 Tailwind CSS
- 🧩 Shadcn UI
- 🌐 Context API for state management
- 🟢 Node.js & Express
- 🐘 PostgreSQL database
- 💧 Drizzle ORM
- ✅ Zod validation
Before you begin, ensure you have the following installed:
- Node.js (version 18 or higher)
- npm (comes with Node.js)
- PostgreSQL database
Follow these steps to run the application locally:
git clone <repository-url>
cd weather-forecasting-app
npm install
Create a .env
file in the root directory with the following variables:
# Database connection (replace with your PostgreSQL details)
DATABASE_URL=postgresql://username:password@localhost:5432/weather_app
# OpenWeather API Key (required)
OPENWEATHER_API_KEY=your_openweather_api_key
Important: You need to obtain an OpenWeather API key from OpenWeatherMap. Sign up for a free account and get your API key from the dashboard.
Ensure PostgreSQL is running on your machine, then create the database:
# Create a new PostgreSQL database
createdb weather_app
# Run database migrations
npm run db:push
npm run dev
The application will be available at http://localhost:5000
/client
- Frontend React application/src/components
- UI components/src/context
- React context providers/src/hooks
- Custom React hooks/src/pages
- Page components
/server
- Backend Express serverroutes.ts
- API endpointsstorage.ts
- Database access layer
/shared
- Shared code between frontend and backendschema.ts
- Database schema and TypeScript types
GET /api/weather?city={cityName}
- Get weather data for a cityGET /api/recent-searches
- Get recent search historyPOST /api/recent-searches
- Add a city to recent searchesDELETE /api/recent-searches
- Clear recent search history