This Repo is for Foodics Hiring Task. The task is building an inventory management system ( single merchant )
- Simple auth system with Sanctum (for advanced auth system with OAuth2 passport is recommended )
- API throttling for API rate limits.
- API versioning.
- Custom Exception Handler.
- Validation Through Requests.
- DB Seeders.
- Database indexes are used for better efficiency.
- Repository Pattern is used to decouple hard dependencies of models.
- Service layer is used to handle the logic.
- Used interfaces to for better structuring.
- SOLID principles are applied.
- Ingredient Unit Management to handle different units of measurement.
- DB transactions are applied to handle race conditions.
- Queues are used to handle email notifications ( for more advanced queue system we can Redis for example)
- Notifications are configured to queue only after successful db transaction.
- Using Docker through Laravel Sail to create docker-compose.yaml.
- Swagger Docs are implemented for better and easier API testing.
- Unit & Feature Tests are added.
- Logging for critical operation and errors.
- App is deployed and documented here https://meta.endlessref.com/api/documentation
- Events for stock updates and EDA.
- Redis for caching initial stocks and handling queues.
- passport for more advanced auth system.
- implement observer pattern to handle notifications for multiple merchants.
You need to have Docker installed on your device.
-
copy necessary variables from .env.ecample to your .env
-
Clone the Repository on your machine.
git clone https://github.com/itszakjo/foodicsTask
cd foodicsTask
-
Install project dependencies
docker run --rm \ -u "$(id -u):$(id -g)" \ -v "$(pwd):/var/www/html" \ -w /var/www/html \ laravelsail/php82-composer:latest \ composer install --ignore-platform-reqs
-
Configure bash alias for laravel Sail
alias sail='bash vendor/bin/sail'
-
Build and Run the project using detached mode
sail up -d
-
Generate a new key
sail artisan key:generate
-
Migrate & Seed the Database
sail artisan migrate --seed
-
To Stop The Containers Insert this command
sail stop
-
For testing with sail
sail test
add mysql credentials to .env
$ composer install
$ php artisan key:generate
$ php artisan migrate --seed
$ php artisan serve
$ php artisan test
Note: API Endpoints are found with examples on this Swagger Docs
X-POST /api/v1/login
Parameters | example | ||
---|---|---|---|
email |
string |
required |
user@mail.com |
password |
string |
required |
password |
{
"access_token": "token"
"token_type": "bearer",
}
x-POST /api/v1/orders
-H 'Authorization: 'your_token' \
Parameter | ||
---|---|---|
produdcts |
array |
required |
products.*.product_id |
int |
required |
products.*.quantity |
int |
required |