Skip to main content

Configuration reference

Chive configuration is managed through environment variables and configuration files.

Configuration sources

Configuration is loaded in order (later sources override earlier):

  1. Default values (hardcoded)
  2. Configuration files (config/*.yaml)
  3. Environment variables
  4. Command-line arguments

Server configuration

API server

OptionEnv varDefaultDescription
server.portPORT3000HTTP port
server.hostHOST0.0.0.0Bind address
server.trustProxyTRUST_PROXYfalseTrust X-Forwarded headers
server.corsOriginsCORS_ORIGINS*Allowed CORS origins
server.requestTimeoutREQUEST_TIMEOUT30000Request timeout (ms)
server.bodyLimitBODY_LIMIT10mbRequest body limit

Worker

OptionEnv varDefaultDescription
worker.concurrencyWORKER_CONCURRENCY5Concurrent jobs
worker.queuesWORKER_QUEUESindexing,enrichmentQueues to process

Database configuration

PostgreSQL

OptionEnv varDefaultDescription
postgres.hostPOSTGRES_HOSTlocalhostDatabase host
postgres.portPOSTGRES_PORT5432Database port
postgres.databasePOSTGRES_DBchiveDatabase name
postgres.userPOSTGRES_USERchiveUsername
postgres.passwordPOSTGRES_PASSWORDRequiredPassword
postgres.poolMinPOSTGRES_POOL_MIN5Min pool connections
postgres.poolMaxPOSTGRES_POOL_MAX20Max pool connections
postgres.sslPOSTGRES_SSLfalseEnable SSL

Elasticsearch

OptionEnv varDefaultDescription
elasticsearch.urlELASTICSEARCH_URLhttp://localhost:9200Cluster URL
elasticsearch.userELASTICSEARCH_USERNoneUsername
elasticsearch.passwordELASTICSEARCH_PASSWORDNonePassword
elasticsearch.indexPrefixELASTICSEARCH_INDEX_PREFIXchiveIndex prefix
elasticsearch.shardsELASTICSEARCH_SHARDS3Shards per index
elasticsearch.replicasELASTICSEARCH_REPLICAS2Replicas

Neo4j

OptionEnv varDefaultDescription
neo4j.uriNEO4J_URIbolt://localhost:7687Bolt URI
neo4j.userNEO4J_USERneo4jUsername
neo4j.passwordNEO4J_PASSWORDRequiredPassword
neo4j.databaseNEO4J_DATABASEneo4jDatabase name
neo4j.maxPoolSizeNEO4J_MAX_POOL_SIZE50Connection pool

Redis

OptionEnv varDefaultDescription
redis.hostREDIS_HOSTlocalhostRedis host
redis.portREDIS_PORT6379Redis port
redis.passwordREDIS_PASSWORDNonePassword
redis.dbREDIS_DB0Database number
redis.tlsREDIS_TLSfalseEnable TLS

Authentication

OptionEnv varDefaultDescription
auth.jwtSecretJWT_SECRETRequiredJWT signing secret
auth.jwtExpiryJWT_EXPIRY7dToken expiration
auth.sessionTtlSESSION_TTL604800Session TTL (seconds)
auth.mfaRequiredMFA_REQUIREDfalseRequire MFA

Rate limiting

OptionEnv varDefaultDescription
rateLimit.enabledRATE_LIMIT_ENABLEDtrueEnable rate limiting
rateLimit.windowMsRATE_LIMIT_WINDOW60000Window size (ms)
rateLimit.anonymousRATE_LIMIT_ANONYMOUS30Anonymous requests/window
rateLimit.authenticatedRATE_LIMIT_AUTHENTICATED100Auth requests/window
rateLimit.trustedRATE_LIMIT_TRUSTED500Trusted requests/window

Firehose

OptionEnv varDefaultDescription
firehose.urlFIREHOSE_URLRequiredRelay URL
firehose.collectionsFIREHOSE_COLLECTIONSpub.chive.*Collections to index
firehose.reconnectDelayFIREHOSE_RECONNECT_DELAY5000Reconnect delay (ms)
firehose.maxRetriesFIREHOSE_MAX_RETRIES10Max reconnect attempts

Caching

OptionEnv varDefaultDescription
cache.preprintTtlCACHE_PREPRINT_TTL300Preprint cache TTL (s)
cache.searchTtlCACHE_SEARCH_TTL300Search cache TTL (s)
cache.userTtlCACHE_USER_TTL600User cache TTL (s)
cache.blobTtlCACHE_BLOB_TTL3600Blob cache TTL (s)

Observability

OptionEnv varDefaultDescription
log.levelLOG_LEVELinfoLog level
log.formatLOG_FORMATjsonLog format (json/pretty)
otel.enabledOTEL_ENABLEDfalseEnable OpenTelemetry
otel.endpointOTEL_EXPORTER_OTLP_ENDPOINTNoneOTLP endpoint
otel.serviceNameOTEL_SERVICE_NAMEchiveService name
metrics.portMETRICS_PORT9090Prometheus port

External services

Semantic Scholar

OptionEnv varDefaultDescription
semanticScholar.apiKeyS2_API_KEYNoneAPI key
semanticScholar.rateLimitS2_RATE_LIMIT100Requests per 5 min

OpenAlex

OptionEnv varDefaultDescription
openAlex.emailOPENALEX_EMAILNoneContact email
openAlex.rateLimitOPENALEX_RATE_LIMIT10Requests per second

ORCID

OptionEnv varDefaultDescription
orcid.clientIdORCID_CLIENT_IDNoneOAuth client ID
orcid.clientSecretORCID_CLIENT_SECRETNoneOAuth client secret

Feature flags

OptionEnv varDefaultDescription
features.discoveryFEATURE_DISCOVERYtrueEnable recommendations
features.claimingFEATURE_CLAIMINGtrueEnable authorship claims
features.governanceFEATURE_GOVERNANCEtrueEnable governance
features.backlinksFEATURE_BACKLINKStrueEnable Bluesky backlinks

Configuration files

config/default.yaml

server:
port: 3000
host: 0.0.0.0
trustProxy: false

postgres:
host: localhost
port: 5432
database: chive
poolMin: 5
poolMax: 20

redis:
host: localhost
port: 6379
db: 0

cache:
preprintTtl: 300
searchTtl: 300

log:
level: info
format: json

config/production.yaml

server:
trustProxy: true

postgres:
ssl: true
poolMin: 10
poolMax: 50

elasticsearch:
replicas: 2

cache:
preprintTtl: 600

log:
level: warn

Loading configuration

import { loadConfig } from '@/config/index.js';

const config = loadConfig();

console.log(config.server.port); // 3000
console.log(config.postgres.host); // localhost

Validation

Configuration is validated on startup:

// All required fields must be set
if (!config.postgres.password) {
throw new ConfigurationError('POSTGRES_PASSWORD is required');
}

// Values must be within bounds
if (config.rateLimit.anonymous < 1) {
throw new ConfigurationError('Rate limit must be positive');
}