# gopal092003/currency-converter-api architecture

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

- Interactive diagram: https://gitdiagram.com/gopal092003/currency-converter-api
- Repository: https://github.com/gopal092003/currency-converter-api

## Overview

This is a FastAPI currency-conversion service. Its public workflow accepts conversion or rate queries, retrieves reference rates from Frankfurter, validates and normalizes provider data, and returns converted amounts or rate results. The README also documents historical, time-series, currency-listing, and liveness capabilities. Database, API-key, usage, rate-limit, cache, worker, and observability modules exist, but the README says several are not connected to public routes or middleware; those are shown as supporting, optional subsystems. Some internal wiring is omitted where source was not sampled.

Main entry points: [`app/api/v1/router.py`](https://github.com/gopal092003/currency-converter-api/blob/main/app/api/v1/router.py) (V1 routes), [`app/modules/currency/service.py`](https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/currency/service.py) (Conversion service), [`app/modules/rates/service.py`](https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/rates/service.py) (Rate service), [`app/modules/providers/base.py`](https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/providers/base.py) (Provider interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_v1router["V1 routes<br/>[router.py]"]
  node_convert_endpoint["Convert endpoint<br/>[convert.py]"]
  node_rates_endpoint["Rates endpoints<br/>[rates.py]"]
  node_currencies_endpoint["Currencies endpoint<br/>[currencies.py]"]
  node_health["Liveness check<br/>[health.py]"]
  node_error_handling["Error envelopes<br/>[error_handlers.py]"]
end

subgraph group_domain["Currency and Rates"]
  node_rate_service["Rate service<br/>[service.py]"]
  node_conversion_service["Conversion service<br/>[service.py]"]
  node_rounding["Decimal rounding<br/>[rounding.py]"]
  node_rate_schemas["Rate validation<br/>[schemas.py]"]
  node_currency_schemas["Currency validation<br/>[schemas.py]"]
end

subgraph group_providers["Rate Providers"]
  node_provider_interface["Provider interface<br/>[base.py]"]
  node_provider_factory["Provider selection<br/>[factory.py]"]
  node_frankfurter["Frankfurter client<br/>[frankfurter.py]"]
end

subgraph group_support["Supporting Modules"]
  node_api_key["API-key management<br/>[service.py]"]
  node_api_key_store["API-key repository<br/>[repository.py]"]
  node_database[("Database<br/>[session.py]")]
  node_usage["Usage and quota<br/>[service.py]"]
  node_rate_limit["Rate limiting<br/>[middleware.py]"]
  node_rate_cache["Rate cache<br/>[cache.py]"]
  node_refresh_worker["Rate refresh worker<br/>[rate_refresh.py]"]
  node_metrics["Metrics<br/>[metrics.py]"]
end

node_caller(("API client"))

node_caller -->|"requests API"| node_v1router
node_v1router -->|"routes to"| node_convert_endpoint
node_v1router -->|"routes to"| node_rates_endpoint
node_v1router -->|"routes to"| node_currencies_endpoint
node_caller -->|"checks liveness"| node_health
node_rates_endpoint -.->|"retrieves rates"| node_rate_service
node_currencies_endpoint -.->|"retrieves latest rates"| node_rate_service
node_convert_endpoint -.->|"converts amount"| node_conversion_service
node_rate_service -->|"requests rate data"| node_provider_interface
node_conversion_service -->|"requests latest rate"| node_provider_interface
node_conversion_service -->|"rounds result"| node_rounding
node_rate_service -->|"validates data"| node_rate_schemas
node_conversion_service -->|"uses request and result"| node_currency_schemas
node_provider_factory -.->|"selects provider"| node_frankfurter
node_frankfurter -.->|"implements"| node_provider_interface
node_api_key -->|"persists keys"| node_api_key_store
node_api_key -->|"uses session"| node_database
node_usage -.->|"stores usage"| node_database
node_rate_limit -.->|"uses storage"| node_rate_cache
node_refresh_worker -->|"fetches rates"| node_provider_interface
node_refresh_worker -->|"writes refreshed rates"| node_rate_cache
node_refresh_worker -->|"records outcomes"| node_metrics

click node_v1router "https://github.com/gopal092003/currency-converter-api/blob/main/app/api/v1/router.py"
click node_convert_endpoint "https://github.com/gopal092003/currency-converter-api/blob/main/app/api/v1/endpoints/convert.py"
click node_rates_endpoint "https://github.com/gopal092003/currency-converter-api/blob/main/app/api/v1/endpoints/rates.py"
click node_currencies_endpoint "https://github.com/gopal092003/currency-converter-api/blob/main/app/api/v1/endpoints/currencies.py"
click node_rate_service "https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/rates/service.py"
click node_conversion_service "https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/currency/service.py"
click node_rounding "https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/currency/rounding.py"
click node_rate_schemas "https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/rates/schemas.py"
click node_currency_schemas "https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/currency/schemas.py"
click node_provider_interface "https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/providers/base.py"
click node_provider_factory "https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/providers/factory.py"
click node_frankfurter "https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/providers/frankfurter.py"
click node_health "https://github.com/gopal092003/currency-converter-api/blob/main/app/observability/health.py"
click node_error_handling "https://github.com/gopal092003/currency-converter-api/blob/main/app/core/error_handlers.py"
click node_api_key "https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/auth/service.py"
click node_api_key_store "https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/auth/repository.py"
click node_database "https://github.com/gopal092003/currency-converter-api/blob/main/app/db/session.py"
click node_usage "https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/usage/service.py"
click node_rate_limit "https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/rate_limiting/middleware.py"
click node_rate_cache "https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/rates/cache.py"
click node_refresh_worker "https://github.com/gopal092003/currency-converter-api/blob/main/app/workers/rate_refresh.py"
click node_metrics "https://github.com/gopal092003/currency-converter-api/blob/main/app/observability/metrics.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_v1router,node_convert_endpoint,node_rates_endpoint,node_currencies_endpoint,node_health,node_error_handling,node_caller toneBlue
class node_rate_service,node_conversion_service,node_rounding,node_rate_schemas,node_currency_schemas toneAmber
class node_provider_interface,node_provider_factory,node_frankfurter toneMint
class node_api_key,node_api_key_store,node_database,node_usage,node_rate_limit,node_rate_cache,node_refresh_worker,node_metrics toneRose
```

## Components

### Public API

- [V1 routes](https://github.com/gopal092003/currency-converter-api/blob/main/app/api/v1/router.py): `app/api/v1/router.py`
- [Convert endpoint](https://github.com/gopal092003/currency-converter-api/blob/main/app/api/v1/endpoints/convert.py): `app/api/v1/endpoints/convert.py`
- [Rates endpoints](https://github.com/gopal092003/currency-converter-api/blob/main/app/api/v1/endpoints/rates.py): `app/api/v1/endpoints/rates.py`
- [Currencies endpoint](https://github.com/gopal092003/currency-converter-api/blob/main/app/api/v1/endpoints/currencies.py): `app/api/v1/endpoints/currencies.py`
- [Liveness check](https://github.com/gopal092003/currency-converter-api/blob/main/app/observability/health.py): `app/observability/health.py`
- [Error envelopes](https://github.com/gopal092003/currency-converter-api/blob/main/app/core/error_handlers.py): `app/core/error_handlers.py`

### Currency and Rates

- [Rate service](https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/rates/service.py): `app/modules/rates/service.py`
- [Conversion service](https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/currency/service.py): `app/modules/currency/service.py`
- [Decimal rounding](https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/currency/rounding.py): `app/modules/currency/rounding.py`
- [Rate validation](https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/rates/schemas.py): `app/modules/rates/schemas.py`
- [Currency validation](https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/currency/schemas.py): `app/modules/currency/schemas.py`

### Rate Providers

- [Provider interface](https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/providers/base.py): `app/modules/providers/base.py`
- [Provider selection](https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/providers/factory.py): `app/modules/providers/factory.py`
- [Frankfurter client](https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/providers/frankfurter.py): `app/modules/providers/frankfurter.py`

### Supporting Modules

- [API-key management](https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/auth/service.py): `app/modules/auth/service.py`
- [API-key repository](https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/auth/repository.py): `app/modules/auth/repository.py`
- [Database](https://github.com/gopal092003/currency-converter-api/blob/main/app/db/session.py): `app/db/session.py`
- [Usage and quota](https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/usage/service.py): `app/modules/usage/service.py`
- [Rate limiting](https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/rate_limiting/middleware.py): `app/modules/rate_limiting/middleware.py`
- [Rate cache](https://github.com/gopal092003/currency-converter-api/blob/main/app/modules/rates/cache.py): `app/modules/rates/cache.py`
- [Rate refresh worker](https://github.com/gopal092003/currency-converter-api/blob/main/app/workers/rate_refresh.py): `app/workers/rate_refresh.py`
- [Metrics](https://github.com/gopal092003/currency-converter-api/blob/main/app/observability/metrics.py): `app/observability/metrics.py`

### Other components

- **API client**

## Connections

- API client → V1 routes: requests API (evidence: `README.md`)
- V1 routes → Convert endpoint: routes to (evidence: `app/api/v1/router.py`)
- V1 routes → Rates endpoints: routes to (evidence: `app/api/v1/router.py`)
- V1 routes → Currencies endpoint: routes to (evidence: `app/api/v1/router.py`)
- API client → Liveness check: checks liveness (evidence: `README.md`)
- Rates endpoints → Rate service: retrieves rates
- Currencies endpoint → Rate service: retrieves latest rates
- Convert endpoint → Conversion service: converts amount
- Rate service → Provider interface: requests rate data (evidence: `app/modules/rates/service.py`)
- Conversion service → Provider interface: requests latest rate (evidence: `app/modules/currency/service.py`)
- Conversion service → Decimal rounding: rounds result (evidence: `app/modules/currency/service.py`)
- Rate service → Rate validation: validates data (evidence: `app/modules/rates/service.py`)
- Conversion service → Currency validation: uses request and result (evidence: `app/modules/currency/service.py`)
- Provider selection → Frankfurter client: selects provider
- Frankfurter client → Provider interface: implements
- API-key management → API-key repository: persists keys (evidence: `app/modules/auth/service.py`)
- API-key management → Database: uses session (evidence: `app/modules/auth/router.py`)
- Usage and quota → Database: stores usage
- Rate limiting → Rate cache: uses storage
- Rate refresh worker → Provider interface: fetches rates (evidence: `app/workers/rate_refresh.py`)
- Rate refresh worker → Rate cache: writes refreshed rates (evidence: `app/workers/rate_refresh.py`)
- Rate refresh worker → Metrics: records outcomes (evidence: `app/workers/rate_refresh.py`)
