Getting Started
Local development setup, environment variables, database initialization, and Railway deployment.
Deploy as a Railway Template (Recommended)
Persona Lab is designed to be deployed as a Railway template using a bring-your-own-key (BYOK) model:
- Deploy the Persona Lab template on Railway — Railway automatically provisions the PostgreSQL plugin and injects
DATABASE_URL. - In the app service's Variables, set
AI_PROVIDER(gemini,openai, oranthropic) and paste your own API key (GEMINI_API_KEY,OPENAI_API_KEY, orANTHROPIC_API_KEY). - Optionally set
AUTH_USERNAME,AUTH_PASSWORD, andAUTH_SECRETto gate the public Railway URL behind a login screen. - On startup,
railway.tomlautomatically runsnpm run db:initto initialize the schema and seed the 12 starter personas before starting Next.js.
Local Development
- Copy
.env.exampleto.envin thepersona-labdirectory and configure your database and AI provider credentials:
cp .env.example .env
npm install
npm run dev- Open http://localhost:3000.
Environment Variables
| Variable | Source / Default | Purpose |
|---|---|---|
DATABASE_URL | PostgreSQL connection string | Required for all persona, session, and chat storage |
AI_PROVIDER | gemini (default), openai, or anthropic | Selects the AI provider for generation, chat, and synthesis |
GEMINI_API_KEY | Google AI Studio | Required when AI_PROVIDER=gemini (or legacy VERTEX_API_KEY) |
OPENAI_API_KEY | OpenAI Platform | Required when AI_PROVIDER=openai |
ANTHROPIC_API_KEY | Anthropic Console | Required when AI_PROVIDER=anthropic |
AI_MODEL | Optional | Overrides the default model for the selected provider |
GEMINI_MODEL / OPENAI_MODEL / ANTHROPIC_MODEL | Optional fallbacks | Provider-specific models used when AI_MODEL is unset |
AUTH_USERNAME | Optional | Login username (required with password and secret to enable auth) |
AUTH_PASSWORD | Optional | Login password |
AUTH_SECRET | Optional | Secret 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.sqlDeploy to Railway
- Push the repository to GitHub.
- Create a new Railway project and connect the repository.
- Add a PostgreSQL plugin so Railway injects
DATABASE_URL. - Set
AI_PROVIDERand its matching API key (plus optionalAUTH_*variables) in Variables. - Deploy — Railway builds the app and runs
npm run db:initbefore starting Next.js.