A Laravel 12 backend application that serves a smartphone product catalog with real-time currency conversion (USD to UAH) using the National Bank of Ukraine (NBU) exchange rates.
- Browse smartphone catalog sourced from DummyJSON
- View prices in USD (original) or UAH (converted via NBU rates)
- Retrieve the current USD/UAH exchange rate from the NBU API
- Modular domain-driven architecture for the Currency module
- PHP ^8.2
- Laravel 12
- PHPUnit 11 for testing
- Docker via Laravel Sail (PHP 8.5, MySQL 8.4, Redis, Memcached)
Returns a list of smartphones with prices in the requested currency.
| Parameter | Type | Allowed Values | Description |
|---|---|---|---|
currency |
string | usd, uah |
Currency for product prices |
Response (200):
{
"data": [
{
"id": 1,
"title": "iPhone 5s",
"price": 199.99,
"rating": 2.83,
"thumbnail": "https://cdn.dummyjson.com/..."
}
]
}Unsupported currencies return 404.
Returns the current USD to UAH exchange rate from the NBU.
Response (200):
{
"data": {
"currencyCode": "USD",
"rate": 43.0996,
"exchangeDate": "02.03.2026"
}
}app/
├── Http/
│ ├── Controllers/
│ │ └── CatalogController.php # Smartphone catalog endpoint
│ └── Requests/
│ └── CatalogRequest.php # Validates currency parameter
├── Models/
│ └── User.php
└── Modules/
└── Currency/
├── Application/
│ ├── Facades/
│ │ └── CurrencyExchangeFacade.php # Entry point for currency operations
│ └── Http/
│ ├── Controllers/
│ │ └── ExchangeRateController.php
│ └── Requests/
│ └── ExchangeRateRequest.php
├── Domain/
│ ├── ConvertedPrice.php # DTO for converted price data
│ ├── CurrencyExchangeService.php # Core exchange logic
│ └── CurrencyRate.php # DTO for rate data
├── Infrastructure/
│ └── NbuApiCurrencyRepository.php # NBU API integration
└── Providers/
└── CurrencyServiceProvider.php # DI bindings
- PHP 8.2+ (or Docker)
- Composer
- Node.js & npm
composer setupThis runs composer install, copies .env.example to .env, generates the app key, runs migrations, and builds frontend assets.
cp .env.example .env
# Start the containers
./vendor/bin/sail up -d
# Install dependencies and set up the application
./vendor/bin/sail composer setupThe application will be available at http://localhost.
composer devThis starts the Laravel dev server, queue worker, log watcher (Pail), and Vite concurrently.
composer testOr directly with PHPUnit:
php artisan testTests use Http::fake() to mock external API calls (DummyJSON and NBU), so no network access is needed.
- Catalog endpoint — USD/UAH responses, price conversion, currency validation, HTTP method restrictions
- Exchange rate endpoint — JSON structure, rate values, HTTP method restrictions
- Both endpoints verified to not require authentication
| API | Purpose | URL |
|---|---|---|
| DummyJSON | Smartphone product data | https://dummyjson.com/products/category/smartphones |
| NBU | USD/UAH exchange rate | https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange |