Third CodeAlpha task - a backend for handling the day to day stuff a restaurant deals with: menu, tables, reservations, orders and stock. Built with Django again, mainly so the admin panel could double as the staff dashboard instead of building one from scratch.
- Django (Python)
- SQLite
- Django templates for the customer-facing pages, no JS framework
- Browse the menu and place an order (dine-in at a specific table, or takeaway)
- Check which tables are free right now and reserve one for a future date/time
- Reservations get blocked if they'd overlap with an existing one on the same table
- Placing an order automatically deducts the ingredients it uses from inventory, and checks first that there's actually enough stock - if not, the order gets rejected instead of going through half-done
- Cancelling an order puts the ingredients back into stock
- Staff get the full Django admin panel: manage the menu, tables, inventory, mark orders completed or cancel them in bulk, see who's reserved what
- A couple of small reporting endpoints - daily sales total, and a low-stock alert list
pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
Go to /admin/ first and set up some menu items, tables, and inventory (and link ingredients to menu items) before trying the customer-facing pages - otherwise there's nothing to order.
| Method | URL | Does what |
|---|---|---|
| GET | /api/menu/ | list available menu items |
| GET | /api/menu// | one menu item's details |
| GET | /api/tables/ | list tables + whether they're occupied |
| POST | /api/tables//reserve/ | reserve a table |
| POST | /api/reservations//cancel/ | cancel a reservation |
| POST | /api/orders/ | place an order |
| GET | /api/orders// | order status + items + total |
| POST | /api/orders//cancel/ | cancel an order (restocks ingredients) |
| GET | /api/inventory/ | current stock levels |
| GET | /api/inventory/alerts/ | items at or below their reorder threshold |
| POST | /api/inventory//update/ | set stock level (staff login required) |
| GET | /api/reports/daily-sales/ | total sales for a given day |
Each menu item can have one or more MenuItemIngredient rows linking it to an InventoryItem and how much of it one serving uses. When an order comes in, it adds up everything needed across all items in that order, checks each ingredient has enough stock, and only then creates the order and deducts stock - all inside one atomic transaction so it can't end up half-applied if something fails partway through.
- Proper staff login flow for the API instead of relying on the browsable admin session
- A kitchen-facing view showing just the pending/preparing orders
- Weekly/monthly sales reports, not just daily
- Table capacity checks against party size when reserving