This guide will help you set up the Pascal Editor with authentication and database integration.
- Node.js 18+ or Bun 1.3+
- Docker Desktop (for running Supabase locally)
bun installThis installs the Supabase CLI as a dev dependency - no need for global installation!
bun db:startThis will start a local Supabase instance. You'll see output like:
API URL: http://127.0.0.1:54321
DB URL: postgresql://postgres:postgres@127.0.0.1:54322/postgres
Studio URL: http://127.0.0.1:54323
Anon key: eyJh...
Service role key: eyJh...
Create apps/editor/.env.local with the following variables:
# Database Connection (Supabase local)
POSTGRES_URL=postgresql://postgres:postgres@127.0.0.1:54322/postgres
# Supabase Configuration
NEXT_PUBLIC_SUPABASE_URL=http://127.0.0.1:54321
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU
# Better Auth (generate your own secret with: openssl rand -base64 32)
BETTER_AUTH_SECRET=<generate_with_command_below>
BETTER_AUTH_URL=http://localhost:3000
# Google Maps (optional, for address search)
NEXT_PUBLIC_GOOGLE_MAPS_API_KEY=<your_google_maps_key>Generate a secret for BETTER_AUTH_SECRET:
openssl rand -base64 32bun db:resetThis will create all necessary tables for authentication and properties.
bun devThe editor will be available at http://localhost:3000
.
├── apps/
│ └── editor/ # Next.js editor application
│ ├── app/
│ │ └── api/auth/ # Better Auth API routes
│ ├── components/ # UI components
│ └── features/
│ └── cloud-sync/ # Cloud sync feature
├── packages/
│ ├── auth/ # @pascal-app/auth - Authentication package
│ │ ├── src/
│ │ │ ├── server.ts # Better Auth server config
│ │ │ └── client.ts # Better Auth client
│ │ └── README.md
│ ├── db/ # @pascal-app/db - Database package
│ │ ├── src/
│ │ │ ├── client.ts # Supabase client (with RLS)
│ │ │ ├── server.ts # Supabase admin client
│ │ │ └── types.ts # Database types
│ │ ├── supabase/
│ │ │ ├── config.toml
│ │ │ └── migrations/ # SQL migrations
│ │ └── README.md
│ ├── core/ # @pascal-app/core - Core editor logic
│ ├── viewer/ # @pascal-app/viewer - 3D viewer
│ └── ui/ # @repo/ui - Shared UI components
└── turbo.json
- users - User accounts with email and profile
- sessions - Active authentication sessions
- accounts - OAuth provider accounts (for future use)
- verification_tokens - Magic link tokens
-
properties - User properties
id: Property IDname: Property nameowner_id: User ID (foreign key to users)
-
properties_addresses - Property addresses with Google Maps data
id: Address IDproperty_id: Property ID (foreign key)formatted_address: Full addresslatitude,longitude: GPS coordinates- Plus detailed address components (street, city, state, etc.)
-
properties_models - Scene graph models (versions)
id: Model IDproperty_id: Property ID (foreign key)name: Model nameversion: Version numberdraft: Draft statusscene_graph: JSONB scene graph data
- Magic Link Sign-In: Passwordless authentication via email
- Session Management: 7-day sessions with automatic refresh
- Cookie-based: Secure httpOnly cookies
- Create Properties: Add properties with real-world addresses
- Google Maps Integration: Address autocomplete and geocoding
- Switch Properties: Seamlessly switch between properties
- Auto-Save: Changes saved every 2 seconds
- Scene Loading: Automatic scene loading when switching properties
- Version Control: Models are versioned for future rollback support
-
Create a new migration:
cd packages/db supabase migration new your_migration_name -
Edit the migration file in
supabase/migrations/ -
Apply the migration:
supabase db reset
After changing the database schema, regenerate TypeScript types:
- Update
packages/db/src/types.tsto match your new schema - Run
bun installto update type checking
- Start the editor:
bun dev - Click "Save to cloud" button
- Enter your email
- Check console for magic link (not sent via email in development)
- Click the link to authenticate
Access the local Supabase Studio at: http://127.0.0.1:54323
Use this to:
- Browse and edit tables
- Run SQL queries
- View logs
- Manage RLS policies
- Test database functions
For production deployment:
- Create a Supabase project at https://supabase.com
- Get your production database connection string
- Update environment variables in your hosting platform
- Link and push migrations:
cd packages/db bunx supabase link --project-ref your-project-ref bunx supabase db push - Configure email provider in
packages/auth/src/server.ts
Make sure you've set POSTGRES_URL in apps/editor/.env.local to your Supabase connection string.
Try stopping and restarting:
bun db:stop
bun db:startReset the database:
cd packages/db
supabase db reset- Check that Better Auth API route exists at
apps/editor/app/api/auth/[...all]/route.ts - Verify
BETTER_AUTH_SECRETandBETTER_AUTH_URLare set - Check console for magic link URLs in development
- Configure email provider for magic links
- Add OAuth providers (Google, GitHub, etc.)
- Set up production Supabase project
- Configure RLS policies for additional security
- Add more property features (sharing, collaboration, etc.)