Skip to content

Latest commit

 

History

History
102 lines (70 loc) · 4.64 KB

File metadata and controls

102 lines (70 loc) · 4.64 KB

FrameSignal Supabase Setup

This project now has the Supabase foundation installed, but it does not connect any real data yet.

What Supabase Will Be Used For Later

Supabase will eventually support:

  • PostgreSQL database tables for articles, movies, moods, tags, media metadata, and CMS records.
  • Supabase Auth for admin and editor access.
  • Supabase Storage or another approved storage provider for future media workflows.
  • Row Level Security policies for safe public/admin data access.
  • CMS data for the FrameSignal admin dashboard and publishing workflow.

What This Task Added

Task 3A added:

  • @supabase/supabase-js
  • @supabase/ssr
  • .env.example
  • src/lib/supabase/env.ts
  • src/lib/supabase/browser-client.ts
  • src/lib/supabase/server-client.ts
  • This setup guide

The client utilities are not imported into pages yet. Existing public pages and the admin mock shell still use static mock data.

Task 3B added the initial schema migration at supabase/migrations/0001_initial_schema.sql and the beginner schema guide at docs/database-schema.md. The migration has not been applied to a real Supabase project yet.

Task 3C added the first RLS policy migration at supabase/migrations/0002_rls_policies.sql and the beginner policy guide at docs/rls-policy-plan.md. The policy migration has not been applied to a real Supabase project yet.

Task 3D added local demo seed data at supabase/seed.sql and the beginner seed guide at docs/seed-data.md. The seed file has not been applied to a real Supabase project yet.

Task 3E added local Supabase workflow scripts, the Supabase CLI dev dependency, a placeholder generated-types file at src/types/database.types.ts, and the beginner local workflow guide at docs/local-supabase-workflow.md.

Local database testing should happen before cloud deployment. Start with the local workflow guide when a future task asks to run Supabase locally.

Task 3F added the auth profile lifecycle migration at supabase/migrations/0003_auth_profile_lifecycle.sql and the beginner guide at docs/auth-profile-lifecycle.md. It prepares the database for future staff auth, but auth UI is still a future task.

Task 4A added Supabase admin sign-in, sign-out, session refresh through proxy.ts, and protected /admin access for active admin or editor profiles. See docs/admin-auth-setup.md. CRUD, CMS editing, storage, and public data integration are still deferred.

Environment Variables

Use .env.example as the template:

NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=

# Future server-only keys. Not used yet.
SUPABASE_SECRET_KEY=
SUPABASE_SERVICE_ROLE_KEY=

Do not put real credentials in .env.example.

For local development later, create .env.local manually and add real values there. .env.local is intentionally ignored by Git.

For production later, add the same values in Vercel project environment variables.

Creating A Supabase Project Later

When the task explicitly asks to connect Supabase:

  1. Go to the Supabase dashboard.
  2. Create a new project.
  3. Open the project settings or connection/API area.
  4. Copy the project URL into NEXT_PUBLIC_SUPABASE_URL.
  5. Copy the publishable key into NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY.
  6. Add those values to .env.local locally.
  7. Add those values to Vercel environment variables before deployment.

The official Supabase Next.js SSR guide uses @supabase/ssr and separate browser/server client helpers: https://supabase.com/docs/guides/auth/server-side/creating-a-client?framework=nextjs&package-manager=npm

Key Safety Rules

  • Public browser variables must use the NEXT_PUBLIC_ prefix.
  • Server-only keys must never use NEXT_PUBLIC_.
  • Do not import service role or secret keys into Client Components.
  • Do not expose service role or secret keys in browser code, bundled JavaScript, logs, screenshots, or public documentation.
  • Use publishable/public keys for browser and normal SSR clients.
  • Reserve service role usage for carefully reviewed server-only tasks later.

Still Not Connected Yet

These pieces are still intentionally deferred:

  • Authentication
  • Applying the database migration to a real Supabase project
  • Creating auth users or staff profiles in a real Supabase project
  • Testing RLS policies in a real Supabase project
  • Applying seed data to a real Supabase project
  • CRUD flows
  • CMS editing and publishing workflows
  • API routes
  • Server actions beyond admin login
  • Storage or media upload
  • Real CMS data

FrameSignal remains a mostly static mock-data frontend until later Supabase-specific tasks explicitly apply the migrations, load reviewed seed data, test or modify RLS policies, create staff accounts, or connect CRUD.