Skip to Content
Persona Lab

Getting Started

Local development setup, environment variables, database initialization, and Railway deployment.

Persona Lab is designed to be deployed as a Railway template using a bring-your-own-key (BYOK) model:

  1. Deploy the Persona Lab template on Railway — Railway automatically provisions the PostgreSQL plugin and injects DATABASE_URL.
  2. In the app service's Variables, set AI_PROVIDER (gemini, openai, or anthropic) and paste your own API key (GEMINI_API_KEY, OPENAI_API_KEY, or ANTHROPIC_API_KEY).
  3. Optionally set AUTH_USERNAME, AUTH_PASSWORD, and AUTH_SECRET to gate the public Railway URL behind a login screen.
  4. On startup, railway.toml automatically runs npm run db:init to initialize the schema and seed the 12 starter personas before starting Next.js.

Local Development

  1. Copy .env.example to .env in the persona-lab directory and configure your database and AI provider credentials:
cp .env.example .env
npm install
npm run dev
  1. Open http://localhost:3000.

Environment Variables

VariableSource / DefaultPurpose
DATABASE_URLPostgreSQL connection stringRequired for all persona, session, and chat storage
AI_PROVIDERgemini (default), openai, or anthropicSelects the AI provider for generation, chat, and synthesis
GEMINI_API_KEYGoogle AI StudioRequired when AI_PROVIDER=gemini (or legacy VERTEX_API_KEY)
OPENAI_API_KEYOpenAI PlatformRequired when AI_PROVIDER=openai
ANTHROPIC_API_KEYAnthropic ConsoleRequired when AI_PROVIDER=anthropic
AI_MODELOptionalOverrides the default model for the selected provider
GEMINI_MODEL / OPENAI_MODEL / ANTHROPIC_MODELOptional fallbacksProvider-specific models used when AI_MODEL is unset
AUTH_USERNAMEOptionalLogin username (required with password and secret to enable auth)
AUTH_PASSWORDOptionalLogin password
AUTH_SECRETOptionalSecret for signing session cookies (e.g. openssl rand -hex 32)

Database Initialization

On every Railway start or redeploy, railway.toml runs npm run db:init before starting Next.js. This reapplies the idempotent schema (db/schema.sql) and upserts the 12 starter personas while preserving user-created personas and attributes.

To initialize manually:

psql "$DATABASE_URL" -f db/schema.sql
psql "$DATABASE_URL" -f db/seed.sql

Deploy to Railway

  1. Push the repository to GitHub.
  2. Create a new Railway project and connect the repository.
  3. Add a PostgreSQL plugin so Railway injects DATABASE_URL.
  4. Set AI_PROVIDER and its matching API key (plus optional AUTH_* variables) in Variables.
  5. Deploy — Railway builds the app and runs npm run db:init before starting Next.js.

On this page