Server Configuration
The mzchat backend uses a flat configuration system that can be populated via a YAML file or environment variables.
Configuration Sources
Section titled “Configuration Sources”The configuration is loaded from the following sources, in order of precedence:
- Environment Variables: Direct mapping to configuration keys (e.g.,
PORT,DATABASE_URL). - Configuration File: Reads from
mzchat-backend.ymlin the current working directory by default (can be overridden by theCONFIG_FILEenvironment variable). - Defaults: Hardcoded sane defaults in the source code.
Configuration Keys
Section titled “Configuration Keys”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 tocanonicalAddress).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: 50051databaseUrl: file:dev.dbcanonicalAddress: http://localhost:5173migrationsPath: drizzlebasePath: ""Environment Variables
Section titled “Environment Variables”Environment variables match the configuration keys exactly.
export PORT=50059export DATABASE_URL=file:prod.dbexport CANONICAL_ADDRESS=https://chat.example.com./backend serve