Skip to content

Environment Variables

Environment Variables

Manacore uses a centralized environment variable system. All development variables are managed from a single file.

Quick Start

Terminal window
# After cloning, install dependencies (auto-generates .env files)
pnpm install
# Or manually generate .env files
pnpm setup:env

That’s it! All app-specific .env files are generated from .env.development.

How It Works

.env.development # Central config (committed)
scripts/generate-env.mjs # Transforms variables
apps/**/apps/**/.env # Generated files (gitignored)

The generator reads .env.development and creates app-specific .env files with the correct prefixes for each platform:

PlatformPrefixExample
Expo (mobile)EXPO_PUBLIC_EXPO_PUBLIC_SUPABASE_URL
SvelteKit (web)PUBLIC_PUBLIC_SUPABASE_URL
NestJS (backend)NoneSUPABASE_URL

File Locations

Source File

  • .env.development - Single source of truth, committed to git

Generated Files (gitignored)

  • services/mana-core-auth/.env
  • apps/chat/apps/backend/.env
  • apps/chat/apps/mobile/.env
  • apps/chat/apps/web/.env
  • And more…

Variable Reference

Shared Variables

VariableDescriptionUsed By
MANA_CORE_AUTH_URLAuth service URLAll apps
JWT_PRIVATE_KEYJWT signing keymana-core-auth
JWT_PUBLIC_KEYJWT verification keyAll backends
POSTGRES_USERDatabase userDocker, backends
POSTGRES_PASSWORDDatabase passwordDocker, backends
REDIS_HOSTRedis hostmana-core-auth
REDIS_PORTRedis portmana-core-auth

Mana Core Auth Service

VariableDescriptionDefault
MANA_CORE_AUTH_PORTService port3001
MANA_CORE_AUTH_DATABASE_URLPostgreSQL connection-
JWT_ACCESS_TOKEN_EXPIRYAccess token TTL15m
JWT_REFRESH_TOKEN_EXPIRYRefresh token TTL7d
JWT_ISSUERJWT issuer claimmanacore
JWT_AUDIENCEJWT audience claimmanacore
STRIPE_SECRET_KEYStripe secret key-
CREDITS_SIGNUP_BONUSCredits on signup150
CREDITS_DAILY_FREEDaily free credits5

Project-Specific Variables

VariableDescription
CHAT_BACKEND_PORTBackend port (3002)
CHAT_DATABASE_URLPostgreSQL connection
AZURE_OPENAI_ENDPOINTAzure OpenAI endpoint
AZURE_OPENAI_API_KEYAzure OpenAI key

Adding New Variables

  1. Add to .env.development

    Terminal window
    MY_NEW_PROJECT_API_KEY=your-api-key
    MY_NEW_PROJECT_URL=https://api.example.com
  2. Update the Generator Script

    Edit scripts/generate-env.mjs:

    {
    path: 'apps/my-project/apps/backend/.env',
    vars: {
    API_KEY: (env) => env.MY_NEW_PROJECT_API_KEY,
    API_URL: (env) => env.MY_NEW_PROJECT_URL,
    },
    },
  3. Regenerate

    Terminal window
    pnpm setup:env

Local Overrides

If you need to override variables locally:

  1. The generated .env files are gitignored
  2. You can manually edit them after generation
  3. Or create .env.local files (also gitignored) that some frameworks auto-load

Docker Integration

The root .env.development is also used by Docker Compose:

Terminal window
# Start all services with shared env
pnpm docker:up

Troubleshooting

”Variable is undefined” Error

  1. Check if the variable exists in .env.development
  2. Run pnpm setup:env to regenerate
  3. Restart your dev server (env changes require restart)

Expo Not Picking Up Changes

Expo caches environment variables. Clear the cache:

Terminal window
cd apps/<project>/apps/mobile
npx expo start -c

Security Notes