Overview
Argument Cartographer requires multiple environment variables for AI services, external APIs, and Firebase configuration. This guide provides a complete reference extracted from the actual codebase.Environment File Structure
Create a.env file in your project root:
.env
Variable Reference
AI Configuration
string
required
Google Gemini API Key for AI-powered argument analysis.
- Used in: All AI flows (blueprint generation, fallacy detection, summarization)
- Model: Gemini 1.5 Pro
- Get key: Google AI Studio
External API Tools
string
required
Firecrawl API Key for web scraping and search functionality.
- Used in:
web-search.ts,web-scraper.ts - Purpose: Scrapes article content and performs web searches
- Limit: 20 results per search, 20,000 characters per scrape
- Get key: Firecrawl
If Firecrawl fails or credits are depleted, the application falls back to using user query only with limited analysis mode.
string
required
Twitter API v2 Bearer Token for social media sentiment analysis.
- Used in:
twitter-search.tsfor Social Pulse feature - Query format:
{query} lang:en -is:retweet - Max results: 20 tweets, sorted by relevancy
- Get token: Twitter Developer Portal
author_id- Get full user objectstweet.fields:created_at,author_id,public_metricsuser.fields:profile_image_url,username,name
Twitter search failures are non-fatal. The application continues without social pulse data if the API fails.
Firebase Client Configuration
These variables are public (prefixed withNEXT_PUBLIC_) and exposed to the browser:
string
required
Firebase Web API key for client-side authentication.Location: Firebase Console → Project Settings → General → Web API Key
string
required
Firebase authentication domain.Format:
{project-id}.firebaseapp.comstring
required
Unique Firebase project identifier.Used in: Client SDK initialization, Firestore paths
string
required
Firebase Storage bucket name.Format:
{project-id}.appspot.comstring
required
Firebase Cloud Messaging sender ID for push notifications.
string
required
Unique Firebase app identifier.Format:
1:xxxxx:web:xxxxxxFirebase Admin Configuration
These variables are private (server-side only) and used for admin operations:string
required
Firebase project ID for admin SDK.Must match:
NEXT_PUBLIC_FIREBASE_PROJECT_IDstring
required
Service account email for Firebase Admin SDK.Format:
firebase-adminsdk-{id}@{project-id}.iam.gserviceaccount.comLocation: Firebase Console → Project Settings → Service Accounts → Generate new private keystring
required
Service account private key for server-side Firebase operations.Format: Must be enclosed in double quotes with escaped newlines:
Validation and Error Handling
The application validates environment variables at runtime:API Key Validation
Fallback Behavior
Firecrawl API Failure
Firecrawl API Failure
When Firecrawl API fails or credits are depleted:
- Application attempts fallback to general search without site filtering
- If all scraping fails, uses search snippets as context
- If search also fails, enters limited analysis mode using only the user query
Twitter API Failure
Twitter API Failure
Twitter search failures are non-fatal:The application continues without social pulse data and returns an empty tweets array.
Security Best Practices
1
Never Commit Secrets
Add
.env to .gitignore:.gitignore
2
Use Vercel Environment Variables
For production, add variables in:Vercel Dashboard → Project Settings → Environment VariablesSet scope:
- Production: Live environment
- Preview: Pull request previews
- Development: Local development (optional)
3
Rotate Keys Regularly
- Firebase service account keys: Every 90 days
- API keys: When team members leave
- Immediately if keys are exposed
4
Use Separate Environments
Maintain separate Firebase projects and API keys for:
- Development
- Staging
- Production
Testing Configuration
Verify your environment variables are loaded correctly:Troubleshooting
Environment variables not loading in Vercel
Environment variables not loading in Vercel
Solution:
- Verify variables are added in Vercel dashboard
- Check variable scope (Production/Preview/Development)
- Redeploy after adding new variables
- Ensure
NEXT_PUBLIC_prefix for client-side variables
Firebase authentication not working
Firebase authentication not working
Check:
- All 6
NEXT_PUBLIC_FIREBASE_*variables are set - Auth domain matches Firebase console
- Service account private key format (escaped newlines)
API calls failing with 401/403 errors
API calls failing with 401/403 errors
Check:
- API keys are valid and not expired
- Keys don’t have placeholder values like
YOUR_API_KEY_HERE - Billing is enabled for paid APIs
- Rate limits not exceeded
Next Steps
Firebase Setup
Configure Firebase project and security rules
Vercel Deployment
Deploy your application to production
API Errors
Debug API integration issues
Common Issues
Resolve common deployment problems
