Skip to content

Commit 17d72b9

Browse files
committed
tweaks during dry run
1 parent 8a3cd18 commit 17d72b9

10 files changed

Lines changed: 64 additions & 59 deletions

File tree

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
# App environment (development, preview, production)
2+
APP_ENV=development
3+
14
# Your Supabase project URL: Note the ip address is tailored for use over your local network (you probably don't need to change this)
2-
SUPABASE_URL=http://127.0.0.1:54321
5+
SUPABASE_URL=http://192.168.1.102:54321
36

4-
# Your Supabase secret key (get this by running supabase start or supabase status)
7+
# Your Supabase anon/public key (get this by running supabase start or supabase status)
58
SUPABASE_SECRET_KEY=get-this-from-running-supabase-start-or-supabase-status
6-
7-
# App environment (development, preview, production)
8-
APP_ENV=development

‎.github/workflows/scheduled-backups.yaml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
# This workflow backs up the Supabase database (roles, schema, and data) to
66
# Google Cloud Storage. It can be triggered manually or on a schedule.
77
#
8-
# NOTE: THIS WORKFLOW ISN'T OFFICIALLY SUPPORTED BY MOSAYIC YET. YOU CAN USE IT IF YOU
8+
# NOTE: THIS WORKFLOW ISN'T OFFICIALLY SUPPORTED. YOU CAN USE IT IF YOU
99
# FIGURE OUT HOW TO SET UP THE REQUIRED GCP PERMISSIONS AND SECRETS YOURSELF (GCP STORAGE
1010
# AND GITHUB ACTIONS SECRETS). OTHERWISE, IGNORE IT FOR NOW UNTIL THE FEATURE BECOMES
1111
# SUPPORTED IN A MORE USER-FRIENDLY WAY. NOTE THAT IF YOU'RE USING THE PAID VERSION OF
1212
# SUPABASE, THEY PROVIDE AUTOMATIC BACKUPS AS PART OF THE SERVICE, SO YOU WON'T NEED THIS.
1313
#
14+
# Get in touch with John if you're interested in this feature.
1415
#
1516
# Requirements:
1617
# - SUPABASE_DB_URL: Database URL (e.g., postgresql://postgres:[PASSWORD]@db.<ref>.supabase.co:5432/postgres)

‎.github/workflows/supabase-deploy-migrations.yaml‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,19 @@
77
#
88
# Requirements:
99
# - The Python API codebase with the migrations folder up to do date.
10-
# - A GitHub Actions Secret named 'SUPABASE_DB_URL_PROD', containing the database URL.
10+
# - A GitHub Actions Secret named 'DATABASE_CONNECTION_STRING', containing the database URL.
1111
# You can find this URL in the Supabase dashboard; you'll need to also insert the
12-
# dataabase password into the URL.
12+
# database password into the URL.
1313
#
14-
# This workflow is currently disabled for pushes to 'main' branch. To enable it, change the branch
15-
# name from 'none' to 'main' in the 'push' event section.
14+
# This workflow is currently disabled. To enable it, set the on: triggers to the desired branches/events.
1615
#
1716
###################################
1817

1918
name: Deploy Supabase Migrations
2019

2120
on:
2221
release:
23-
types: [none] # set this to 'published' to run on release creation
22+
types: [none] # set this to 'published' to run on release creation (Recommended)
2423
push:
2524
branches:
2625
- none # set this to 'main' to run on pushes to the main branch
@@ -34,13 +33,13 @@ jobs:
3433
uses: actions/checkout@v3
3534

3635
- name: Setup Supabase CLI
37-
# if: github.event_name == 'release'
36+
if: github.event_name == 'release'
3837
uses: supabase/setup-cli@v1
3938
with:
4039
version: latest
4140

4241
- name: Push Supabase Migrations to Prod
43-
# if: github.event_name == 'release'
42+
if: github.event_name == 'release'
4443
env:
4544
DATABASE_CONNECTION_STRING: ${{ secrets.DATABASE_CONNECTION_STRING }}
4645
run: |

‎.gitignore‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.env*
2-
!.env.local.example
2+
!.env..example
3+
!.env.example
4+
35

46

57
*.py[cod]

‎README.md‎

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Mosayic Python API
1+
# Python API
22

3-
A FastAPI backend application with Supabase database integration.
3+
A FastAPI backend application with Supabase database integration, designed to compliment the React Native Mobile application Stack at Kealy Studio.
44

55
## Tech Stack
66

@@ -44,7 +44,7 @@ python-api/
4444

4545
1. Install dependencies:
4646
```bash
47-
uv sync
47+
uv sync --all-groups
4848
```
4949

5050
2. Start local Supabase:
@@ -54,12 +54,13 @@ python-api/
5454

5555
3. Copy environment variables:
5656
```bash
57-
cp .env.local.example .env.local
57+
mv .env.example .env
58+
mv supabase/.env.example supabase/.env
5859
```
5960

6061
4. Run the development server:
6162
```bash
62-
uv run uvicorn app.main:app --reload --port 8080
63+
uv run uvicorn app.main:app --host 0.0.0.0 --port 8080
6364
```
6465

6566
### Running Tests
@@ -68,40 +69,36 @@ python-api/
6869
uv run pytest
6970
```
7071

71-
### Docker
7272

73-
Build and run the container:
74-
75-
```bash
76-
docker build -t mosayic-api .
77-
docker run -p 8080:8080 mosayic-api
78-
```
79-
80-
## Environment Variables
81-
82-
Configure in `.env.local` for development:
83-
84-
| Variable | Description |
85-
|----------|-------------|
86-
| `supabase_url` | Supabase project URL |
87-
| `supabase_secret_key` | Supabase service role key |
88-
| `api_key` | API authentication key |
89-
| `debug_mode` | Enable debug mode (default: false) |
90-
| `environment` | Environment name (development/production) |
9173

9274
## Database
9375

9476
Supabase migrations are in `supabase/migrations/`. Current schema includes:
9577

9678
- `users` - User profiles synced with Supabase Auth
97-
- `items` - User-owned items
79+
- `devices` - A user may have many devices
80+
9881

99-
Run migrations locally:
100-
```bash
101-
supabase db push
102-
```
10382

10483
## Deployment
10584

10685
- **API**: Deployed to Google Cloud Run (see `.github/workflows/gcp-deploy.yaml`)
10786
- **Database**: Migrations deployed via GitHub Actions (see `.github/workflows/supabase-deploy-migrations.yaml`)
87+
88+
The command to deploy is:
89+
```
90+
# Set the variables
91+
export PROJECT_ID=goat-together
92+
export REGION=eu-west1
93+
export SERVICE_NAME=goattogether-api
94+
95+
# Get the project number
96+
PROJECT_NUMBER=$(gcloud projects describe $PROJECT_ID --format="value(projectNumber)")
97+
98+
# Deploy to Cloud Run
99+
gcloud run deploy $SERVICE_NAME \
100+
--source . \
101+
--region=$REGION \
102+
--project=$PROJECT_ID \
103+
--allow-unauthenticated
104+
```

‎app/core/settings.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class Settings(BaseSettings):
99
model_config = SettingsConfigDict(
10-
env_file=".env.local",
10+
env_file=".env",
1111
extra='allow',
1212
env_file_encoding='utf-8'
1313
)

‎app/main.py‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
55
Later, if you need to more control, you can access the FastAPI app instance directly, or just create your own.
66
"""
7-
from fastapi import Depends
8-
from supabase_auth.types import User
9-
10-
from app import app
11-
from app.core.auth import get_current_user
12-
from app.routes.auth_router import router as auth_router
7+
from fastapi import Depends
8+
from supabase_auth.types import User
139

10+
from app import app
11+
from app.core.auth import get_current_user
12+
from app.routes.auth_router import router as auth_router
1413

15-
@app.get("/public")
14+
15+
@app.get("/")
1616
async def public_route():
17-
return {"message": "Welcome to your Python API!"}
17+
return {"message": "Welcome to the Python API!"}
18+
19+
20+
@app.get("/protected")
21+
async def protected_route(user: User = Depends(get_current_user)):
22+
return {"message": "You are authenticated!", "user_id": user.id}
1823

1924

20-
@app.get("/protected")
21-
async def protected_route(user: User = Depends(get_current_user)):
22-
return {"message": "You are authenticated!", "user_id": user.id}
23-
24-
25-
app.include_router(auth_router)
25+
app.include_router(auth_router)

‎app/routes/auth_router.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from app.core.auth import delete_auth_user, get_current_user
55

6-
router = APIRouter(prefix="/auth", tags=["auth"])
6+
router = APIRouter(prefix="/auth", tags=["Auth"])
77

88

99
@router.delete("/users/{user_id}")

‎supabase/.env.example‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Google OAuth credentials for Supabase Auth (get secret from Google Cloud Console)
2+
SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID=<get this from Google Cloud Console>
3+
SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET=<get this from Google Cloud Console>
4+
5+
# Supabase PostgreSQL password (DO NOT REFERENCE THIS IN YOUR CODE)
6+
SUPABASE_DB_PASSWORD=your-postgres-password
File renamed without changes.

0 commit comments

Comments
 (0)