How tusharsinha007/climatepredictor works
Project Type and Purpose
• This is a full-stack climate tracking application that gathers weather data from OpenWeatherMap and integrates with several AWS services (Lambda, S3, API Gateway, CloudWatch) to store, process, and display weather data.
• It includes a frontend for data visualization and backend components (implemented in Python) that are deployed as AWS Lambda functions.
Analyzing the File Structure
• The top-level files (README.md, api.py, live_weather_api.py, weather_prediction.py) hint at backend logic, possibly used as AWS Lambda functions.
• The “frontend” directory contains the web assets (HTML, CSS, JS) that provide the interactive user interface – note files like index.html and aws-config.js.
• The “mock” directory holds sample CSV and JSON files used for testing or simulating various weather scenarios.
• Other CSV files (weather_forecast.csv, processed_chennai_weather.csv) indicate processed data which is likely stored and referenced in S3.
• The requirements.txt shows third-party dependencies.
Key Components Identified
a. Frontend
– Located in the “frontend” folder (index.html, CSS, JS).
– Interacts with AWS API Gateway (configured via aws-config.js) to retrieve weather data.
b. AWS Lambda Functions
– Two primary Lambda functions are described: one for current weather data collection (e.g., implemented in lambda_function.py or live_weather_api.py) and one for retrieving historical data (referenced in the README).
– They are responsible for invoking the OpenWeatherMap API, processing weather data, and storing/retrieving data from S3.
c. Amazon API Gateway
– Serves as the RESTful API endpoint for the frontend to interact with.
– The README details endpoints like /weather and /historical which map to corresponding Lambda functions.
d. Amazon S3
– Used for storage of the weather data, largely in CSV format (as evidenced by the CSV files in the file tree and README instructions to create an S3 bucket).
e. Amazon CloudWatch
– Used for monitoring and logging the activity of Lambda functions and overall system performance.
f. External Weather API (OpenWeatherMap)
– The data source from which real-time weather information is retrieved.
g. AWS EventBridge (CloudWatch Events)
– Used to schedule the regular invocation of the weather collection Lambda function.
• The Frontend (user’s web browser) sends HTTP requests to the API Gateway (configured with endpoints such as /weather and /historical).
• API Gateway routes these requests to the respective AWS Lambda functions.
• The “Data Collection Lambda” function connects to the external OpenWeatherMap API to fetch current weather data.
• Once retrieved, this Lambda function stores weather data (in CSV format) into the Amazon S3 bucket.
• The “Data Retrieval Lambda” function fetches historical weather data from S3 when requested.
• Both Lambda functions log events to CloudWatch for monitoring purposes.
• AWS EventBridge is configured to trigger the Data Collection Lambda function periodically.
[User / Browser]
│
▼
[Frontend (index.html, JS)]
│ (configured via aws-config.js)
▼
[Amazon API Gateway] ──► Routes REST requests ──► [AWS Lambda Functions]
│ ├── (Data Collection Lambda: calls OpenWeatherMap API ──► [OpenWeatherMap API])
│ │ └─► Stores CSV data into [Amazon S3]
│ └── (Data Retrieval Lambda: reads from Amazon S3)
│
▼
[Amazon CloudWatch] (Monitoring & Logging of Lambda functions)
• Additional supporting interactions:
• AWS EventBridge periodically triggers the Data Collection Lambda.
Architectural Patterns
• The application follows a decoupled architecture where the frontend and backend are clearly separated.
• It relies on serverless components (AWS Lambda functions) to reduce management overhead.
• There is a clear request-response pattern between the frontend and backend through the API Gateway.
• The storage layer is segregated from the compute logic (data stored in S3 and processed in Lambda).