A comprehensive backend API for a cafe kiosk self-service system with admin functionality.
- Product Management: Create, update, delete, and retrieve food/beverage products
- Category Management: Organize products into categories
- Order Processing: Handle customer orders with customizations
- Inventory Tracking: Monitor stock levels and reorder points
- User Management: Admin and staff user accounts with role-based access
- Customization Options: Product customizations (sizes, add-ons, etc.)
- Backend: Node.js with Express
- Database: PostgreSQL via Supabase
- Authentication: JWT-based authentication (basic implementation)
- Clone the repository
git clone <repository-url>
cd cafe-kiosk-api- Install dependencies
npm install- Create a
.envfile in the root directory with the following variables:
PORT=8080
SUPABASE_URL=your-supabase-url
SUPABASE_ANON_KEY=your-supabase-anon-key
NODE_ENV=development
- Start the server
npm startGET /api/products- Get all productsGET /api/products/:id- Get product by IDGET /api/products/category/:categoryId- Get products by categoryPOST /api/products- Create new productPUT /api/products/:id- Update productDELETE /api/products/:id- Delete product
GET /api/categories- Get all categoriesGET /api/categories/:id- Get category by IDPOST /api/categories- Create new categoryPUT /api/categories/:id- Update categoryDELETE /api/categories/:id- Delete category
GET /api/orders- Get all ordersGET /api/orders/:id- Get order by IDGET /api/orders/date-range- Get orders by date rangePOST /api/orders- Create new orderPUT /api/orders/:id/status- Update order statusPOST /api/orders/:id/payment- Process payment for order
POST /api/users/login- User loginPOST /api/users/register- Register new userGET /api/users- Get all users (admin)GET /api/users/:id- Get user by ID (admin)PUT /api/users/:id- Update userDELETE /api/users/:id- Delete user (admin)
GET /api/inventory- Get all inventory itemsGET /api/inventory/:id- Get inventory item by IDGET /api/inventory/product/:productId- Get inventory for productGET /api/inventory/low-stock- Get low stock inventory itemsPOST /api/inventory- Create new inventory itemPUT /api/inventory/:id- Update inventory itemDELETE /api/inventory/:id- Delete inventory itemPOST /api/inventory/:id/restock- Restock inventory
GET /api/customization- Get all customizationsGET /api/customization/:id- Get customization by IDGET /api/customization/type/:type- Get customizations by typeGET /api/customization/product/:productId- Get customizations for productPOST /api/customization- Create new customizationPUT /api/customization/:id- Update customizationDELETE /api/customization/:id- Delete customizationPOST /api/customization/product- Add customization to productDELETE /api/customization/product/:product_id/customization/:customization_id- Remove customization from product
The system uses the following tables:
- users
- categories
- products
- inventory
- kiosks
- settings
- orders
- orderitems
- customization
- productcustomizeoption
- ordercustomization
- activitylog
- notification
- inventorytransaction
- promotiontable
- promotionproduct
- orderpromotion
- paymenttransaction
The API uses a simple token-based authentication system. For protected endpoints:
- Get a token by logging in:
POST /api/users/login - Include the token in the Authorization header:
Authorization: Bearer <token>
To run the server in development mode with hot reloading:
npm run dev