Configuration Guide
This guide covers all configuration options for Tarefa AI, including API keys, integrations, and advanced settings.
Environment Variables
Core Configuration
Database
DATABASE_URL="postgresql://postgres:postgres@localhost:5433/claude_scheduler"For production (Neon, Supabase, etc.):
DATABASE_URL="postgresql://user:password@host.region.aws.neon.tech:5432/dbname?sslmode=require"Encryption Key
Required for securely storing API keys:
# Generate a secure 64-character hex key
openssl rand -hex 32ENCRYPTION_KEY="your-64-character-hex-key-here"Never reuse the same encryption key across environments. Generate unique keys for development, staging, and production.
AI Provider Configuration
OpenRouter API
OpenRouter provides access to 200+ AI models through a single API:
- Create account at OpenRouter.ai
- Navigate to Keys
- Generate an API key
- Add credits (minimum $5)
OPENROUTER_API_KEY="sk-or-v1-xxxxxxxxxxxxxx"
NEXT_PUBLIC_OPENROUTER_API_KEY="sk-or-v1-xxxxxxxxxxxxxx"The NEXT_PUBLIC_ prefix exposes the key to the browser for client-side model selection. This is safe as all actual API calls are server-side.
Supported Models (25+):
- Claude Sonnet 4.5, Opus 4, Haiku
- GPT-5 Pro, GPT-5, o3, o4 Mini, GPT-4o
- Gemini 2.5 Pro/Flash/Lite
- Grok 4, Grok 4 Fast
- DeepSeek V3.1 (FREE)
- Llama 3.3 70B (FREE)
Notification Services
Email (Resend)
Professional email notifications:
- Sign up at Resend.com
- Verify your sending domain
- Generate API key
RESEND_API_KEY="re_xxxxxxxxxxxx"
RESEND_FROM_EMAIL="notifications@yourdomain.com"WhatsApp (Evolution API)
Send WhatsApp notifications:
- Set up Evolution API instance (self-hosted or cloud)
- Create instance and connect WhatsApp number
- Generate API key
EVOLUTION_API_URL="https://your-evolution-api.com"
EVOLUTION_API_KEY="your-api-key"
EVOLUTION_INSTANCE="instance-name"Evolution API supports both official WhatsApp Business API and WhatsApp Web. Choose based on your volume needs.
Integration Services
Notion
Post AI results directly to Notion databases:
- Go to Notion Integrations
- Create new integration
- Copy Internal Integration Token
- Share your database with the integration
NOTION_API_KEY="ntn_xxxxxxxxxxxx"Figma
Post comments to Figma files:
- Visit Figma Settings
- Generate Personal Access Token
- Set appropriate scopes (file_read, file_comments:write)
FIGMA_ACCESS_TOKEN="figd-xxxxxxxxxxxx"Advanced Configuration
Application URL
NEXT_PUBLIC_APP_URL="http://localhost:3000" # Development
NEXT_PUBLIC_APP_URL="https://your-app.vercel.app" # ProductionNode Environment
NODE_ENV="development" # or "production"Scheduler Configuration
# Execute tasks every N seconds (default: 60)
SCHEDULER_INTERVAL_SECONDS="60"
# Maximum concurrent task executions
MAX_CONCURRENT_EXECUTIONS="5"User Configuration (In-App)
Setting Up Your API Key
After installation, configure your OpenRouter API key through the UI:
- Navigate to Settings → API Key
- Paste your OpenRouter API key
- Click "Save & Validate"
- Test the connection
The key is encrypted with AES-256-GCM and stored securely in the database.
Notification Preferences
Configure notification channels in Settings → Notifications:
Email Notifications
- Toggle: Enable/Disable
- Email address: Verified email
- Triggers: Task completion, errors, daily summary
WhatsApp Notifications
- Toggle: Enable/Disable
- Phone number: International format (+1234567890)
- Triggers: Task completion, critical errors
Webhooks
- URL: Your webhook endpoint
- Secret: For signature verification (HMAC-SHA256)
- Headers: Custom headers (JSON)
Example webhook payload:
{
"event": "task.completed",
"task": {
"id": 123,
"name": "Daily Report",
"status": "completed"
},
"execution": {
"id": 456,
"output": "AI response here",
"tokens": 1250,
"duration_ms": 2340
},
"timestamp": "2025-10-17T10:30:00Z"
}Notion Integration
- Database ID: From your Notion database URL
- Properties mapping: Match fields to database properties
Figma Integration
- File URL: Figma file where comments will be posted
- Node ID: Specific frame/component (optional)
Security Best Practices
API Key Management
Security Checklist
- ✅ Use different keys for development and production
- ✅ Rotate keys every 90 days
- ✅ Never commit keys to version control
- ✅ Use environment variables, not hardcoded values
- ✅ Limit API key permissions to minimum required
- ✅ Monitor API usage for anomalies
Encryption
All sensitive data is encrypted at rest using AES-256-GCM:
- User API keys
- OAuth tokens
- Webhook secrets
- Integration credentials
Access Control
Configure user access in the Admin Panel:
- User activation/deactivation
- Coupon-based access gating
- Role-based permissions
Environment-Specific Configuration
Development (.env.local)
DATABASE_URL="postgresql://postgres:postgres@localhost:5433/claude_scheduler"
ENCRYPTION_KEY="dev-only-key-do-not-use-in-production"
OPENROUTER_API_KEY="sk-or-v1-dev-key"
NODE_ENV="development"
NEXT_PUBLIC_APP_URL="http://localhost:3000"Production (.env.production)
DATABASE_URL="postgresql://user:pass@production-db.neon.tech/dbname?sslmode=require"
ENCRYPTION_KEY="secure-production-key-64-chars-hex"
OPENROUTER_API_KEY="sk-or-v1-production-key"
NODE_ENV="production"
NEXT_PUBLIC_APP_URL="https://your-app.vercel.app"Always use different API keys and encryption keys for development and production environments.
Configuration Files
next.config.ts
Key configurations:
const config = {
reactStrictMode: true,
env: {
NEXT_PUBLIC_APP_NAME: 'Tarefa AI',
},
images: {
domains: ['avatars.githubusercontent.com'],
},
};drizzle.config.ts
Database connection configuration:
export default {
schema: './db/schema.ts',
out: './drizzle',
driver: 'pg',
dbCredentials: {
connectionString: process.env.DATABASE_URL!,
},
};Validation
Test Configuration
Verify all configurations are working:
# Test database connection
npm run db:studio
# Test OpenRouter API
curl -X POST https://openrouter.ai/api/v1/models \
-H "Authorization: Bearer $OPENROUTER_API_KEY"
# Test email (Resend)
curl -X POST https://api.resend.com/emails \
-H "Authorization: Bearer $RESEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{"from": "test@yourdomain.com", "to": "you@example.com", "subject": "Test", "html": "<p>Test email</p>"}'
# Test application health
curl http://localhost:3000/api/healthTroubleshooting
Configuration Issues
Invalid API Key
Error: Unauthorized (401)
Solution: Verify API key is correct and has proper permissions.
Database Connection Failed
Error: Connection terminated unexpectedly
Solution: Check DATABASE_URL format, credentials, and SSL mode.
Encryption Key Invalid
Error: Invalid key length
Solution: Encryption key must be exactly 64 hexadecimal characters.
Environment Variables Not Loading
- Check file name:
.env.local(note the dot prefix) - Restart development server after changes
- Verify no typos in variable names
- Check for proper quote usage
# Correct
DATABASE_URL="postgresql://..."
# Incorrect (missing quotes)
DATABASE_URL=postgresql://...Next Steps
With your configuration complete, you're ready to: