This project is a FastAPI-based backend application for monitoring weather conditions in major Indian cities, providing daily summaries, and sending alerts based on user-defined thresholds.
- Real-time weather data fetching for major Indian cities (Delhi, Mumbai, Chennai, Bangalore, Kolkata, Hyderabad)
- Daily weather summaries
- Historical weather data retrieval
- CORS support for frontend integration
- Python 3.11+
- MongoDB Atlas account
-
Clone the repository:
git clone https://github.com/shrey258/zeotap_app2_backend.git cd zeotap_app2_backend
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Set up environment variables: Create a
.env
file in the root directory and add the following:OPENWEATHERMAP_API_KEY=your_api_key_here MONGO_URI=your_mongodb_atlas_connection_string CORS_ORIGINS=http://localhost:3000,https://yourdomain.com CORS_METHODS=GET,POST,PUT,DELETE CORS_HEADERS=Content-Type,Authorization
To start the server, run:
python -m uvicorn app.main:app --reload
The API will be available at http://localhost:8000
.
/weather/{city}
: Get current weather for a city/summaries/{city}/
: Get daily weather summaries for a city/weather-history/{city}
: Get historical weather data for a city
app/main.py
: Main application file with FastAPI app configurationapp/routes.py
: API route definitionsapp/services.py
: Core business logic for fetching weather dataapp/tasks.py
: Background task for continuous weather monitoringapp/models.py
: Pydantic models for data validationapp/config.py
: Configuration management using environment variablesapp/logger.py
: Custom logging setup
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.