Skip to content

Commit 7c56f68

Browse files
docs+ci: add docs/DEPLOYMENT.md
Signed-off-by: laurentketterle-hub <laurentketterle-hub@users.noreply.github.com>
1 parent acd915d commit 7c56f68

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

docs/DEPLOYMENT.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Deployment Guide
2+
3+
This guide documents how to deploy and operate the AI growth platform's
4+
Supabase backend.
5+
6+
## Prerequisites
7+
8+
- A Supabase project (or a self-hosted Supabase instance).
9+
- The Supabase CLI (`supabase`) installed and authenticated.
10+
- Node.js 20+ for building and testing edge functions.
11+
- Access to the project's environment variables (see `.env.example`).
12+
13+
## Environment variables
14+
15+
| Variable | Purpose | Required |
16+
|---|---|---|
17+
| `SUPABASE_URL` | Project URL | yes |
18+
| `SUPABASE_SERVICE_ROLE_KEY` | Server-side API key (never expose in client code) | yes |
19+
| `UPSTREAM_FEED_URL` | Primary opportunity feed endpoint | yes |
20+
| `UPSTREAM_FEED_FALLBACK` | Secondary discovery endpoint | no |
21+
| `LOG_LEVEL` | Logging verbosity (`debug`, `info`, `warn`, `error`) | no |
22+
23+
Secrets must be stored in Supabase's secret manager, never committed to the
24+
repository.
25+
26+
## Deploying edge functions
27+
28+
```bash
29+
# Link to the project
30+
supabase link --project-ref <project-ref>
31+
32+
# Deploy a single function
33+
supabase functions deploy runtime-opportunity-scout
34+
35+
# Deploy all functions
36+
supabase functions deploy
37+
```
38+
39+
After deploying, verify the function responds:
40+
41+
```bash
42+
curl -s https://<project-ref>.supabase.co/functions/v1/runtime-opportunity-scout
43+
```
44+
45+
## Configuration management
46+
47+
Function configuration is set through Supabase secrets:
48+
49+
```bash
50+
supabase secrets set UPSTREAM_FEED_URL=https://api.example.com/feed
51+
supabase secrets set UPSTREAM_FEED_FALLBACK=https://api.example.com/fallback
52+
```
53+
54+
Rotate secrets with `supabase secrets set` (which overwrites) rather than
55+
editing files in place.
56+
57+
## Scheduled ingestion
58+
59+
Opportunity discovery is intended to run on a schedule. Configure the schedule
60+
through Supabase's cron extension or an external scheduler that invokes the
61+
function on an interval. Keep the interval conservative (no more than once per
62+
hour) to stay within upstream rate limits.
63+
64+
## Rollback
65+
66+
Edge functions are versioned. To roll back:
67+
68+
```bash
69+
supabase functions deploy runtime-opportunity-scout --use-verification=false
70+
```
71+
72+
Or re-deploy the previous bundle from CI history. Keep deployment artifacts
73+
(e.g. CI run IDs) in the runbook so a bad release can be reverted quickly.
74+
75+
## Monitoring checklist
76+
77+
- Watch function invocation count and error rate in the Supabase dashboard.
78+
- Alert on zero discovered opportunities over a full day, which usually means
79+
an upstream endpoint changed format.
80+
- Review structured logs for fallback-path hits; repeated fallbacks indicate
81+
the primary endpoint is unhealthy.
82+
83+
## Troubleshooting
84+
85+
| Symptom | Likely cause | Action |
86+
|---|---|---|
87+
| Zero opportunities | Upstream changed format | Check logs, update ingest mapping |
88+
| HTML shell returned | Endpoint now serves JS app | Verify fallback path is configured |
89+
| High error rate | Rate limited upstream | Lower schedule frequency |
90+
| `task_id` collisions | URL normalization changed | Revert URL canonicalization |

0 commit comments

Comments
 (0)