The CafeteriaPM API is a FastAPI application served by Uvicorn. It can be run directly with Python or containerized with Docker. All configuration is provided through environment variables read byDocumentation 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.
python-decouple, which looks for a .env file in the project root and falls back to real environment variables — making it equally at home in local development and container-based production deployments.
Prerequisites
Before you start, make sure you have the following installed and available:- Python 3.11+ — the Docker image uses
python:3.11-slim; local development works with 3.10 or later - PostgreSQL 14+ — create a dedicated database and user before running the API
- pip — used to install Python dependencies
- gcc and libpq-dev (Linux) — required to compile
psycopg2-binary; on macOS usebrew install libpq
Local Setup
Install Python dependencies
fastapi==0.111.0, uvicorn==0.29.0, sqlalchemy==2.0.30, psycopg2-binary==2.9.9, python-jose==3.3.0, bcrypt==4.0.1, python-decouple==3.8, reportlab==4.2.0, and openpyxl==3.1.2.Copy the example env file and configure it
.env in your editor and fill in your database credentials and a strong secret key. See the Environment Variables section below for the full reference.Initialize the database and seed reference data
seed_all.py runs the full sequence automatically: it calls init_db.py to load the schema from the bundled SQL file, then executes seed_admin.py, seed_estados.py, seed_productos.py, and seed_demo_data.py in order.Environment Variables
Every setting is loaded from your.env file (or real environment variables) by python-decouple. The file api/app/core/config.py defines all defaults.
Database
Hostname or IP address of your PostgreSQL server. When running the API inside Docker and the database is on the host machine, use
host.docker.internal.PostgreSQL username. Example:
cafeteria_user.Password for the PostgreSQL user. Example:
cafeteria_pass.Name of the PostgreSQL database. Example:
cafeteria_db.Port PostgreSQL is listening on.
Authentication (JWT)
The HMAC key used to sign and verify JWT tokens. Minimum 32 characters. Generate a safe value with:
JWT signing algorithm.
HS256 is recommended for single-server deployments.Token time-to-live in minutes. The default of
480 equals 8 hours — a typical full shift for cafeteria staff.Application
Application name returned in the health-check response.
Application version string returned in the health-check response.
Runtime environment. Accepted values:
development, production.Enables FastAPI/Uvicorn debug mode and verbose error responses. Set to
False in production.Docker
Theapi/Dockerfile uses a python:3.11-slim base image. It installs the gcc and libpq-dev system packages needed to compile psycopg2, copies requirements.txt and installs all Python dependencies with --no-cache-dir, then copies the full application source. Port 8000 is exposed and the container starts with:
Build and run
--env-file flag to pass your .env file directly:
Health Check
Once the server is running,GET / returns a JSON object confirming the application name, version, and status:
| Endpoint | Description |
|---|---|
GET / | Health check — returns app name, version, and status |
GET /docs | Interactive Swagger UI |
GET /redoc | ReDoc API reference |
Seed Scripts
Theapi/scripts/ directory contains a collection of utility scripts for database initialization and test data loading. Run them with python scripts/<script>.py from the api/ directory with your virtual environment activated.
| Script | Purpose |
|---|---|
init_db.py | Initializes the database schema by executing the bundled SQL file (sql/CafeteriaPM_S203.sql) against the configured PostgreSQL database. Run this first on a fresh database. |
seed_admin.py | Creates a single admin user. Useful when you only need an admin account without the full reference dataset. |
seed_all.py | Runs the full seed sequence in order: init_db.py → seed_admin.py → seed_estados.py → seed_productos.py → seed_demo_data.py. Use this for a complete fresh install including demo data. |
seed_demo_data.py | Loads sample products, ingredients, dining tables, and orders. Intended for development and QA environments only. |
seed_estados.py | Seeds order state records (pendiente, en_preparacion, listo, entregado, pagado, cancelado, reservado) and payment methods (efectivo, tarjeta, transferencia, otro). |
seed_productos.py | Seeds a sample product catalog with names, prices, and categories. |
check_db.py | Verifies database connectivity by attempting a connection with the configured credentials. Useful for diagnosing configuration issues before running the app. |