The repository ships with aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/pvnm4/Social-Media-Backend/llms.txt
Use this file to discover all available pages before exploring further.
render.yaml Blueprint file that lets you provision both the FastAPI web service and a managed PostgreSQL database on Render.com in a single click. No manual service configuration is required — Render reads the Blueprint and creates every resource with the correct settings, environment variables, and inter-service wiring automatically.
What render.yaml configures
Therender.yaml file at the root of the project defines the full infrastructure for the application:
databases block
Provisions a free-tier PostgreSQL instance on Render with:
- Instance name:
fastapi-db(used internally to reference the database from services) - Database name:
fastapi_tutorial - Database user:
fastapi_user - Plan:
free— 1 GB storage, expires after 90 days ipAllowList: []— allows inbound connections from any IP address, which is required for the web service to reach the database
services block
Provisions a Python web service with:
- Build command:
pip install uv && uv sync— installsuvand then uses it to install all dependencies declared inpyproject.toml - Start command:
uv run uvicorn app.main:app --host 0.0.0.0 --port $PORT— Render injects the$PORTvariable automatically; the application binds to it - Python version:
3.14, pinned via thePYTHON_VERSIONenvironment variable
DATABASE_URL wiring
The fromDatabase directive automatically injects the PostgreSQL connection string from fastapi-db into the DATABASE_URL environment variable of the web service. Render resolves this at deploy time, so there is no need to copy and paste connection strings manually.
The application’s
app/database.py constructs its SQLAlchemy URL from individual DATABASE_* variables (DATABASE_HOSTNAME, DATABASE_PORT, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME), not from DATABASE_URL. After deployment you will need to supply those individual variables (see step 6 below).Deployment steps
Push the repository to GitHub
Render deploys from a connected Git repository. Fork the project or push it to a GitHub repository under your own account:
Create a Render account
Sign up for a free account at render.com if you do not already have one. No credit card is required for the free tier.
Create a new Blueprint deployment
In the Render dashboard, click New in the top navigation bar, then select Blueprint from the dropdown menu.
Connect your GitHub repository
Authorize Render to access your GitHub account and select the repository that contains
render.yaml. Render will scan the repository root for the Blueprint file.Review and apply the Blueprint
Render detects
render.yaml and displays a summary of the resources it will create:- 1 PostgreSQL database (
fastapi-db) - 1 web service (
fastapi-tutorial)
Set additional environment variables
The Blueprint wires
DATABASE_URL automatically, but the application reads individual DATABASE_* variables. Add the following manually in the Render dashboard under Environment for the fastapi-tutorial service:| Variable | Example value | Description |
|---|---|---|
DATABASE_HOSTNAME | dpg-xxx.oregon-postgres.render.com | Hostname from the Render database info page |
DATABASE_PORT | 5432 | PostgreSQL port |
DATABASE_USERNAME | fastapi_user | Database user defined in render.yaml |
DATABASE_PASSWORD | (from Render DB page) | Auto-generated by Render |
DATABASE_NAME | fastapi_tutorial | Database name defined in render.yaml |
SECRET_KEY | a-long-random-string | Used to sign JWT tokens |
ALGORITHM | HS256 | JWT signing algorithm |
ACCESS_TOKEN_EXPIRE_MINUTES | 60 | Token lifetime in minutes |
Render builds and deploys automatically
After saving the environment variables, Render triggers a new deploy. Monitor progress in the Logs tab of the
fastapi-tutorial service. A successful deploy ends with a log line from Uvicorn confirming the server is running.Once deployed, your API is available at the URL shown in the service dashboard (e.g., https://fastapi-tutorial.onrender.com).Run database migrations after deployment
The Blueprint does not run Alembic migrations automatically. After the first successful deploy, run the migrations using the Render Shell feature:- In the Render dashboard, open the
fastapi-tutorialservice. - Click the Shell tab to open an interactive terminal inside the running container.
- Run:
posts, users, votes) in the fastapi_tutorial database.
Important notes
-
DATABASE_URLis automatically injected — thefromDatabasedirective inrender.yamlwires the full PostgreSQL connection string fromfastapi-dbinto the web service at build time. You do not need to copy it manually. -
Automatic redeploys — once connected, Render redeploys the service automatically on every push to the configured branch (default:
main). Each redeploy runsuv syncto pick up any new dependencies. - Zero-downtime deploys — on paid plans, Render performs rolling deploys. On the free plan, there is a brief downtime window during each redeploy.