hezarfen_backend
Clone
https://git.tahinli.com/archive/hezarfen_backend.git
0 watching0 forksRust8.3 MiB6d68754Ahmet Kaan Gümüş2 months ago566 commits
| 1 | # Copy to .env and adjust as needed. |
| 2 | HOST=127.0.0.1 |
| 3 | PORT=7656 |
| 4 | |
| 5 | # PostgreSQL connection string. Also read by sqlx's compile-time query macros, |
| 6 | # so `cargo check` prepares every query against this database. For local dev: |
| 7 | # podman compose up -d postgres |
| 8 | DATABASE_URL=postgres://hezarfen:hezarfen@127.0.0.1:5432/hezarfen_control |
| 9 | |
| 10 | # The maintenance database tests clone scratch databases from (see |
| 11 | # tests/common). Uncomment to override the default. |
| 12 | # HEZARFEN_TEST_DATABASE_URL=postgres://hezarfen:hezarfen@127.0.0.1:5432/postgres |
| 13 | |
| 14 | # Directory for uploaded note-file blobs (created at startup). Each school |
| 15 | # writes into a subdirectory of it named by its uuid. |
| 16 | FILES_PATH=./data/files |
| 17 | |
| 18 | # Optional log filter. |
| 19 | RUST_LOG=info,hezarfen_backend=debug |
| 20 | |
| 21 | # Add the `Secure` attribute to the session cookie so browsers only send it |
| 22 | # over HTTPS. Enable in production behind TLS; leave unset for plain-HTTP dev. |
| 23 | # COOKIE_SECURE=true |
| 24 | |
| 25 | # Comma-separated CORS allowlist for browser clients on other origins; listed |
| 26 | # origins may send credentials (the session cookie). Leave unset to reflect the |
| 27 | # request's Origin (dev-friendly) — but without credentials, so a cookie-using |
| 28 | # browser frontend must be listed here explicitly. A lone `*` reflects every |
| 29 | # origin WITH credentials ("anywhere, for now"): SameSite=Lax still keeps |
| 30 | # third-party sites from riding the cookie cross-site, so what this opens is |
| 31 | # same-site origins (your own subdomains/ports) — replace it with the real |
| 32 | # origins once the frontends are known. |
| 33 | # CORS_ALLOWED_ORIGINS=https://app.example.com,https://admin.example.com |
| 34 | # CORS_ALLOWED_ORIGINS=* |
| 35 | |
| 36 | # Per-IP rate limits (requests per minute). AUTH covers /auth/login and |
| 37 | # /auth/register only (brute-force protection); API covers every route. |
| 38 | # Set a limit to 0 to disable that tier (handy for load testing). |
| 39 | # RATE_LIMIT_AUTH_PER_MINUTE=1000 |
| 40 | # RATE_LIMIT_API_PER_MINUTE=30000 |
| 41 | |
| 42 | # Chatbot messages per minute, per USER (not per IP) — the tier that rations |
| 43 | # the AI service, so a shared-IP classroom can't spend one student's budget on |
| 44 | # another's. 0 disables it, like the tiers above. |
| 45 | # RATE_LIMIT_CHATBOT_PER_MINUTE=2000 |
| 46 | |
| 47 | # RAG messages per minute, per USER — the same shape as the chatbot tier, and |
| 48 | # with a lower default for the same reason it exists: every message spends a |
| 49 | # retrieval over the course-note corpus before it generates anything. 0 |
| 50 | # disables it. |
| 51 | # RATE_LIMIT_RAG_PER_MINUTE=600 |
| 52 | |
| 53 | # Key rate limits by the rightmost X-Forwarded-For entry instead of the TCP |
| 54 | # peer address. Enable ONLY behind a reverse proxy that appends the client IP |
| 55 | # to that header — otherwise the header is client-forged and limits are |
| 56 | # trivially bypassed. When off (default), the peer address is used. |
| 57 | # TRUST_PROXY=true |
| 58 | |
| 59 | # Seed a BUILDER account at startup: the deployment operator who creates, |
| 60 | # suspends and drops schools. Not a user of any school and holds no role in |
| 61 | # one; its cookie is `builder.<token>` where a school user's is |
| 62 | # `<uuid>.<token>`. Both must be set together. An existing account with this |
| 63 | # username is left exactly as it is — the seed never rewrites a credential, so |
| 64 | # changing the password here does not re-key a live builder. |
| 65 | # BUILDER_USERNAME=builder |
| 66 | # BUILDER_PASSWORD=builder123 |
| 67 | |
| 68 | # --- AI bridge (QUIC) ------------------------------------------------------- |
| 69 | # The AI features run as separate services that dial IN to this backend over |
| 70 | # QUIC and register the capabilities they serve. Leaving AI_QUIC_ADDR unset |
| 71 | # turns the bridge off entirely; the API runs exactly as before. |
| 72 | # AI_QUIC_ADDR=0.0.0.0:8090 |
| 73 | |
| 74 | # Shared secret every AI service must present in its Hello frame. REQUIRED |
| 75 | # whenever AI_QUIC_ADDR is set — the backend refuses to boot rather than |
| 76 | # listen unauthenticated. |
| 77 | # AI_SHARED_TOKEN=change-me |
| 78 | |
| 79 | # TLS for the bridge listener. Both unset (the default) generates a |
| 80 | # self-signed certificate at boot and logs its sha256 fingerprint, which the |
| 81 | # services pin. Set both for a real certificate. |
| 82 | # AI_TLS_CERT=/etc/hezarfen/ai-cert.pem |
| 83 | # AI_TLS_KEY=/etc/hezarfen/ai-key.pem |
| 84 | |
| 85 | # Default deadline for one AI request, in seconds. Model inference is slow, so |
| 86 | # this is much larger than the HTTP request timeout. 0 or garbage falls back |
| 87 | # to 30. |
| 88 | # AI_REQUEST_TIMEOUT_SECS=30 |
| 89 | |
| 90 | # --- Telemetry (OpenTelemetry) ---------------------------------------------- |
| 91 | # Where to send traces, metrics and logs. Unset (the default) turns export off |
| 92 | # entirely; the process logs to stdout exactly as before. |
| 93 | # Nothing user-identifying ever leaves here: no user id, no client IP, no URL |
| 94 | # path, no bodies, no headers or cookies. Spans carry the method, the route |
| 95 | # TEMPLATE, the status, a random request id and the school uuid. |
| 96 | # OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4317 |
| 97 | |
| 98 | # Wire transport: grpc (default, port 4317) or http/protobuf (port 4318). |
| 99 | # OTEL_EXPORTER_OTLP_PROTOCOL=grpc |
| 100 | |
| 101 | # Extra headers for the collector, as key=value pairs. Unset is fine when |
| 102 | # exporting to the compose OpenObserve: the process mints Authorization=Basic |
| 103 | # from ZO_ROOT_USER_EMAIL / ZO_ROOT_USER_PASSWORD. |
| 104 | # OTEL_EXPORTER_OTLP_HEADERS=authorization=Bearer%20token |
| 105 | |
| 106 | # Service name on every exported signal. Defaults to hezarfen_backend. |
| 107 | # OTEL_SERVICE_NAME=hezarfen_backend |
| 108 | |
| 109 | # Sampling, read by the SDK. Default: parentbased_always_on (100%). Use |
| 110 | # parentbased_traceidratio with an ARG between 0 and 1 to sample a fraction. |
| 111 | # OTEL_TRACES_SAMPLER=parentbased_traceidratio |
| 112 | # OTEL_TRACES_SAMPLER_ARG=0.1 |
| 113 | |
| 114 | # Names the deployment on every signal (deployment.environment.name). |
| 115 | # DEPLOY_ENV=production |
| 116 | |
| 117 | # stdout log rendering: pretty (default, human lines) or json (one object per |
| 118 | # event, with the span fields). Anything else refuses to boot. |
| 119 | # LOG_FORMAT=json |