Skip to content

Latest commit

 

History

History
68 lines (50 loc) · 2.27 KB

File metadata and controls

68 lines (50 loc) · 2.27 KB

Weather Automation Study Case

This repository contains a small study case designed to explore FastAPI, asynchronous APIs, background tasks, validation, and service-oriented application structure.

The goal is to simulate how a real backend service would behave when dealing with APIs, background processing, validation layers, and basic authentication mechanisms.


Features

  • FastAPI REST API with two endpoints:
    • /healht: Service status check.
    • /weather: Returns mocked weather data by city.
  • Query parameter support (city, unit) to simulate dynamic response.
  • Mocked weather data instead of external API integration.
  • Basic request validation using Pydantic models.
  • JWT authentication via request headers (Authorization: Bearer <token>)
  • Background task executing using Celery workers.
  • Scheduled tasks using Celery Beat (hourly simulation of data fetching)
  • Redis integration as Celery broker.
  • Structured logging across modules.
  • Basic business rule validation before returning responses.
  • Error handling for invalid requests and authentication failures.

Commands

uv sync # Install dependencies
uv run src/main.py # Start the app (localhost:8000)
uv run celery -A src.tasks.celery_app worker --beat --pool=solo --loglevel=info # Start Celery

Limitations

  • No real external weather API integration.
  • No persistent database layer.
  • Authentication is simplified (no refresh tokens or user system)
  • Celery setup is minimal and intended only for study purposes.

Notes about .env

This project uses a .env file to manage sensitive configuration values, such as the JWT secret used for token encoding and decoding.

Since this is a study case, the .env file is not included in the repository.

To run the project locally, create a .env file in the root directory with the following content:

KEY=your_encoded_jwt_secret_key_here
SECRET=the_same_secret_used_to_encode_jwt_token_here

These values are required for JWT generation and validation to work correctly.


Final Notes

This project was developed as a personal study case to better understand FastAPI and common backend patterns in Python applications. It is intentionally simplified and focuses on learning core concepts rather than production readiness.