LazyRoom API
The Laravel backend of a multi-vendor ordering app: customers order meals and groceries from campus suppliers and pay from an in-app wallet. The mobile app was built by a teammate in Flutter; this repository is the backend.
Demo accounts
| Role | Password | |
|---|---|---|
| Customer | customer@lazyroom.com | password |
| Supplier | supplier@lazyroom.com | password |
| Admin | admin@lazyroom.com | password |
Try the order flow
- In the interactive docs, send
POST /api/loginas the customer (it is pre-filled) and copy thetoken. - Paste it as the Bearer token and send
POST /api/orders(pre-filled with products 1 and 4). Note the orderid. - Log in as the supplier and send
POST /api/orders/{id}/accept. - Log in as the customer again and send
POST /api/orders/{id}/complete. CheckGET /api/balance: the money moved from the customer to the supplier.
What's inside
Order state machineOrders move from pending to accepted, rejected, cancelled or complete, and stock is reserved and restored along the way.
Safe wallet paymentsCompleting an order runs in a database transaction with row locks, so a double click or a retry never charges twice.
Measured under loadOn MySQL, 20 parallel completions of one order charge it exactly once, and 50 parallel orders never overdraw a wallet.
RolesSanctum tokens and role middleware for customers, suppliers and admins.
TestedFeature tests for the payment flow run on every push with GitHub Actions.
DocumentedOpenAPI docs generated from the code, plus a Postman collection.
Free hosting: the server sleeps when idle, so the first request can take up to a minute. This demo runs on SQLite, which has no row locks; the concurrency results above were measured on MySQL. The demo database is reset on every restart.