eCommerce API Demo

API Service

View the source and Docker file for the API service (opens in a new tab)

Using the Labstack Echo library, I created a simple http microservice that provides 50 random products. Product details are generated using the Faker library.

eCommerce Site

View the source for the eCommerce site (opens in a new tab)

Base Laravel Installation - Dashboard showing 'Sync Products' and 'Remove all products' buttons

Using a base Laravel 10.10 installation I created Livewire components that allow the user to populate the database with products from the API Service. The livewire component UpdateProdcuts.php (opens in a new tab) fetches the data from the API service using an HTTP client, this data is then passed to a Laravel Job process (opens in a new tab) that is responsible for importing each product into the eCommerce database.

Dashboard showing a list of products imported via API

Once completed a Laravel event is fired (opens in a new tab) that will trigger the ListProducts Livewire component (opens in a new tab), via websockets/Pusher, to refresh the page, displaying the newly added products.

© Adrian St Onge.RSS