How manojbaniya444/currency-converter3 works
Project type and purpose
• This is a backend-only, RESTful API service built in FastAPI.
• It provides currency exchange rates & conversion endpoints.
• It optionally uses Redis (via docker-compose) to cache exchange data and offload repeated requests.
File structure
Top-level directories & files:
• app/ – application code
– api/routes/converter.py: HTTP endpoints for conversion
– api/dependencies.py: DI for cache, config, services
– core/config.py: environment & config loading
– services/exchange_service.py: business logic, external-API & cache calls
– main.py: FastAPI app instance & router registration
• requirements.txt: Python dependencies (FastAPI, redis, httpx, etc.)
• docker-compose.yml: Redis service + FastAPI service definition
• Dockerfile: containerizes the FastAPI app
• tests/: simple smoke-test for health check
• .github/workflows: CI for linting & deployment
Extract README insights
• App exposes documentation at /docs (Swagger UI).
• Supports Docker Compose (“docker-compose up” spins up Redis & app).
• Screenshots demonstrate request→response on converter endpoint.
Main components to reflect
a. Client / Consumer (e.g. browser, curl, mobile app)
b. API Layer
• FastAPI application (containerized)
• Router (converter endpoints)
c. Service Layer
• ExchangeService: orchestrates cache lookups & external API calls
d. Cache Layer
• Redis instance (caching exchange rates)
e. External Currency Provider
• Third-party REST API (e.g. exchangeratesapi.io)
f. Configuration & DI
• Config service loads .env
• Dependencies inject cache & service into routes
Relationships & interactions
1. Client → HTTP request → FastAPI converter endpoint
2. Endpoint → Dependency-injected ExchangeService
3. ExchangeService:
a. Checks Redis for cached rate
b. If missing, calls external API → gets rate → stores in Redis
c. Applies conversion logic → returns result
4. FastAPI → HTTP response → Client
Architectural patterns & principles
• Layered architecture: API layer → Service layer → Cache/External API
• Dependency Injection (app/api/dependencies.py) to decouple components
• Single responsibility: routes only marshal requests; business logic in services
• Containerization: each service in own Docker container; networked via docker-compose
Essential elements to capture
• Component names & responsibilities
• Data-flow directions & decision points (cache hit vs. miss)
• Deployment context (Docker, Compose network)
• Technology labels: FastAPI, Python 3.x, Redis, Docker