A FastAPI backend application with Supabase database integration, designed to compliment the React Native Mobile application Stack at Kealy Studio.
- Framework: FastAPI
- Database: Supabase (PostgreSQL)
- Package Manager: uv
- Testing: pytest, pytest-asyncio, pytest-mock
- Deployment: Docker, Google Cloud Run
python-api/
├── app/
│ ├── core/
│ │ ├── __init__.py
│ │ └── settings.py # Environment configuration (Pydantic)
│ ├── __init__.py # FastAPI app initialization
│ └── main.py # API endpoints
├── supabase/
│ ├── migrations/ # Database migrations
│ └── config.toml # Local Supabase configuration
├── tests/
│ ├── fixtures/ # Test fixtures
│ └── conftest.py # pytest configuration
├── .github/workflows/ # CI/CD workflows
├── Dockerfile
├── pyproject.toml
└── uv.lock
- Python 3.10 - 3.12
- uv package manager
- Supabase CLI (for local development)
-
Install dependencies:
uv sync --all-groups
-
Start local Supabase:
supabase start
-
Copy environment variables:
mv .env.example .env mv supabase/.env.example supabase/.env
-
Run the development server:
uv run uvicorn app.main:app --host 0.0.0.0 --port 8080
uv run pytestSupabase migrations are in supabase/migrations/. Current schema includes:
users- User profiles synced with Supabase Authdevices- A user may have many devices
- API: Deployed to Google Cloud Run (see
.github/workflows/gcp-deploy.yaml) - Database: Migrations deployed via GitHub Actions (see
.github/workflows/supabase-deploy-migrations.yaml)
The command to deploy is:
# Set the variables
export PROJECT_ID=
export REGION=us-east1
export SERVICE_NAME=
# Get the project number
PROJECT_NUMBER=$(gcloud projects describe $PROJECT_ID --format="value(projectNumber)")
# Give the deployment service account access to the secrets
gcloud projects add-iam-policy-binding $PROJECT_NUMBER \
--member="serviceAccount:$PROJECT_NUMBER-compute@developer.gserviceaccount.com" \
--role="roles/secretmanager.secretAccessor"
# Deploy to Cloud Run
gcloud run deploy $SERVICE_NAME \
--source . \
--region=$REGION \
--project=$PROJECT_ID \
--allow-unauthenticated \
--service-account="$PROJECT_NUMBER-compute@developer.gserviceaccount.com"