This guide walks you through running the CafeteriaPM API on your local machine from a fresh clone. By the end you will have a fully seeded database, a running FastAPI server, and a valid JWT token you can use to call any endpoint.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.
Clone and configure
Clone the repository and copy the example environment file to create your local configuration:The Update
.env.example ships with safe placeholder values:DB_HOST, DB_USER, DB_PASSWORD, and DB_NAME to match your local PostgreSQL instance, then save the file as api/.env.Install Python dependencies
Navigate to the The key dependencies pinned in
api directory and install all required packages:requirements.txt are:| Package | Version | Purpose |
|---|---|---|
fastapi | 0.111.0 | Web framework and OpenAPI generation |
sqlalchemy | 2.0.30 | ORM and database connection management |
pydantic | 2.7.1 | Request/response schema validation |
uvicorn | 0.29.0 | ASGI server |
passlib | 1.7.4 | Password hashing (bcrypt backend) |
python-jose | 3.3.0 | JWT creation and verification |
reportlab | 4.2.0 | PDF report generation |
openpyxl | 3.1.2 | Excel report generation |
psycopg2-binary | 2.9.9 | PostgreSQL driver |
python-decouple | 3.8 | .env file loading |
Initialize the database
With your PostgreSQL server running and
api/.env configured, run the two initialisation scripts from inside the api directory:init_db.py executes the bundled SQL schema file (sql/CafeteriaPM_S203.sql) which creates all tables, constraints, and indexes in your database.seed_all.py then orchestrates the full seeding sequence by running each seed script in order:init_db.py— schema creation (re-run as a safety step)seed_admin.py— creates the four roles (admin,cocina,caja,mesero) and the default administrator accountseed_estados.py— populates order states and payment methodsseed_productos.py— loads a sample product catalogue with categories and ingredientsseed_demo_data.py— inserts demonstration orders, sales, and expense records
| Field | Value |
|---|---|
[email protected] | |
| Password | Admin123! |
Start the API server
Launch the API with uvicorn from inside the The
api directory:--reload flag watches for source file changes and restarts the server automatically, which is useful during development. Once the server is running you can access:- Interactive API docs (Swagger UI): http://localhost:8000/docs
- Alternative docs (ReDoc): http://localhost:8000/redoc
- Health check: http://localhost:8000/
Authenticate and make your first call
Exchange the seeded admin credentials for a JWT access token:A successful response returns the token alongside the user’s identity and role:Copy the Replace
access_token value and use it as a Bearer token to call any protected endpoint. For example, to list all products:<access_token> with the full token string returned by the login call. Tokens are valid for 480 minutes (8 hours) by default, controlled by ACCESS_TOKEN_EXPIRE_MINUTES in your .env file.