Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/teofilobetancourt/Restaurant-Equis/llms.txt

Use this file to discover all available pages before exploring further.

The Restaurant Equis API is built with FastAPI and serves as the single backend for the entire restaurant management system — covering the POS cashier, kitchen display, inventory, supplier directory, and reporting dashboards. All endpoints live under the /api/ path prefix, return JSON responses, and are automatically documented through Swagger UI at /api/docs and a raw OpenAPI 3.x spec at /api/openapi.json.

Base URL

The frontend TypeScript layer resolves the base URL from the VITE_API_URL environment variable:
const BASE = import.meta.env.VITE_API_URL || '';
EnvironmentBase URL
Local developmenthttp://localhost:5000
Production (same-origin)(empty string — Nginx proxies /api/ to the backend)
In production, the React SPA and the FastAPI backend are served from the same Linux VPS. Nginx acts as a reverse proxy, so the frontend simply uses a relative path (no host prefix), and Nginx forwards any request starting with /api/ to the Uvicorn process on port 5000. In local development, set VITE_API_URL=http://localhost:5000 in a .env.local file at the project root.

Endpoints Summary

MethodEndpointDescription
GET/api/Health check — returns API version
GET/api/ordenesList all orders
GET/api/ordenes?estatus=activoActive orders only (kitchen view)
GET/api/ordenes/{num_ticket}Get a single order by ticket number
POST/api/ordenesCreate a new order
PUT/api/ordenes/{num_ticket}Update an order’s status
DELETE/api/ordenes/{num_ticket}Cancel (delete) an order
GET/api/platosList all menu dishes (canonical route)
POST/api/platosCreate a new dish
GET/api/productosAlias for /api/platos — same data, compatible field names
GET/api/inventarioList all inventory items (insumos)
POST/api/inventarioCreate a new inventory item
PUT/api/inventario/{id}Update an inventory item by ID
DELETE/api/inventario/{id}Delete an inventory item by ID
GET/api/proveedoresList all suppliers
POST/api/proveedoresCreate a new supplier
PUT/api/proveedores/{id_proveedor}Update a supplier by ID
DELETE/api/proveedores/{id_proveedor}Delete a supplier by ID
GET/api/reportes/resumenKPI summary (revenue, order counts, trends)
GET/api/reportes/pedidosFiltered orders report
GET/api/debugDatabase connection debug info

Interactive Documentation

FastAPI auto-generates interactive documentation from the route definitions and Pydantic schemas. No extra configuration is needed.
Navigate to /api/docs in your browser for the full Swagger UI. You can inspect every endpoint, view request/response schemas, and execute live test requests directly from the interface.
http://localhost:5000/api/docs      # local development
http://<your-server>/api/docs       # production

Response Format

All responses are JSON. Successful responses return the resource or list of resources directly as a JSON object or array. The health check endpoints are the simplest examples. GET /api/ returns the versioned health response:
curl http://localhost:5000/api/
{
  "status": "ok",
  "servicio": "Restaurant Equis API",
  "version": "1.1.0"
}
GET / (root, without the /api/ prefix) returns a slightly different response that includes the db_integration key instead of version:
{
  "status": "ok",
  "servicio": "Restaurant Equis API",
  "db_integration": "nelrondon/restaurant-bd-tdb"
}
Use GET /api/ (with the /api/ prefix) for the versioned health check. The root GET / endpoint exists for platform-level liveness probes and returns db_integration rather than version.

Error Handling

The API registers a global exception handler that catches any unhandled Python exception and returns a structured 500 response. This makes it straightforward to trace backend errors from the frontend or from API logs. 500 — Unhandled server error The handler in backend/main.py uses traceback.format_exc().splitlines() to produce a JSON-serialisable list of strings:
{
  "error": "column \"foo\" of relation \"plato\" does not exist",
  "type": "ProgrammingError",
  "traceback": [
    "Traceback (most recent call last):",
    "  File \"/backend/routers/productos.py\", line 42, in ...",
    "..."
  ]
}
404 — Resource not found FastAPI’s HTTPException with a 404 status produces the standard detail envelope:
{
  "detail": "Pedido 9999 no encontrado"
}
422 — Validation error When a required field is missing or has the wrong type, FastAPI returns 422 Unprocessable Entity with a detail array describing each validation failure:
{
  "detail": [
    {
      "type": "missing",
      "loc": ["body", "tipo_pedido"],
      "msg": "Field required"
    }
  ]
}

CORS

Cross-Origin Resource Sharing is configured in backend/main.py using FastAPI’s CORSMiddleware. The middleware is currently hardcoded to allow all origins ("*"), with the CORS_ORIGINS environment variable parsed but reserved for a future tighter configuration:
raw_origins = os.getenv("CORS_ORIGINS", "http://localhost:5173,http://158.220.100.226,http://localhost:3000")
origins = [o.strip() for o in raw_origins.split(",") if o.strip()]

app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)
The origins list built from CORS_ORIGINS is computed but not yet passed to allow_origins — the middleware always uses ["*"]. Changing the CORS_ORIGINS environment variable has no effect on the current build. To restrict browser origins, you must replace allow_origins=["*"] with allow_origins=origins directly in backend/main.py. See the Authentication page for deployment hardening guidance.

Build docs developers (and LLMs) love