Stat-Weather API is a production-ready, serverless backend service that processes real-time weather data through a specialized statistical model to calculate a "Human Comfort Index" (SCI). Built with TypeScript and deployed on AWS, it demonstrates a modern approach to cloud-native application development and analytical data processing.
Serverless Architecture: Fully hosted on AWS Lambda, providing high scalability and zero maintenance.
Statistical Analysis: Raw meteorological data (Temperature, Humidity, Wind Speed) is transformed into a single "Comfort Score" using a weighted penalty algorithm.
Automated CI/CD Pipeline: Integration with GitHub Actions ensures that every code change is automatically built, tested, and deployed to the AWS Stockholm (eu-north-1) region.
Type-Safe Implementation: Developed using TypeScript to ensure robust error handling and maintainable code architecture.
The API calculates the human comfort level by measuring deviations from ideal environmental conditions. The model applies weighted penalties to different meteorological factors using the following formula:
-
Ideal Values:
- Optimal temperature (
$T_{ideal}$ ): 22°C - Optimal humidity (
$H_{ideal}$ ): 45%
- Optimal temperature (
Runtime: Node.js (via AWS Lambda)
Language: TypeScript
Infrastructure: AWS (API Gateway, Lambda, CloudWatch)
DevOps: GitHub Actions (CI/CD)
Data Provider: OpenWeatherMap API
Get Weather & Comfort Analysis Endpoint: GET /weather
Query Parameters: | Parameter | Type | Required | Description | | :--- | :--- | :--- | :--- | | city | string | No | The target city for analysis (Default: Ankara) |
Example Request: https://2ekmzv5ov7.execute-api.eu-north-1.amazonaws.com/weather?city=Istanbul
Example Response:
{ "city": "Istanbul", "temperature": "14.5°C", "humidity": "%65", "windSpeed": "4.2 m/s", "condition": "broken clouds", "comfortScore": 68, "message": "Caution is advised for outdoor activities." }
Node.js installed locally.
An active AWS Account with IAM credentials configured.
OpenWeatherMap API Key.
git clone https://github.com/your-repo/stat-weather-api.git
npm install
npx tsc
The project uses GitHub Actions for deployment. Ensure the following secrets are added to your GitHub repository settings:
AWS_ACCESS_KEY_ID: Your IAM access key.
AWS_SECRET_ACCESS_KEY: Your IAM secret key.
AWS_REGION: The target region (e.g., eu-north-1).