A production deployment requires a PostgreSQL database and a Gmail OAuth2 application for sending credential emails. The API is a standard ASGI app served by Uvicorn, so it runs on any Linux host, container, or PaaS that can execute a Python process.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Crypto-Project-ENSTA/back-end/llms.txt
Use this file to discover all available pages before exploring further.
Install dependencies
Install all Python packages from Key packages and their roles:
requirements.txt into your environment:| Package | Version | Role |
|---|---|---|
fastapi | 0.135.2 | Web framework |
uvicorn | 0.42.0 | ASGI server |
sqlalchemy | 2.0.48 | ORM |
alembic | 1.18.4 | Database migrations |
psycopg2-binary | 2.9.11 | PostgreSQL driver |
cryptography | 46.0.6 | RSA operations |
pydantic | 2.12.5 | Request/response validation |
pydantic-settings | 2.13.1 | Environment variable loading |
itsdangerous | 2.2.0 | Signed session cookies |
google-api-python-client | 2.193.0 | Gmail API client |
google-auth | 2.49.1 | Gmail OAuth2 |
starlette | 1.0.0 | Session middleware |
python-dotenv | 1.2.2 | .env file loading |
Set environment variables
The application reads its configuration from environment variables. Create a All nine variables are required. The application will fail to start if any are missing.
.env.local file (or export variables directly) with the following values:| Variable | Description |
|---|---|
ENV | Runtime environment label (development or production). |
ALLOWED_ORIGINS | Comma-separated list of frontend origins permitted by the CORS middleware. Must include every domain that will access the API. |
DATABASE_URL | Full SQLAlchemy-compatible PostgreSQL connection string. |
SECRET_KEY | Secret used to sign session cookies. Use a cryptographically random value of at least 32 characters. |
EMAIL_FROM | The From address for credential emails sent via Gmail. |
GMAIL_TOKEN | Access token (can be left blank; the application refreshes it automatically). |
GMAIL_REFRESH_TOKEN | OAuth2 refresh token from your Gmail API credentials. |
GMAIL_CLIENT_ID | OAuth2 client ID from Google Cloud Console. |
GMAIL_CLIENT_SECRET | OAuth2 client secret from Google Cloud Console. |
Set up the database
Run Alembic migrations to create all tables in the target database:This is idempotent — you can safely run it on each deployment to apply any new migrations.
Start the server
Launch the API with Uvicorn:For production, run with multiple workers and enable access logging:
CORS
TheALLOWED_ORIGINS variable controls which frontend origins the API accepts cross-origin requests from. The value is a comma-separated list parsed at startup: