Skip to content

CorpEdward/Middle-PHP-backend-assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

PHP Backend Assignment — Smartphone Product Manager

Level: Middle  |  Duration: 3 days  |  Stack: PHP 8.4+ · Laravel


Overview

Build a RESTful backend application using Laravel that manages a local catalog of smartphones. The app must integrate with the DummyJSON public API to seed initial data, and expose its own CRUD endpoints for managing those products.

This assignment tests your ability to:

  • Consume a third-party REST API
  • Design and implement a clean CRUD layer with a database
  • Structure a Laravel application following good practices
  • Write input validation and error handling
  • Cover your code with automated tests

Technical Requirements

  • PHP 8.4 or higher
  • Laravel (latest stable version)
  • Any database of your choice (MySQL, PostgreSQL, SQLite, etc.)
  • Eloquent ORM for all database interactions
  • Composer for dependency management

API Endpoints

Method Endpoint Description
GET /api/products List all products. Supports ?page=, ?limit=, ?brand=, and ?currency= query params.
GET /api/products/{id} Get a single product by its local database ID. Supports ?currency=.
POST /api/products Create a new product from a JSON body.
PATCH /api/products/{id} Partial update — only fields present in the request body are updated.
DELETE /api/products/{id} Delete a product by ID.

Artisan Command

In addition to the API endpoints above, provide a custom Artisan command (e.g. php artisan products:seed) that fetches all smartphones from the DummyJSON API and imports them into the local database. This replaces having a dedicated HTTP seed endpoint — seeding is an operational/setup task, not something the API should expose publicly.

  • The command should be idempotent (safe to run more than once without creating duplicate products).
  • Document the exact command to run in your submission README.

Multi-Currency Support

Product prices are stored locally in USD (the currency returned by the DummyJSON API). The API must also be able to return prices converted to UAH and EUR on request.

  • Add a ?currency=USD|EUR|UAH query parameter to GET /api/products and GET /api/products/{id}. When omitted, default to USD (the stored currency).
  • Exchange rates must be fetched from the National Bank of Ukraine (NBU) exchange rate API: https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange?format=json (the endpoint also supports a valcode filter, e.g. &valcode=USD, and returns the UAH value of one unit of the given currency for the current date)
  • Rates should be cached (e.g. once per day) rather than re-fetched on every request, and the caching strategy should be explained in your submission README.
  • Document in your README how you convert between currencies (e.g. USD → UAH directly via the NBU rate, USD → EUR via a UAH cross-rate) and how you handle the case where the NBU API is unavailable.

Submission Requirements

  1. Push your code to a public GitHub repository
  2. Include a README.md that explains:
    • What the project does and how it is structured
    • The database schema you designed (tables, columns, relationships)
    • How you decided to organize the Laravel application
  3. Cover the API endpoints with automated tests using a PHP testing framework of your choice (Pest, PHPUnit, Codeception, etc.)
  4. All tests must pass with a single command, e.g. php artisan test or ./vendor/bin/pest

Note on AI

AI tools are a normal part of modern development — feel free to use them. That said, be ready to walk us through your solution in a follow-up review: what you built, the decisions you made, and how you used AI along the way.


Good luck! We are looking forward to reading your code.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors