Environment Configuration
To run the BBX Tournament Platform, you must configure several environment variables. These variables handle database connectivity via Supabase, AI integrations through OpenRouter, and application-specific settings for testing and deployment.
Create a .env or .env.local file in the root of the project and populate it with the following values.
Core Configuration
Supabase Connectivity
The application uses Supabase for data storage, real-time updates, and authentication.
| Variable | Description |
| :--- | :--- |
| NEXT_PUBLIC_SUPABASE_URL | The API URL found in your Supabase project settings. |
| NEXT_PUBLIC_SUPABASE_ANON_KEY | The anonymous "Public" API key for client-side database interactions. |
OpenRouter (AI Integration)
The platform integrates with OpenRouter to provide AI-assisted tournament features. Note that while the service is OpenRouter, the client library specifically looks for an "OpenAI" named key by default.
| Variable | Description |
| :--- | :--- |
| OPENAI_API_KEY | Your OpenRouter API key. Used to authenticate requests to https://openrouter.ai/api/v1. |
Development & Testing
Certain scripts and views rely on a hardcoded tournament ID to simplify testing and local development.
| Variable | Description |
| :--- | :--- |
| TEST_TOURNAMENT_ID | The UUID of a specific tournament used by CLI scripts (like view_bracket_results.js) and certain "strict mode" frontend views. |
Implementation Example
Below is a template for a standard .env configuration:
# Supabase (Required for Database & Auth)
NEXT_PUBLIC_SUPABASE_URL=https://your-project-id.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-public-anon-key
# OpenRouter (Required for AI features)
# Note: Variable is named OPENAI_API_KEY for compatibility with the OpenAI SDK
OPENAI_API_KEY=sk-or-v1-your-openrouter-key
# Testing & CLI Tools
TEST_TOURNAMENT_ID=550e8400-e29b-41d4-a716-446655440000
Security Considerations
- Public vs. Private: Variables prefixed with
NEXT_PUBLIC_are exposed to the browser. Never store sensitive credentials (like your OpenRouter key or Supabase Service Role key) in variables using this prefix. - Environment Sync: Ensure that
OPENAI_API_KEYis available in your deployment environment (e.g., Vercel, Docker) to allow thelib/openrouter.jsmodule to initialize correctly. - Local Scripts: If running CLI tools like
node view_bracket_results.js, ensure you havedotenvinstalled or your environment variables exported in your shell session, as these scripts rely ondotenv/configto load settings.