Skip to content

Server Configuration

The mzchat backend uses a flat configuration system that can be populated via a YAML file or environment variables.

The configuration is loaded from the following sources, in order of precedence:

  1. Environment Variables: Direct mapping to configuration keys (e.g., PORT, DATABASE_URL).
  2. Configuration File: Reads from mzchat-backend.yml in the current working directory by default (can be overridden by the CONFIG_FILE environment variable).
  3. Defaults: Hardcoded sane defaults in the source code.
  • port: The port the gRPC/Web server binds to (default: 50051).
  • databaseUrl: Connection string for the database (default: file:dev.db).
  • canonicalAddress: The public-facing URL of the server (e.g., http://localhost:5173).
  • assetsDomain: Domain for serving user-uploaded media (defaults to canonicalAddress).
  • migrationsPath: Path to the Drizzle migrations folder (default: drizzle).
  • basePath: Optional URL prefix for all routes.
  • staticPath: Optional path to serve static assets from.
  • meiliUrl: The URL of the Meilisearch instance for message indexing.
  • meiliApiKey: The API key (Master Key) for Meilisearch.
  • meiliIndexName: The name of the index to use (default: mzchat-messages).

Example Configuration (mzchat-backend.yml)

Section titled “Example Configuration (mzchat-backend.yml)”
port: 50051
databaseUrl: file:dev.db
canonicalAddress: http://localhost:5173
migrationsPath: drizzle
basePath: ""

Environment variables match the configuration keys exactly.

Terminal window
export PORT=50059
export DATABASE_URL=file:prod.db
export CANONICAL_ADDRESS=https://chat.example.com
./backend serve