A REST API which allows users add items to shopping basket (cart) and make order
This project was built with Laravel and MySQL.
- Laravel Passport
- Create cart and add products to cart
- Remove product from cart
- Create orders from cart
- PHPUnit (https://phpunit.de)
- Faker (https://github.com/fzaninotto/Faker)
- Users (Registered / Guest) can add products to cart and make orders
- Users are allowed to create multiple carts
- Maximum quantity allowed per product is 20
- Filtering, sorting, pagination is not supported
- Products are seeded into the database
- Payments for cart items on orders is not integrated
To run the API, you must have:
Create an .env
file using the command. You can use this config or change it for your purposes.
$ cp .env.example .env
Configure environment variables in .env
for dev environment based on your MYSQL database configuration
DB_CONNECTION=<YOUR_MYSQL_TYPE>
DB_HOST=<YOUR_MYSQL_HOST>
DB_PORT=<YOUR_MYSQL_PORT>
DB_DATABASE=<YOUR_DB_NAME>
DB_USERNAME=<YOUR_DB_USERNAME>
DB_PASSWORD=<YOUR_DB_PASSWORD>
API End points and documentation can be found at: Postman Documentation.
List of all API endpoints:
POST /api/auth/login
GET /api/auth/logout
POST /api/auth/register
POST /api/carts
GET /api/carts/{id}/products
POST /api/carts/{id}/products
DELETE /api/carts/{id}/products/{id}
PATCH /api/carts/{id}/products/{id}
POST /api/orders
GET /api/products
GET /api/products/{id}
GET /api/data
Install the dependencies and start the server
$ composer install
$ php artisan key:generate
$ php artisan migrate --seed
$ php artisan passport:install
$ php artisan serve
To run integration tests:
$ composer test
Generate swagger documentation
$ php artisan l5-swagger:generate