> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Environment Configuration

> > Current Environment: STAGING

> **Current Environment:** STAGING

## Quick Reference

| Environment | Project ID             | Status     |
| ----------- | ---------------------- | ---------- |
| Production  | `zkgxozahyczcnzpwhbbf` | ⚪ Inactive |
| Staging     | `rzfzikcargkoyhgqllap` | 🟢 Active  |

***

## Environment Credentials

### Production

```env theme={null}
# .env
VITE_SUPABASE_PROJECT_ID="zkgxozahyczcnzpwhbbf"
VITE_SUPABASE_PUBLISHABLE_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InprZ3hvemFoeWN6Y256cHdoYmJmIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njg0OTIxNTEsImV4cCI6MjA4NDA2ODE1MX0.BCZHeeKYdbPjSCCIO21W4KK6AMcuFUo4oXVBjfjAAVY"
VITE_SUPABASE_URL="https://zkgxozahyczcnzpwhbbf.supabase.co"
```

```toml theme={null}
# supabase/config.toml
project_id = "zkgxozahyczcnzpwhbbf"
```

**Dashboard:** [https://supabase.com/dashboard/project/zkgxozahyczcnzpwhbbf](https://supabase.com/dashboard/project/zkgxozahyczcnzpwhbbf)

***

### Staging

```env theme={null}
# .env
VITE_SUPABASE_PROJECT_ID="rzfzikcargkoyhgqllap"
VITE_SUPABASE_PUBLISHABLE_KEY="sb_publishable_zDoiXHBgmMkcun6uHShNOA_dVzvZ4Tn"
VITE_SUPABASE_URL="https://rzfzikcargkoyhgqllap.supabase.co"
```

```toml theme={null}
# supabase/config.toml
project_id = "rzfzikcargkoyhgqllap"
```

**Dashboard:** [https://supabase.com/dashboard/project/rzfzikcargkoyhgqllap](https://supabase.com/dashboard/project/rzfzikcargkoyhgqllap)

***

## Switching Environments

### New Workflow (Using Supabase CLI)

The project now uses multi-environment configuration in `supabase/config.toml` with `[remotes]` blocks. This allows seamless switching between environments using the Supabase CLI.

**Important:** The `.env` file still needs to be updated for frontend application configuration. The `supabase/config.toml` is now managed via CLI commands.

### Local Development

```bash theme={null}
# Start local Supabase stack (uses default config)
npx supabase start

# Verify services are running
npx supabase status

# Stop local stack when done
npx supabase stop
```

**Frontend Configuration:**

* Update `.env` with local Supabase URL and keys from `npx supabase status`
* Or use staging/production URLs if testing against remote

### To Switch to Staging

**CLI Configuration:**

```bash theme={null}
# Link to staging project
npx supabase link --project-ref rzfzikcargkoyhgqllap

# Verify connection
npx supabase status

# Deploy migrations (when ready)
npx supabase db push

# Deploy edge functions (when ready)
npx supabase functions deploy
```

**Frontend Configuration:**

1. Update `.env` with **Staging** credentials above
2. Wait for Lovable to auto-regenerate `src/integrations/supabase/client.ts`
3. Wait for Lovable to auto-regenerate `src/integrations/supabase/types.ts`
4. Update "Current Environment" at top of this file to STAGING

### To Switch to Production

**⚠️ WARNING: Production environment - use with extreme caution!**

**CLI Configuration:**

```bash theme={null}
# Link to production project
npx supabase link --project-ref zkgxozahyczcnzpwhbbf

# ALWAYS verify you're connected to production
npx supabase status

# Deploy migrations (ONLY after staging validation)
npx supabase db push

# Deploy edge functions (ONLY after staging validation)
npx supabase functions deploy
```

**Frontend Configuration:**

1. Update `.env` with **Production** credentials above
2. Wait for Lovable to auto-regenerate `src/integrations/supabase/client.ts`
3. Wait for Lovable to auto-regenerate `src/integrations/supabase/types.ts`
4. Update "Current Environment" at top of this file to PRODUCTION

### Switching Between Environments

```bash theme={null}
# Switch from production to staging
npx supabase link --project-ref rzfzikcargkoyhgqllap

# Switch from staging to production (be careful!)
npx supabase link --project-ref zkgxozahyczcnzpwhbbf

# Switch back to local development
npx supabase unlink
npx supabase start
```

### Checklist

When switching environments:

* [ ] **CLI:** Link to correct project using `npx supabase link --project-ref <project-id>`
* [ ] **CLI:** Verify connection with `npx supabase status`
* [ ] **Frontend:** Update `.env` with correct `VITE_SUPABASE_*` variables
* [ ] **Frontend:** Wait for Lovable to auto-regenerate client and types
* [ ] **Documentation:** Update "Current Environment" at top of this file

***

## Environment Purposes

| Environment    | Purpose               | Data                |
| -------------- | --------------------- | ------------------- |
| **Production** | Live application      | Real user data      |
| **Staging**    | Development & testing | Synthetic test data |

### When to Use Each

* **Staging**: New feature development, migration testing, debugging
* **Production**: Verified deployments only, after staging validation

***

## Files Updated During Switch

| File                                  | Update Method              | Notes                                              |
| ------------------------------------- | -------------------------- | -------------------------------------------------- |
| `.env`                                | Manual                     | Update `VITE_SUPABASE_*` variables for frontend    |
| `supabase/config.toml`                | Managed via CLI            | Uses `[remotes]` blocks - no manual editing needed |
| `src/integrations/supabase/client.ts` | Auto-generated by Lovable  | Regenerates when `.env` changes                    |
| `src/integrations/supabase/types.ts`  | Auto-generated from schema | Regenerates when `.env` changes                    |

## Configuration Details

### Supabase CLI Configuration

The `supabase/config.toml` file now uses multi-environment configuration:

* **Default config:** Used for local development (`npx supabase start`)
* **`[remotes.staging]`:** Configuration for staging project (`rzfzikcargkoyhgqllap`)
* **`[remotes.production]`:** Configuration for production project (`zkgxozahyczcnzpwhbbf`)

See `docs/development/SUPABASE_MULTI_ENV_SETUP.md` for complete documentation.

### Frontend Environment Variables

The `.env` file controls which Supabase project the frontend application connects to:

* **Local:** Use credentials from `npx supabase status` output
* **Staging:** Use staging credentials (see Staging section above)
* **Production:** Use production credentials (see Production section above)

***

*Last updated: 2026-01-16*
