Skip to main content

Documentation 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.

Social Media Backend uses pydantic-settings to load all runtime configuration from environment variables or a .env file placed in the project root (the directory containing pyproject.toml). Every variable listed below is required — the application calls Settings() at import time and will raise a ValidationError and refuse to start if any variable is absent or incorrectly typed.

Environment file template

Copy the block below into a file named .env in the project root and fill in your values before starting the server.
.env
DATABASE_HOSTNAME=localhost
DATABASE_PORT=5432
DATABASE_PASSWORD=your_password
DATABASE_USERNAME=postgres
DATABASE_NAME=social_media
SECRET_KEY=your_super_secret_key_here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=60
Never commit .env to source control. The file contains your database credentials and JWT signing secret. Add .env to your .gitignore immediately.
echo ".env" >> .gitignore

Variable reference

Database connection

The application constructs the SQLAlchemy connection URL internally from the five individual database variables below. There is no DATABASE_URL variable in the Settings class — do not set one in your .env file.
postgresql://{DATABASE_USERNAME}:{DATABASE_PASSWORD}@{DATABASE_HOSTNAME}:{DATABASE_PORT}/{DATABASE_NAME}

JWT authentication

How settings are loaded

The Settings class in app/config.py inherits from pydantic_settings.BaseSettings. At startup, pydantic-settings reads variables from the process environment first, then falls back to the .env file declared in the inner Config class:
from pydantic_settings import BaseSettings

class Settings(BaseSettings):
    database_hostname: str
    database_port: str
    database_password: str
    database_username: str
    database_name: str
    secret_key: str
    algorithm: str
    access_token_expire_minutes: int

    class Config:
        env_file = ".env"

settings = Settings()
The module-level settings singleton is imported throughout the application (e.g. in database.py and oauth2.py), so it is evaluated once at import time. Any missing or mis-typed variable causes an immediate startup failure with a descriptive validation error.
In production (e.g. Render, Railway, Fly.io), set these variables as platform-level environment variables rather than deploying a .env file. Process environment variables always take precedence over the .env file, so the same Settings class works in both local and deployed environments without any code changes.

Build docs developers (and LLMs) love