FridgeRadar’s backend is a fully asynchronous REST API built with FastAPI 0.111, SQLAlchemy 2.0 (async), and aiomysql, designed to run on Python 3.12. It handles authentication (JWT + bcrypt), household inventory management, scheduled semáforo recalculation via APScheduler, and 13 resource endpoints across theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/EstefanoARG/FridgeRadar/llms.txt
Use this file to discover all available pages before exploring further.
/api/v1 prefix.
Requirements
Python 3.12+
The backend uses
match statements, asyncio improvements, and type annotation syntax available only in 3.12+.MySQL 8+
Required for
utf8mb4, window functions, generated columns, and MySQL Events used by the semáforo scheduler.Running MySQL Instance
The backend connects at startup — ensure MySQL is accessible before launching uvicorn.
Setup and Installation
Install Python dependencies
All pinned runtime dependencies (FastAPI, SQLAlchemy, aiomysql, APScheduler, pydantic-settings, uvicorn, etc.) are listed in Key packages installed:
requirements.txt:| Package | Version | Purpose |
|---|---|---|
fastapi | 0.111.0 | ASGI web framework |
uvicorn | 0.29.0 | ASGI server |
sqlalchemy | 2.0.36 | Async ORM |
aiomysql | 0.2.0 | Async MySQL driver |
APScheduler | 3.10.4 | Background task scheduler |
pydantic | 2.7.1 | Request/response validation |
pydantic-settings | 2.2.1 | .env-based configuration |
python-jose | 3.3.0 | JWT token signing |
bcrypt | 4.0.1 | Password hashing |
Configure environment variables
Copy the example file and edit it with your credentials:All variables recognized by
app/core/config.py:Initialize the database schema
Before starting the API, load the full schema into MySQL:See the Database page for a complete description of what this script creates.
Start the API server
Development — with hot reload:Or use the convenience script (which does the same thing from the correct working directory):Production — multiple workers, reload disabled:
Set
DEBUG=False in .env for all production deployments. In debug mode, tracebacks are included in API error responses.Verifying the Deployment
Health Check
Once the server is running, confirm it is healthy:Interactive API Documentation
FridgeRadar exposes two self-hosted API documentation UIs automatically:Swagger UI
Full interactive documentation at
/docs. Try any endpoint directly from the browser, including authenticated routes after supplying a Bearer token.ReDoc
Clean, readable reference documentation at
/redoc. Ideal for sharing with frontend teams or external integrators.CORS Configuration
The backend reads allowed origins from theALLOWED_ORIGINS environment variable, which maps to Settings.ALLOWED_ORIGINS in app/core/config.py (a list[str]).
The value must be valid JSON — use double quotes inside the list. If the frontend and backend are served from the same domain through a reverse proxy, you can omit the CORS configuration entirely.
API Endpoints Reference
| Method | Route | Description |
|---|---|---|
POST | /api/v1/auth/login | Authenticate; returns JWT access token |
POST | /api/v1/auth/register | Register a new user |
GET / PUT / DELETE | /api/v1/usuarios/{id} | User profile CRUD |
GET / POST | /api/v1/hogares | Household management |
GET / POST | /api/v1/zonas | Storage zones within a household |
GET / POST / PATCH / DELETE | /api/v1/estantes | Shelf CRUD; supports ?id_zona= filter |
GET / POST | /api/v1/inventario/{id_hogar} | Household inventory; supports ?estado=rojo filter |
GET / POST | /api/v1/productos | Global product catalog |
GET | /api/v1/recetas | Available recipes |
GET | /api/v1/alertas | Unread alerts for the authenticated user |
GET / POST | /api/v1/listas-compra | Shopping lists |
GET | /api/v1/desperdicio | Waste report |
GET | /api/v1/semaforo | Food freshness semáforo status |
GET | /api/v1/tengo-hambre | Recipe suggestions using soon-to-expire items |
Testing
Run the full test suite with coverage:Integration tests require a live MySQL connection. Ensure your
.env points to a test database before running them.Linting and Type Checking
The project usesruff for fast linting and mypy for static type analysis, both configured in pyproject.toml targeting Python 3.12.