Domain Languages:
- Customer.
- Marketeer (Sales person).
- Basket.
Basket API consists of:
- Customer can add products.
- Customer can delete products.
- Customer can increment products.
- Marketeer person can list all the user's baskets (including previous which are checkout) and items.
- Some errors are also handled such trying to remove an item which does not exist in the basket.
Technical Notes:
- To demonstrate Domain Driven Design approach; I treated Customer's Basket as a Model of a domain. By this
everything
is segregated to its own folder
models/Basket
. Although, for such small projects DDD is over engineering. - There are around eight testcases written, yet some are missing.
- Some functionality can be more furnish.
- PHP 8.0 is now a standard for this project.
- Laravel 8, Sanctum and Jetstream is used.
Setting UP
- Get the clone and checkout to
solved
branch. - Run
vendor/bin/sail up -d
to build and run images. - Run
vendor/bin/sail composer install
if needed and make sure.env
is present. - Run
vendor/bin/sail artisan migrate
. - Run
vendor/bin/sail test models/Basket/Tests
to run the tests.
Notes:
- As
CustomerBasket
object is acting as a singleton and carrying all the necessary task of managing user's basket features. It is possible in near future it will grow. Therefore, all the features can be extracted to its own independent class andCustomerBasket
will act as a Facade. - API url is segregated by user's realm. for example
api/customer/basket
andapi/marketeer/basket
. Here customer and marketeer act as a realm so when the application is loaded it will load all necessary stuff for user's realm. For example please checkBasket/Middleware/CustomerMiddleware
which gets loaded only for customer's realm. - Some core domain features are extracted to its root application.
/app
folder is treated as the primary part of the domain and all the models will inherit it. - There is no UI to test customer's basket features.