Naalya Handbook
Secrets and credentials

Where they live

Local .env.local, and Railway variables named in .railway/ with preserve() so values stay out of git.

A config secret has two homes in the tree this pass read. Commands below are copied from infra/README.md. They were not run.

  • Local dev. A .env.local file in the repo root, which you create and which git ignores.
  • Staging and production. Railway holds the values. .railway/variables.ts and .railway/environments.ts name the variables. preserve() keeps a secret's current Railway value, so the value is not in git.

infra/staging/ and infra/prod/ contain railway.yaml and a Centrifugo JSON file. They do not contain secrets.staging.yaml or secrets.prod.yaml. scripts/sync-railway-env.sh is not in the repository at a5dff0c208d5193c274d3d1f87787b55344d5d30. Do not follow an older page that tells you to edit those YAML files or run that script.

Re-read at API fbb63d5178bcfe171292daebb19b6cbdac025a44 on 14 November 2026. infra/staging/ lists centrifugo.staging.json and railway.yaml. infra/prod/ lists centrifugo.prod.json and railway.yaml. Neither directory has a secrets yaml. The comment in docker-compose.dev.yaml on the Centrifugo service says Railway-dynamic values, the redis address, are layered as env vars from infra/<env>/secrets.<env>.yaml. That path is a name in a comment. It is not a file, and this page does not invent a hosted Redis URL from it. The committed placeholders are local only. .env.example sets REDIS_URL to redis://localhost:6379 and CACHE_REDIS_URL to redis://localhost:6379/1. docker-compose.yaml sets REDIS_URL to redis://redis:6379 for the server, worker, and audit services. Those are the compose network and a laptop. They are not a staging or production address.

.env.local

When the app boots, NestJS's ConfigModule is told to load from .env.local.

apps/server/src/app/app.module.ts
ConfigModule.forRoot({
  isGlobal: true,
  load: [config],
  envFilePath: '.env.local',
}),

That populates process.env before the Zod schema validates it. (apps/server/src/instrument.ts is imported first in main.ts and starts OpenTelemetry before any module loads.) Copy .env.example to .env.local (Task env does this when the file is missing) and replace placeholders with values a teammate hands you. Do not commit .env.local.

.env.example is a template, not a secret store

.env.example is committed and lists key names. It is not a reason to paste real values into git. envSchema remains the boot check. A blank entry is an empty string and overrides a Zod default. Where the example and the schema disagree, trust the schema and fix the example in the same change.

Railway variables

toEnv in .railway/variables.ts builds a service's variable map from one or more groups. A group has settings (the value is written in the file) and secrets (only the name is listed).

.railway/variables.ts
secrets.map((name) => [name, preserve()] as const)

The comment above Vars says a service's variables are exactly what its groups list, and anything missing is deleted on apply. preserve() keeps the value Railway already holds.

APP.secrets names the shared secrets for the API, worker, and audit apps, including DATABASE_URL, JWT_SECRET_KEY, REDIS_URL, and RABBIT_MQ_URL. At API main 6bfb9f6bdb004fd3a909405c2c826cf1e383249b, the same tree as staging 0d611c96, that array names OPENAI_API_KEY and does not name OPENROUTER_API_KEY. Compare d229592a...6bfb9f6b does not touch the array. .env.example has no blank line for it either. The live value was not read. Deployment was not verified. GitHub Actions run 45252018549 finished apply-production: Plan and Apply both succeeded, and apply-staging was skipped. The logs were not opened, so this page does not say a worker restarted. This page does not copy the full list or any setting value. Open the file. Some non-secret settings are committed there too, such as JWT_ACCESS_TOKEN_EXPIRATION_MS. That is configuration, not a licence to commit a credential. See Authentication.

infra/README.md is the procedure:

  1. Set the secret in Railway first, in the dashboard or with railway variable set NAME --stdin -s <service> -e <environment>.
  2. Add the name to the right secrets array.
  3. Apply through .github/workflows/railway-config.yml.

A pull request into staging that touches .railway/** gets a plan comment. Merging applies that pinned plan to Staging. A push to main that touches .railway/** plans and applies to production through the prod GitHub Environment. This audit did not watch either apply.

infra/staging/railway.yaml and infra/prod/railway.yaml are still in the tree. They are target IDs for scripts/redeploy-railway-services.sh, not a secrets file. The Taskfile task is redeploy-railway. It was not run. See Getting Started.

Service links use Railway reference strings in settings, for example the Centrifugo URL built from RAILWAY_PRIVATE_DOMAIN. The secret value itself stays in Railway.

Where to go next

Sources

  • Naalya-API infra/README.md, infra/staging/ and infra/prod/ directory listings, .railway/variables.ts toEnv, preserve, APP
  • Absence of scripts/sync-railway-env.sh and of secrets.*.yaml at a5dff0c208d5193c274d3d1f87787b55344d5d30
  • Re-read at fbb63d5178bcfe171292daebb19b6cbdac025a44: infra/staging/ and infra/prod/ listings, docker-compose.dev.yaml Centrifugo comment, docker-compose.yaml REDIS_URL, .env.example REDIS_URL and CACHE_REDIS_URL
  • OPENROUTER_API_KEY is absent from APP.secrets and from .env.example at main 6bfb9f6bdb004fd3a909405c2c826cf1e383249b, the same tree as staging 0d611c96. Compare d229592a...6bfb9f6b does not touch those files. A search of the tree finds no OPENROUTER_API_KEY. The Railway value was not read. GitHub Actions run 45252018549 finished apply-production for the earlier commit a888ae35, before this key returned. The logs were not opened. Deployment was not verified.

On this page