CRTX
DocsSign in →

Configuration

Every backend setting is an environment variable with a sensible default. The backend loads them from backend/app/.env (which overrides the defaults defined in app/config.py). The frontend reads NEXT_PUBLIC_* values from frontend/.env.local.

Change values in both places if you also override them in config.py. The .env file wins at runtime, but the config.py default is the fallback.


#Backend — required

VariableDescription
SUPABASE_URLYour Supabase project URL.
SUPABASE_SECRET_KEYSupabase service role key. The backend uses it server-side to enforce its own access logic (Row Level Security is intentionally bypassed). Keep it secret.
SUPABASE_JWKS_URLJWKS endpoint used to validate access tokens (…/auth/v1/.well-known/jwks.json).
OPENAI_API_KEYOpenAI key for embeddings, generation, vision, and the eval judge.
PINECONE_API_KEYPinecone API key.
PINECONE_INDEXName of the Pinecone index (must be 1024-dim, cosine).

#Backend — networking

VariableDefaultDescription
ALLOWED_ORIGINShttp://localhost:3000Comma-separated allowed CORS origins. Set to your frontend origin(s) in production.
REDIS_URLredis://localhost:6379Redis connection for the Arq worker. Required for ingestion and async eval scoring.

#Backend — retrieval & chunking

VariableDefaultDescription
EMBEDDING_MODELtext-embedding-3-smallEmbedding model. Must match the index dimension.
EMBEDDING_DIMENSIONS1024Embedding dimensionality. Must equal the Pinecone index dimension.
CHUNK_SIZE1800Target characters per text chunk (recursive splitter).
CHUNK_OVERLAP250Character overlap between adjacent chunks.
TABLE_MAX_CHARS3000Max size a structured unit (table/slide/row batch) may reach before it is split into prose. Kept above CHUNK_SIZE so tables/slides stay whole.
TOP_K5Number of chunks retrieved and fed to the model.
NEIGHBOR_WINDOW1Adjacent chunks stitched around each retrieved chunk (per side). 0 disables.

#Backend — reranking (opt-in)

VariableDefaultDescription
RERANK_ENABLEDfalseSet true to enable Cohere cross-encoder reranking on similarity/threshold queries.
RERANK_MODELrerank-english-v3.0Cohere rerank model.
RERANK_FETCH_MULTIPLIER4Over-fetch factor before reranking (top_k × this).
COHERE_API_KEYRequired when RERANK_ENABLED=true.

#Backend — vision / multimodal

VariableDefaultDescription
VISION_MODELgpt-4oModel used for image description and scanned-PDF OCR.
MIN_IMAGE_BYTES5000Embedded PDF images smaller than this are skipped (icons, bullets, rules) to avoid noise.

#Frontend

VariableDescription
NEXT_PUBLIC_API_URLBackend origin the browser calls (e.g. http://localhost:8000 or your Railway URL).
NEXT_PUBLIC_SUPABASE_URLSupabase project URL (client-side).
NEXT_PUBLIC_SUPABASE_ANON_KEYSupabase anon key (safe for the browser; not the service role key).

The API client normalizes NEXT_PUBLIC_API_URL — if it lacks a scheme it assumes https://. Set the full origin to be safe.


#External resources you must provision

ResourceRequirement
Pinecone indexServerless, dimension 1024, metric cosine. Name → PINECONE_INDEX.
Supabase Storage: documentsPrivate bucket. Holds original uploads; served via 1-hour signed URLs.
Supabase Storage: imagesPublic bucket. Holds extracted PDF figures; their public URLs go into vector metadata for inline source rendering.
Supabase AuthEmail/password enabled.
Supabase tablescollections, collection_members, collection_shares, collection_documents, document_chunks, chat_sessions, chat_messages, ingest_jobs, rag_evals, query_logs, ingest_logs.
RedisReachable at REDIS_URL; backs the Arq worker.

#Cost-relevant knobs

Most spend is OpenAI usage. The levers:

  • TOP_K and CHUNK_SIZE drive prompt size → generation cost per query.
  • Vision (multimodal PDFs / scanned OCR) is the priciest ingestion path; MIN_IMAGE_BYTES filters trivial images. Prefer native PDFs.
  • Eval scoring uses the cheaper gpt-4o-mini (two short calls per query).
  • Reranking adds a small Cohere cost per query when enabled — usually worth it for precision.

See Operations & scaling for the runtime/process view.