5.6 KiB
Operations And Configuration
Runtime Services
docker-compose.yml defines the runtime stack:
db(Postgres 16, localhost-bound port5432)redis(Redis 7, localhost-bound port6379)typesense(Typesense 29, localhost-bound port8108)api(FastAPI backend, localhost-bound port8000)worker(RQ background worker)frontend(Vite UI, localhost-bound port5173)
Named Volumes
Persistent volumes:
db-dataredis-datadcm-storagetypesense-data
Reset all persisted runtime data:
docker compose down -v
Operational Commands
Start or rebuild stack:
docker compose up --build -d
Stop stack:
docker compose down
Tail logs:
docker compose logs -f
Before running compose, provide explicit API tokens in your shell or project .env file:
export ADMIN_API_TOKEN="<random-admin-token>"
export USER_API_TOKEN="<random-user-token>"
Compose now fails fast if either token variable is missing.
Backend Configuration
Settings source:
- Runtime settings class:
backend/app/core/config.py - API settings persistence:
backend/app/services/app_settings.py
Key environment variables used by api and worker in compose:
APP_ENVDATABASE_URLREDIS_URLSTORAGE_ROOTADMIN_API_TOKENUSER_API_TOKENPUBLIC_BASE_URLCORS_ORIGINS(API service)PROVIDER_BASE_URL_ALLOWLISTPROVIDER_BASE_URL_ALLOW_HTTPPROVIDER_BASE_URL_ALLOW_PRIVATE_NETWORKTYPESENSE_PROTOCOLTYPESENSE_HOSTTYPESENSE_PORTTYPESENSE_API_KEYTYPESENSE_COLLECTION_NAME
Selected defaults from Settings (backend/app/core/config.py):
upload_chunk_size = 4194304max_upload_files_per_request = 50max_upload_file_size_bytes = 26214400max_upload_request_size_bytes = 104857600max_zip_members = 250max_zip_depth = 2max_zip_member_uncompressed_bytes = 26214400max_zip_total_uncompressed_bytes = 157286400max_zip_compression_ratio = 120.0max_text_length = 500000processing_log_max_document_sessions = 20processing_log_max_unbound_entries = 400default_openai_model = "gpt-4.1-mini"default_openai_timeout_seconds = 45default_summary_model = "gpt-4.1-mini"default_routing_model = "gpt-4.1-mini"typesense_timeout_seconds = 120typesense_num_retries = 0
Frontend Configuration
Frontend runtime API target:
VITE_API_BASEindocker-compose.ymlfrontend serviceVITE_API_TOKENindocker-compose.ymlfrontend service (defaults toUSER_API_TOKENin compose, override toADMIN_API_TOKENwhen admin-only routes are needed)
Frontend API authentication behavior:
frontend/src/lib/api.tsaddsAuthorization: Bearer <VITE_API_TOKEN>for all API requests only whenVITE_API_TOKENis non-empty- requests are still sent without authorization when
VITE_API_TOKENis unset, which keeps unauthenticated endpoints such as/api/v1/healthbackward-compatible
Frontend container runtime behavior:
- the container runs as non-root
node /appis owned bynodeinfrontend/Dockerfileso Vite can create runtime temp config files under/app
Frontend local commands:
cd frontend && npm run dev
cd frontend && npm run build
cd frontend && npm run preview
Settings Persistence
Application-level settings managed from the UI are persisted by backend settings service:
- file path:
<STORAGE_ROOT>/settings.json - endpoints:
/api/v1/settings,/api/v1/settings/reset,/api/v1/settings/handwriting
Settings include:
- upload defaults
- display options
- processing-log retention options (
keep_document_sessions,keep_unbound_entries) - provider configuration
- OCR, summary, and routing task settings
- predefined paths and tags
- handwriting-style clustering settings
Read sanitization is resilient to corrupt persisted provider rows. If a persisted provider entry fails URL validation, the entry is skipped and defaults are used when no valid provider remains. This prevents unrelated read endpoints from failing due to stale invalid provider data.
Retention settings are used by worker cleanup and by POST /api/v1/processing/logs/trim when trim query values are not provided.
Security Controls
- Privileged APIs are token-gated with bearer auth:
documentsendpoints: user token or admin tokensettingsandprocessing/logsendpoints: admin token only
- Authentication fails closed when
ADMIN_API_TOKENis not configured. - Provider base URLs are validated on settings updates and before outbound model calls:
- allowlist enforcement (
PROVIDER_BASE_URL_ALLOWLIST) - scheme restrictions (
httpsby default) - local/private-network blocking and per-request DNS revalidation checks for outbound runtime calls
- allowlist enforcement (
- Upload and archive safety guards are enforced:
- multipart upload requires
Content-Lengthand enforces file-count, per-file size, and total request size limits - ZIP member count, per-member uncompressed size, total decompressed size, and compression-ratio guards
- multipart upload requires
- Processing logs redact sensitive payload and text fields, and trim endpoints enforce retention caps from runtime config.
- Compose hardening defaults:
- host ports bind to
127.0.0.1unlessHOST_BIND_IPoverride is set api,worker, andfrontenddrop all Linux capabilities and setno-new-privileges- backend and frontend containers run as non-root users by default
- host ports bind to
Validation Checklist
After operational or configuration changes, verify:
GET /api/v1/healthis healthy- frontend can list, upload, and search documents
- processing worker logs show successful task execution
- settings save or reset works and persists after restart