Environment Files
Yggdrasil uses different environment files for different deployment contexts:.env.local— Local development (not committed to git).env.example— Template with placeholder values (committed to git).env.production— Production values (not committed to git, used for reference)
.env.example to .env.local and fill in your credentials:
Required Variables
These variables must be set for the application to function.Your Supabase project URL.Format:
https://your-project.supabase.coWhere to find it: Supabase Dashboard → Settings → API → Project URLExample:Your Supabase anonymous (public) API key.Format: A long base64-encoded string starting with
eyJWhere to find it: Supabase Dashboard → Settings → API → Project API keys → anon publicExample:This key is safe to expose in client-side code. Supabase uses Row-Level Security (RLS) policies to enforce access control. The anon key only allows users to access their own data (filtered by
auth.uid()).Your Google AI Studio API key for Gemini.Where to find it: Google AI Studio → Get API KeyExample:Used for:
- Extracting rules from uploaded PDF policy documents
- Suggesting column mappings for uploaded CSV files
- Generating AI-powered remediation steps for violations
Optional Variables
The base URL of your application.Example (local):Example (production):Used for:
- Generating absolute URLs for emails and redirects
- OAuth callback URLs (if using social auth)
Enable demo mode to bypass authentication with a hardcoded demo session.Example:When enabled:
- Users are automatically signed in with a demo account
- No email/password is required
- All data is associated with the demo user
- Users must sign up and authenticate via Supabase Auth
- Row-Level Security enforces data isolation between users
Production Configuration
For production deployments, use these guidelines:1. Disable demo mode
2. Set production URLs
3. Use production Supabase keys
Ensure you’re using the production Supabase project keys, not development keys. Production keys should have RLS policies enabled on all tables.4. Secure your Gemini API key
- Store
GEMINI_API_KEYas an environment variable in your deployment platform (Vercel, AWS, etc.) - Never commit it to git
- Rotate the key periodically
5. Enable HTTPS
Your production deployment must use HTTPS. All Supabase auth flows require secure cookies.Vercel Deployment
If deploying to Vercel, add environment variables in the Vercel dashboard:- Go to Project Settings → Environment Variables
- Add each variable with the appropriate scope (Production, Preview, Development)
- Redeploy to apply changes
Security Best Practices
Public vs. Private Variables
Public vs. Private Variables
NEXT_PUBLIC_*variables are embedded in the client-side JavaScript bundle. Anyone can read them by inspecting the browser’s network tab or JavaScript console.- Private variables (without the prefix) are only available server-side in Next.js API routes and Server Components.
NEXT_PUBLIC_ for values that are safe to expose (Supabase URL, anon key, app URL, feature flags).Supabase Row-Level Security (RLS)
Supabase Row-Level Security (RLS)
Yggdrasil relies on RLS policies to enforce data isolation. Even though
NEXT_PUBLIC_SUPABASE_ANON_KEY is public, users can only access data that belongs to them.All tables (policies, rules, scans, violations, pii_findings) have RLS policies that filter rows by auth.uid().Example RLS policy for policies table:Gemini API Key Protection
Gemini API Key Protection
GEMINI_API_KEY is server-side only. It is never sent to the client.To protect it:- Store it as an environment variable (not in code)
- Use a secret manager in production (AWS Secrets Manager, Vercel Environment Variables, etc.)
- Rotate the key if it is ever leaked
- Monitor Google AI Studio usage to detect unauthorized access
Demo Mode Security
Demo Mode Security
Demo mode (
NEXT_PUBLIC_DEMO_MODE=true) is not secure for multi-user deployments.When enabled:- All users share the same demo account
- No authentication is required
- Data is not isolated between users
- Local development
- Public read-only demos (with a separate demo database)
Troubleshooting
”Invalid Supabase URL” error
- Ensure
NEXT_PUBLIC_SUPABASE_URLis set and starts withhttps:// - Verify the URL matches your Supabase project (check the dashboard)
- Restart the dev server after changing
.env.local
”Unauthorized” errors from Supabase
- Check that
NEXT_PUBLIC_SUPABASE_ANON_KEYis correct - Verify RLS policies are enabled on all tables
- Ensure you’re signed in (or demo mode is enabled)
“Gemini API key not found” error
- Ensure
GEMINI_API_KEYis set in.env.local(withoutNEXT_PUBLIC_prefix) - Restart the dev server after adding the key
- Verify the key is valid by testing it in Google AI Studio
Changes to .env.local not taking effect
- Restart the Next.js dev server (
npm run dev) - Clear the browser cache and reload
- Check for typos in variable names (environment variables are case-sensitive)
Next Steps
Installation
Set up Yggdrasil for self-hosted deployment
Quickstart
Run your first compliance scan