# Copy to .env and adjust as needed. HOST=127.0.0.1 PORT=7656 # PostgreSQL connection string. Also read by sqlx's compile-time query macros, # so `cargo check` prepares every query against this database. For local dev: # podman compose up -d postgres DATABASE_URL=postgres://hezarfen:hezarfen@127.0.0.1:5432/hezarfen_control # The maintenance database tests clone scratch databases from (see # tests/common). Uncomment to override the default. # HEZARFEN_TEST_DATABASE_URL=postgres://hezarfen:hezarfen@127.0.0.1:5432/postgres # Directory for uploaded note-file blobs (created at startup). Each school # writes into a subdirectory of it named by its uuid. FILES_PATH=./data/files # Optional log filter. RUST_LOG=info,hezarfen_backend=debug # Add the `Secure` attribute to the session cookie so browsers only send it # over HTTPS. Enable in production behind TLS; leave unset for plain-HTTP dev. # COOKIE_SECURE=true # Comma-separated CORS allowlist for browser clients on other origins; listed # origins may send credentials (the session cookie). Leave unset to reflect the # request's Origin (dev-friendly) — but without credentials, so a cookie-using # browser frontend must be listed here explicitly. A lone `*` reflects every # origin WITH credentials ("anywhere, for now"): SameSite=Lax still keeps # third-party sites from riding the cookie cross-site, so what this opens is # same-site origins (your own subdomains/ports) — replace it with the real # origins once the frontends are known. # CORS_ALLOWED_ORIGINS=https://app.example.com,https://admin.example.com # CORS_ALLOWED_ORIGINS=* # Per-IP rate limits (requests per minute). AUTH covers /auth/login and # /auth/register only (brute-force protection); API covers every route. # Set a limit to 0 to disable that tier (handy for load testing). # RATE_LIMIT_AUTH_PER_MINUTE=1000 # RATE_LIMIT_API_PER_MINUTE=30000 # Chatbot messages per minute, per USER (not per IP) — the tier that rations # the AI service, so a shared-IP classroom can't spend one student's budget on # another's. 0 disables it, like the tiers above. # RATE_LIMIT_CHATBOT_PER_MINUTE=2000 # RAG messages per minute, per USER — the same shape as the chatbot tier, and # with a lower default for the same reason it exists: every message spends a # retrieval over the course-note corpus before it generates anything. 0 # disables it. # RATE_LIMIT_RAG_PER_MINUTE=600 # Key rate limits by the rightmost X-Forwarded-For entry instead of the TCP # peer address. Enable ONLY behind a reverse proxy that appends the client IP # to that header — otherwise the header is client-forged and limits are # trivially bypassed. When off (default), the peer address is used. # TRUST_PROXY=true # Seed a BUILDER account at startup: the deployment operator who creates, # suspends and drops schools. Not a user of any school and holds no role in # one; its cookie is `builder.` where a school user's is # `.`. Both must be set together. An existing account with this # username is left exactly as it is — the seed never rewrites a credential, so # changing the password here does not re-key a live builder. # BUILDER_USERNAME=builder # BUILDER_PASSWORD=builder123 # --- AI bridge (QUIC) ------------------------------------------------------- # The AI features run as separate services that dial IN to this backend over # QUIC and register the capabilities they serve. Leaving AI_QUIC_ADDR unset # turns the bridge off entirely; the API runs exactly as before. # AI_QUIC_ADDR=0.0.0.0:8090 # Shared secret every AI service must present in its Hello frame. REQUIRED # whenever AI_QUIC_ADDR is set — the backend refuses to boot rather than # listen unauthenticated. # AI_SHARED_TOKEN=change-me # TLS for the bridge listener. Both unset (the default) generates a # self-signed certificate at boot and logs its sha256 fingerprint, which the # services pin. Set both for a real certificate. # AI_TLS_CERT=/etc/hezarfen/ai-cert.pem # AI_TLS_KEY=/etc/hezarfen/ai-key.pem # Default deadline for one AI request, in seconds. Model inference is slow, so # this is much larger than the HTTP request timeout. 0 or garbage falls back # to 30. # AI_REQUEST_TIMEOUT_SECS=30 # --- Telemetry (OpenTelemetry) ---------------------------------------------- # Where to send traces, metrics and logs. Unset (the default) turns export off # entirely; the process logs to stdout exactly as before. # Nothing user-identifying ever leaves here: no user id, no client IP, no URL # path, no bodies, no headers or cookies. Spans carry the method, the route # TEMPLATE, the status, a random request id and the school uuid. # OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4317 # Wire transport: grpc (default, port 4317) or http/protobuf (port 4318). # OTEL_EXPORTER_OTLP_PROTOCOL=grpc # Extra headers for the collector, as key=value pairs. Unset is fine when # exporting to the compose OpenObserve: the process mints Authorization=Basic # from ZO_ROOT_USER_EMAIL / ZO_ROOT_USER_PASSWORD. # OTEL_EXPORTER_OTLP_HEADERS=authorization=Bearer%20token # Service name on every exported signal. Defaults to hezarfen_backend. # OTEL_SERVICE_NAME=hezarfen_backend # Sampling, read by the SDK. Default: parentbased_always_on (100%). Use # parentbased_traceidratio with an ARG between 0 and 1 to sample a fraction. # OTEL_TRACES_SAMPLER=parentbased_traceidratio # OTEL_TRACES_SAMPLER_ARG=0.1 # Names the deployment on every signal (deployment.environment.name). # DEPLOY_ENV=production # stdout log rendering: pretty (default, human lines) or json (one object per # event, with the span fields). Anything else refuses to boot. # LOG_FORMAT=json