Skip to content

kundannanubala/weatherApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weather App

A modern weather application built with React.js and FastAPI that provides real-time weather information and forecasts with AI-powered weather analysis.

Features

  • Real-time weather data from OpenWeatherMap API
  • Current weather conditions and forecasts
  • AI-powered weather analysis and suggestions using Groq
  • City search functionality
  • Responsive design with dark mode support
  • Live clock and date display
  • Weather data export to Excel
  • CRUD operations for saving weather data

Tech Stack

Frontend

  • React 19
  • Tailwind CSS
  • Environment Variables

Backend

  • FastAPI
  • Python 3
  • MongoDB
  • Groq for AI analysis
  • python-dotenv for environment management

Prerequisites

  • Node.js (Latest LTS version recommended)
  • Python 3.8 or higher
  • MongoDB installed and running
  • OpenWeatherMap API key
  • Groq API key

API Keys Setup

OpenWeatherMap API Key

  1. Visit OpenWeatherMap
  2. Sign up for a free account
  3. Navigate to "API Keys" section in your account
  4. Copy your API key

Groq API Key

  1. Visit Groq Cloud
  2. Create an account and sign in
  3. Navigate to API Keys section
  4. Generate a new API key

Installation

Backend Setup

  1. Clone the repository and navigate to the backend directory:
cd backend
  1. Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
  1. Install the required packages:
pip install -r requirements.txt
  1. Create a .env file in the backend directory:
weatherAPI=your_openweathermap_api_key
groqAPI=your_groq_api_key
MongoDB_URI=mongodb://localhost:27017

Frontend Setup

  1. Navigate to the frontend directory:
cd frontend
  1. Install the required packages:
npm install
  1. Create a .env.local file in the frontend directory:
NEXT_PUBLIC_API_URL=http://localhost:8000

Database Setup

  1. Install MongoDB if not already installed
  2. Start MongoDB service:
# Linux/Mac
sudo service mongod start

# Windows
net start MongoDB
  1. The application will automatically create required collections

Running the Application

Start the Backend Server

cd backend
uvicorn app:app --reload

The backend server will start at http://localhost:8000

Start the Frontend Development Server

cd frontend
npm run dev

The frontend will be available at http://localhost:3000

Project Structure

Frontend

  • /src/app: Main application pages
  • /src/components: Reusable React components
  • /src/types: TypeScript type definitions
  • /public: Static assets

Backend

  • /api: API route handlers
  • /services: Business logic and external service integrations
  • /core: Core configuration and settings

API Endpoints

Weather Endpoints

  • GET /api/weather: Get weather data for specific coordinates
    • Parameters: lat (float), lon (float)
    • Returns current weather and forecasts

Location Endpoints

  • GET /api/location: Get coordinates for a city
    • Parameters:
      • city (string, required)
      • country_code (string, optional)
      • state_code (string, optional)
      • limit (int, optional, default=1)

Icon Endpoints

  • GET /api/icon: Get weather icon
    • Parameters:
      • icon_code (string)
      • size (string, optional, default="2x")

Database Setup

  1. Install MongoDB if not already installed
  2. Start MongoDB service:
# Linux/Mac
sudo service mongod start

# Windows
net start MongoDB
  1. The application will automatically create required collections

Running the Application

Start the Backend Server

cd backend
uvicorn app:app --reload

The backend server will start at http://localhost:8000

Start the Frontend Development Server

cd frontend
npm start

The frontend will be available at http://localhost:3000

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors