# sachinparulkar270886/sezzle_home_assessment architecture

> Architecture diagram of the GitHub repository sachinparulkar270886/sezzle_home_assessment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sachinparulkar270886/sezzle_home_assessment
- Repository: https://github.com/sachinparulkar270886/sezzle_home_assessment

## Overview

Sezzle Weather Service is a FastAPI application for current-city weather lookups. A browser or API client submits a city; the API validates it and calls the weather service, which checks Redis, queries Open-Meteo on a miss, normalizes the result, and records successful responses in MySQL. The service also provides health/readiness checks, request protections, structured logs, and Prometheus metrics. The graph reflects the shown source and README; some startup wiring and operational details are documented but not fully excerpted.

Main entry points: [`app/main.py`](https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/main.py) (FastAPI Routes), [`app/weather.py`](https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/weather.py) (Weather Service), [`app/cache.py`](https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/cache.py) (Weather Cache), [`app/database.py`](https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/database.py) (Weather Repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_api["FastAPI Routes<br/>[main.py]"]
  node_settings["Service Settings<br/>[config.py]"]
end

subgraph group_weather["Weather Lookup"]
  node_weather_service["Weather Service<br/>[weather.py]"]
  node_weather_schema["Weather Models<br/>[schemas.py]"]
  node_open_meteo["Open-Meteo"]
end

subgraph group_state["Persistence"]
  node_cache["Weather Cache<br/>[cache.py]"]
  node_redis[("Redis")]
  node_repository["Weather Repository<br/>[database.py]"]
  node_mysql[("MySQL Logs")]
end

subgraph group_ops["Operations"]
  node_metrics["Metrics and Logging<br/>[observability.py]"]
end

node_client(("Browser / Client"))
node_prometheus["Prometheus"]

node_client -->|"requests weather"| node_api
node_api -->|"uses settings"| node_settings
node_api -->|"requests lookup"| node_weather_service
node_api -->|"validates response"| node_weather_schema
node_api -->|"checks readiness"| node_cache
node_api -->|"checks readiness"| node_repository
node_api -->|"installs request metrics"| node_metrics
node_weather_service -->|"reads and writes"| node_cache
node_cache -->|"stores entries"| node_redis
node_weather_service -->|"fetches conditions"| node_open_meteo
node_weather_service -->|"builds response"| node_weather_schema
node_weather_service -->|"records result"| node_repository
node_repository -->|"persists response"| node_mysql
node_cache -->|"records cache events"| node_metrics
node_weather_service -->|"records provider events"| node_metrics
node_repository -->|"records DB events"| node_metrics
node_prometheus -->|"scrapes metrics"| node_api

click node_api "https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/main.py"
click node_settings "https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/config.py"
click node_weather_service "https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/weather.py"
click node_weather_schema "https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/schemas.py"
click node_cache "https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/cache.py"
click node_repository "https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/database.py"
click node_metrics "https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/observability.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api,node_settings,node_client toneBlue
class node_weather_service,node_weather_schema,node_open_meteo toneAmber
class node_cache,node_redis,node_repository,node_mysql toneMint
class node_metrics toneRose
class node_prometheus toneIndigo
```

## Components

### HTTP API

- [FastAPI Routes](https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/main.py): `app/main.py`
- [Service Settings](https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/config.py): `app/config.py`

### Weather Lookup

- [Weather Service](https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/weather.py): `app/weather.py`
- [Weather Models](https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/schemas.py): `app/schemas.py`
- **Open-Meteo**

### Persistence

- [Weather Cache](https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/cache.py): `app/cache.py`
- **Redis**
- [Weather Repository](https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/database.py): `app/database.py`
- **MySQL Logs**

### Operations

- [Metrics and Logging](https://github.com/sachinparulkar270886/sezzle_home_assessment/blob/master/app/observability.py): `app/observability.py`

### Other components

- **Browser / Client**
- **Prometheus**

## Connections

- Browser / Client → FastAPI Routes: requests weather (evidence: `README.md`)
- FastAPI Routes → Service Settings: uses settings (evidence: `app/main.py`)
- FastAPI Routes → Weather Service: requests lookup (evidence: `app/main.py`)
- FastAPI Routes → Weather Models: validates response (evidence: `app/main.py`)
- FastAPI Routes → Weather Cache: checks readiness (evidence: `app/main.py`)
- FastAPI Routes → Weather Repository: checks readiness (evidence: `app/main.py`)
- FastAPI Routes → Metrics and Logging: installs request metrics (evidence: `app/main.py`)
- Weather Service → Weather Cache: reads and writes (evidence: `app/weather.py`)
- Weather Cache → Redis: stores entries (evidence: `app/cache.py`)
- Weather Service → Open-Meteo: fetches conditions (evidence: `app/weather.py`)
- Weather Service → Weather Models: builds response (evidence: `app/weather.py`)
- Weather Service → Weather Repository: records result (evidence: `app/weather.py`)
- Weather Repository → MySQL Logs: persists response (evidence: `README.md`)
- Weather Cache → Metrics and Logging: records cache events (evidence: `app/cache.py`)
- Weather Service → Metrics and Logging: records provider events (evidence: `app/weather.py`)
- Weather Repository → Metrics and Logging: records DB events (evidence: `app/database.py`)
- Prometheus → FastAPI Routes: scrapes metrics (evidence: `README.md`)
