Documentation Index
Fetch the complete documentation index at: https://docs.exulu.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
ExuluDatabase provides utilities for initializing and managing the Exulu IMP database schema. It handles core table creation, context-specific tables (items and chunks), default user setup, and API key generation.
What is ExuluDatabase?
ExuluDatabase offers essential database management functions:- Schema initialization: Creates all core Exulu IMP tables
- Schema updates: Adds missing fields to existing tables
- Context tables: Creates items and chunks tables for ExuluContext instances
- Default setup: Creates admin user, roles, and default API key
- API key generation: Generates secure API keys for programmatic access
Initialize schema
Create all core database tables
Context tables
Setup items/chunks tables for contexts
Generate API keys
Create secure API keys for users
Quick start
Methods
init()
Initializes the Exulu IMP database schema and creates context-specific tables.Array of ExuluContext instances for which to create items/chunks tables
-
Creates core tables:
users- User accounts (NextAuth compatible)roles- Role-based access controlagents- Agent configurationsagent_sessions- Conversation sessionsagent_messages- Chat messagestest_cases- Evaluation test caseseval_sets- Evaluation setseval_runs- Evaluation run resultsstatistics- Usage statisticsvariables- Encrypted variable storageworkflow_templates- Workflow definitionsprojects- Project organizationjob_results- Background job resultsprompt_library- Saved promptsembedder_settings- Embedder configurationsprompt_favorites- Favorited promptsplatform_configurations- Platform settingsrbac- Role-based access controlaccounts- NextAuth account linkingverification_token- NextAuth token verification
-
Creates default roles:
admin- Full write access to all resourcesdefault- Read access with write access to agents
-
Creates default admin user:
- Email:
admin@exulu.com - Password:
admin - Super admin privileges
- Email:
-
Generates default API key:
- Name:
exulu - Email:
api@exulu.com - Admin role
- Name:
-
Creates context tables:
- Items table for each context (for document storage)
- Chunks table for each context with embedder (for vector search)
- First time setting up Exulu IMP
- Adding new ExuluContext instances that need database tables
- Resetting database to default state
Running
init() multiple times is safe - it only creates tables and fields that don’t exist. Existing data is preserved.update()
Alias forinit(). Updates the database schema by adding missing tables and fields.
Array of ExuluContext instances to update
- Adding new ExuluContext instances to an existing installation
- Migrating to new Exulu IMP versions with schema changes
- Ensuring database schema is up to date
api.key.generate()
Generates a secure API key for a user.Human-readable name for the API key (used as identifier)
Email address for the API user
Generated API key in format:
sk_{random_string}/{sanitized_name}Warning: This is the only time the plain-text key is available. Store it securely.- Generates random key:
sk_{random}_{random} - Hashes the key using bcrypt (12 salt rounds)
- Sanitizes the name (lowercase, underscores)
- Stores hashed key with postfix:
{bcrypt_hash}/{sanitized_name} - Creates API user with admin role
- Returns plain-text key (only time it’s accessible)
- Prefix:
sk_(secret key) - Random strings: Two random alphanumeric segments
- Postfix:
/{sanitized_name}(lowercase, underscores)
sk_9x7h3j2k5l8_4m6n1p9q8r/production_api
Security:
Usage patterns
First-time setup
Adding new context
Generating API keys for team members
Integration with ExuluApp
CI/CD database setup
Database schema
Core tables structure
All core tables include:id(UUID) - Primary keycreatedAt(timestamp) - Creation timestampupdatedAt(timestamp) - Last update timestamp
Users table
Roles table
Context tables
Items table (created for each ExuluContext):Default credentials
After runningExuluDatabase.init(), the following default credentials are created:
Default admin user
Default admin user
Email:
admin@exulu.com
Password: admin
Role: admin (full write access)
Super admin: YesDefault API key
Default API key
Name:
exulu
Email: api@exulu.com
Role: admin (full write access)
Format: sk_{random}_{random}/exuluThe key is printed to console during initialization:Default roles
Default roles
Admin role:
- agents: write
- evals: write
- workflows: write
- variables: write
- users: write
- api: write
- agents: write
- evals: read
- workflows: read
- variables: read
- users: read
- api: read
Environment variables
ExuluDatabase uses these environment variables:PostgreSQL connection stringFormat:
postgresql://user:password@host:port/databaseExample: postgresql://exulu:password@localhost:5432/exulu_dbSecret key for NextAuth session encryptionUsed for: Password hashing, session tokens, encrypted variablesGenerate:
openssl rand -base64 32Error handling
ECONNREFUSED- Database connection failed42P07- Table already exists3D000- Database does not exist28P01- Authentication failed
Migration from previous versions
If upgrading from an older version of Exulu IMP:update() does:
- Checks for missing tables and creates them
- Checks for missing fields in existing tables
- Adds missing fields without affecting existing data
- Creates new context tables if needed
Database migrations are non-destructive. Existing data is preserved.
Best practices
Context management: Always pass all ExuluContext instances to
init() or update() to ensure all tables exist.Default credentials: Change default admin password and API key in production environments.
Integration with other Exulu components
With ExuluContext
With ExuluAuthentication
With ExuluVariables
Troubleshooting
Database connection fails
Database connection fails
Error:
ECONNREFUSED or ETIMEDOUTSolutions:- Verify PostgreSQL is running:
pg_isready - Check
DATABASE_URLenvironment variable - Verify network connectivity to database host
- Check firewall rules allow PostgreSQL port (default: 5432)
Tables already exist
Tables already exist
Error:
table "users" already existsSolutions:- Use
update()instead ofinit()for existing databases init()is safe to run multiple times (checks existence first)- If seeing this error, there may be a race condition (multiple processes initializing simultaneously)
Missing pgvector extension
Missing pgvector extension
Error:
type "vector" does not existSolutions:- Install pgvector extension in PostgreSQL
- Enable extension in your database:
- Verify installation:
SELECT * FROM pg_extension WHERE extname = 'vector';
Permission denied
Permission denied
Error:
permission denied for schema publicSolutions:- Grant necessary permissions:
- Use a database user with CREATE TABLE privileges
Next steps
ExuluContext
Create knowledge bases with context-specific tables
ExuluAuthentication
Use generated API keys for authentication
ExuluVariables
Store encrypted configuration variables
ExuluApp
Build applications with initialized database