Skip to main content

Documentation 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.

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’s /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

1

Change into the web directory

cd CafeteriaPM_S203/web
2

Create a virtual environment, activate it, and install dependencies

# macOS / Linux
python -m venv venv
source venv/bin/activate

# Windows
python -m venv venv
venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt
The 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.
3

Configure the API base URL

Open web/app.py and locate the API_BASE_URL constant near the top of the file:
API_BASE_URL = "http://localhost:8000"
Change this to the address where your API is running. For example, if the API is deployed on a remote server:
API_BASE_URL = "https://api.yourcafeteria.example.com"
4

Start the web panel

python app.py
The panel starts on port 5050 and binds to 0.0.0.0, making it accessible at http://localhost:5050.

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:
TabData SourceDescription
ventasGET /stats/ventas-listaItemized sales list with optional date range filter
gastosGET /stats/gastos-listaItemized expense list with optional date range filter
productosGET /stats/productos-estadisticasPer-product performance metrics
inventarioGET /stats/inventario-estadoCurrent ingredient stock levels
historialGET /stats/historial-actividadRecent activity log (last 20 events)
Each tab also shows a monthly summary card (from 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)
The /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.
RouteFormatReport
/proxy/reporte-ventas/pdfPDFSales report (supports fecha_inicio / fecha_fin)
/proxy/reporte-ventas/xlsxXLSXSales report (supports date range)
/proxy/reporte-gastos/pdfPDFExpenses report (supports date range)
/proxy/reporte-gastos/xlsxXLSXExpenses report (supports date range)
/proxy/reporte-productos/pdfPDFProduct statistics report
/proxy/reporte-productos/xlsxXLSXProduct statistics report
/proxy/reporte-inventario/pdfPDFInventory status report
/proxy/reporte-inventario/xlsxXLSXInventory status report
/proxy/reporte-historial/pdfPDFActivity history report
/proxy/reporte-historial/xlsxXLSXActivity history report
/proxy/ticket/{pedido_id}/pdfPDFIndividual order ticket

Build docs developers (and LLMs) love