https://github.com/elsayed85/microservice-food
https://github.com/elsayed85/microservice-food
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/elsayed85/microservice-food
- Owner: elsayed85
- Created: 2024-11-10T20:36:49.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-11-11T07:28:58.000Z (over 1 year ago)
- Last Synced: 2025-04-11T01:14:04.015Z (about 1 year ago)
- Language: PHP
- Size: 124 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Building Steps
## Step 1: Preparing Services [ Mysql , PhpMyAdmin , Redis ]
```bash
docker compose up -d --build
```
```bash
##### MYSQL & PHPMYADMIN #####
DB_DATABASE=food_ordering
DB_USERNAME=root
DB_PASSWORD=pass_@123
DB_ROOT_PASSWORD=pass_@123
DB_PORT=3306
PHP_MYADMIN_MY_PORT=8002
PHPMYADMIN_DB_USERNAME=root
PHPMYADMIN_DB_PASSWORD=pass_@123
PHPMYADMIN_PORT=8365
NETWORK_NAME=food_network
DB_UPLOAD_MAX_FILESIZE=100M
##### REDIS #####
REDIS_PORT=6372
```
## Step 2: Which Service You Want To Test [ Monolithic , MicroServices ]
### Monolithic [ Foodics ] [ With Test Cases ]
```bash
===== Monolithic =====
cd monolithic/foodics
docker compose up -d --build
docker exec -it -uroot foodics-service php artisan test
```
### MicroServices [ Notification , Order , Stock ] [ Without Test Cases , sorry :( ]
```bash
===== Notification =====
```bash
cd micro-service/src/Notification
docker compose up -d --build
===== Order =====
cd micro-service/src/Order
docker compose up -d --build
===== Stock =====
cd micro-service/src/Stock
docker compose up -d --build
```
## Step 3: Testing Services [ Monolithic ]
```bash
docker exec -it -uroot foodics-service php artisan test
PASS Tests\Feature\PlaceOrderTest
✓ it places an order successfully 1.14s
✓ it dispatches PlaceNewOrderJob when placing an order 0.03s
✓ it stores the order with "Processing" status 0.05s
✓ it attaches products to the order 0.05s
✓ it reserves product ingredients for the order 0.05s
✓ it deducts ingredient stock based on order quantity 0.05s
✓ it triggers a low stock alert when stock is low 0.07s
✓ it cancels the order when stock is not enough 0.05s
✓ it dispatches SendLowStockAlertJob when an ingredient is low in sto… 0.04s
✓ it dispatches SendLowStockAlertJob only once when multiple orders a… 0.04s
Tests: 10 passed (13 assertions)
Duration: 1.65s
```