Skip to content

Conversation

@Vasundhara369
Copy link

Exchange Rate Updater

Application that fetches exchange rates from Czech National Bank (CNB) for specified currencies.

Separation of Concerns

The codebase follows a clear layered architecture:

  1. Models (Currency, ExchangeRate) - Domain entities with validation
  2. Services - Business logic
    • ExchangeRateProvider - Main service that coordinates exchange rate retrieval
    • CnbExchangeRateService - HTTP client for CNB API communication
    • CnbResponseParser - XML parsing logic
  3. Configuration - Dependency injection setup and configuration options
  4. Constants - Centralized magic strings and formats

Key Design Principles Used

Single Responsibility Principle: Each class has one clear purpose:

  • CnbExchangeRateService - HTTP communication only
  • CnbResponseParser - XML parsing only
  • ExchangeRateProvider - Business logic only

Dependency Injection: All dependencies injected via constructors

Interface-based Design: Interfaces (ICnbExchangeRateService, ICnbResponseParser) allow for swapping without changing business logic.

Reliability & Resilience

  • Retry Policy: 3 retries with exponential backoff for network failures
  • Circuit Breaker: Opens after 5 consecutive failures for 30 seconds to prevent hammering the CNB API
  • Error Handling: All exceptions caught, logged, and wrapped in CnbApiException
  • Timeout Protection: Configurable HTTP timeout (default 30 seconds)
  • Date Validation: Validates that response date matches requested date, logs warnings on mismatch

Future Improvements

  1. Caching: In-memory cache with date-based expiration
  2. Metrics: Application performance monitoring and metrics collection
  3. Health Checks: Health check endpoint for service monitoring
  4. Integration Tests: Tests against real CNB API (not just mocks)
  5. REST API: Expose as ASP.NET Core Web API for external consumption
  6. Rate Limiting: If making many calls, throttle requests to CNB API
  7. Database Storage: Store historical rates for tracking over time

Notes

  • CNB rates are quoted against CZK (base currency)
  • Some currencies have amounts > 1 (e.g., JPY is per 100 units) - rates are normalized to "CZK per 1 unit"
  • Base currency (CZK) is automatically skipped
  • Currencies not provided by CNB are silently ignored
  • Application uses Czech culture (cs-CZ) for parsing decimal values (uses comma as decimal separator)

@wiz-trial-29da161873
Copy link

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 2 Medium
Total 2 Medium

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant