The CafeteriaPM admin web panel is a Flask application that provides a browser-based interface exclusively for admin users. It communicates with the REST API using a server-side Bearer token session — it does not connect to PostgreSQL directly. Every page first authenticates against the API’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/123048152-JJDS/CafeteriaPM_S203/llms.txt
Use this file to discover all available pages before exploring further.
/auth/login endpoint, stores the access token in Flask’s signed server-side session, and then forwards all subsequent data requests to the API with an Authorization: Bearer <token> header.
Prerequisites
- Python 3.10+
- The CafeteriaPM API running and accessible — by default the panel expects the API at
http://localhost:8000. Start the API before launching the web panel.
Setup
Create a virtual environment, activate it, and install dependencies
requirements.txt installs Flask==3.0.0, requests==2.31.0, Jinja2==3.1.6, Werkzeug==3.1.8, python-dotenv==1.0.0, and blinker==1.9.0.Configure the API base URL
Open Change this to the address where your API is running. For example, if the API is deployed on a remote server:
web/app.py and locate the API_BASE_URL constant near the top of the file:Authentication
Only users with the role
admin can access the web panel. During login, the panel calls POST /auth/login on the API and inspects the rol field in the response. If the authenticated user’s role is anything other than admin, the session is immediately cleared and the user is shown an “Acceso denegado. Solo administradores.” message and redirected back to the login page. Non-admin staff (waiters, cashiers, kitchen) should use the mobile app instead.Available Pages
Every route listed below is protected by the@login_required decorator, which verifies both that an active session token exists and that the session role is admin. Unauthenticated or non-admin requests are redirected to /login.
/login
The entry point for the panel. Accepts an email address and password. On success the access token, user ID, display name, and role are stored in the encrypted Flask session. The root path / redirects here automatically if no admin session is active.
/dashboard
The main overview screen after login. Pulls data from GET /stats/dashboard and GET /stats/ventas-diarias?dias=7 to display:
- KPI cards — today’s total sales, number of active orders, ingredients below minimum stock (stock alerts), and total operational expenses
- Daily sales chart — a 7-day revenue trend for at-a-glance performance monitoring
- Top products — the best-selling items ranked by units sold
/usuarios
Full user management for the cafeteria system. Supports:
- List users with optional filters by name/email search term, role, and active/inactive status
- Create a new user — name, email, password, role, and active flag
- Edit an existing user — update any field including password and role assignment
- Deactivate / delete a user — soft or hard removal depending on backend configuration
/estadisticas
A tabbed statistics dashboard with five views selectable via a ?tab= query parameter:
| Tab | Data Source | Description |
|---|---|---|
ventas | GET /stats/ventas-lista | Itemized sales list with optional date range filter |
gastos | GET /stats/gastos-lista | Itemized expense list with optional date range filter |
productos | GET /stats/productos-estadisticas | Per-product performance metrics |
inventario | GET /stats/inventario-estado | Current ingredient stock levels |
historial | GET /stats/historial-actividad | Recent activity log (last 20 events) |
GET /stats/resumen-mes) and download buttons for the active tab’s report.
/pedidos
An order browser that loads orders from GET /pedidos/ with optional filters for order status (estado_id), table (mesa_id), date range (fecha_inicio / fecha_fin), and a text search. Without filters, the panel shows the 10 most recent orders. Admins can manually advance an order’s status via a PATCH /pedidos/{id}/estado call.
/menu
Product catalog management. Displays all products from GET /productos/ with category and ingredient data loaded alongside. From this page an admin can:
- Create a new product (name, description, price, category, ingredients, availability toggle)
- Edit an existing product’s details
- Toggle availability — marks the product as available or unavailable without deleting it
- Delete a product permanently
/inventario
Ingredient stock management. Shows all ingredients from GET /productos/ingredientes alongside a dedicated low-stock alert list from GET /productos/ingredientes/stock-bajo. From this page an admin can:
- Create a new ingredient (name, unit, current stock, minimum stock, unit cost)
- Edit ingredient details
- Adjust stock by adding or subtracting a quantity
- Delete an ingredient (blocked if it is referenced by a product)
/compras/registrar route (POST form submission from the inventario page) registers a new supply purchase against a specific ingredient, recording quantity, total cost, and date. The API automatically increments the ingredient’s stock_actual on purchase.
/mesas
Table status overview. Loads all dining tables from GET /mesas and displays their current status (available, occupied, or reserved). Admins can create new tables, delete existing ones, and transition any table between states:
- Ocupar — marks the table as occupied and opens a new order
- Liberar — closes the active order and frees the table
- Reservar — places a reservation
- Cancelar reserva — cancels an existing reservation
/proxy/reporte-* — Report Downloads
The panel acts as an authenticated proxy for report generation. All report endpoints require an active admin session and forward the request to the API with the session Bearer token. Reports are streamed back directly to the browser as file downloads.
| Route | Format | Report |
|---|---|---|
/proxy/reporte-ventas/pdf | Sales report (supports fecha_inicio / fecha_fin) | |
/proxy/reporte-ventas/xlsx | XLSX | Sales report (supports date range) |
/proxy/reporte-gastos/pdf | Expenses report (supports date range) | |
/proxy/reporte-gastos/xlsx | XLSX | Expenses report (supports date range) |
/proxy/reporte-productos/pdf | Product statistics report | |
/proxy/reporte-productos/xlsx | XLSX | Product statistics report |
/proxy/reporte-inventario/pdf | Inventory status report | |
/proxy/reporte-inventario/xlsx | XLSX | Inventory status report |
/proxy/reporte-historial/pdf | Activity history report | |
/proxy/reporte-historial/xlsx | XLSX | Activity history report |
/proxy/ticket/{pedido_id}/pdf | Individual order ticket |