Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/gcapella0/agente-inteligente-expedientes/llms.txt

Use this file to discover all available pages before exploring further.

Environment variables are loaded at startup via python-dotenv inside src/config.py. The file .env.example ships with the repository and serves as the canonical template — copy it before first run:
cp .env.example .env
Edit the resulting .env with your real values. Variables without a default listed below are required and the service will raise an EnvironmentError if they are missing when the relevant agent starts.
Never commit .env to version control. It contains secrets (JWT key, email credentials, API keys). Add .env to your .gitignore.
Config priority: The LLM factory (src/services/llm/llm_factory.py) checks MongoDB collection sistema_config (document _id: "llm_config") first. If that document exists, it overrides the values in .env — enabling hot-reload of LLM config via PUT /config/llm without restarting the service. All other variables are read directly from the environment on startup.

Security

JWT_SECRET_KEY
string
required
Secret key used to sign and verify JWT tokens (HS256 algorithm). Must be long, random, and unpredictable in production. The default value below is only a placeholder — replace it before deploying.Default: cambiar-en-produccion-clave-larga-y-complejaGenerate a secure value with:
python -c "import secrets; print(secrets.token_hex(48))"

Email / IMAP

These variables configure WatcherAgent — the polling agent that monitors an IMAP mailbox and downloads attachments from matching emails.
MAIL_HOST
string
IMAP server hostname.Default: imap.gmail.com
MAIL_USER
string
required
Email address used to authenticate with the IMAP server.
MAIL_PASS
string
required
App password for IMAP authentication. For Gmail, generate this in Google Account → Security → App passwords. Do not use your regular account password.
MAIL_SSL
boolean
Whether to connect to the IMAP server using SSL/TLS.Default: true
MAIL_FOLDER
string
The IMAP folder (mailbox) to monitor for incoming attachments.Default: INBOX
POLL_INTERVAL_SECONDS
number
Interval in seconds between IMAP polling cycles. Reduce for more responsive processing; increase to lower API load.Default: 60
SUBJECT_KEYWORD
string
Comma-separated list of keywords to match against the email subject. An email matches if its subject contains any of these terms (case-insensitive, accent-insensitive). Only matching emails are processed.Default: Certificado, Diploma, Hoja de vida, Curriculum, CV, Titulo, Documentacion, Voucher de pago, Constancia, Certificado de notas
BODY_KEYWORD
string
Comma-separated list of keywords to match against the email body. Works the same way as SUBJECT_KEYWORD as a secondary filter.Default: Certificado, Diploma, Hoja de vida, Curriculum, CV, Titulo, Documentacion, Voucher de pago, Constancia, Certificado de notas

MongoDB

MONGO_URI
string
MongoDB connection URI. When running with Docker Compose, this is automatically overridden in docker-compose.yml to mongodb://host.docker.internal:27017 — you do not need to change it for single-server deployments.Default: mongodb://localhost:27017
MONGO_DB
string
Name of the MongoDB database. All collections (docentes, documentos, sistema_config, etc.) are created here.Default: expedientes_uneg

LLM — General

LLM_PROVIDER
string
Selects the active LLM backend. Set to openrouter for production (cloud, API key required) or ollama for local development (free, no API key needed).Values: openrouter | ollamaDefault: openrouter

LLM — OpenRouter

These variables apply when LLM_PROVIDER=openrouter.
OPENROUTER_API_KEY
string
required
API key obtained from openrouter.ai. Required when LLM_PROVIDER=openrouter. The validate_ocr() function in config.py will raise an error if this is missing at OCR-agent startup.
OPENROUTER_MODEL
string
The primary model identifier to call first. Must be a valid OpenRouter model slug.Example: minimax/minimax-m2.5:free
OPENROUTER_FALLBACK_MODELS
string
Comma-separated list of fallback model slugs. When the primary model returns a RateLimitError, OpenRouterProvider automatically rotates to the next model in this list (up to 3 retries per model before moving on).Example: google/gemma-3-27b-it:free,meta-llama/llama-4-scout:free,qwen/qwen3-8b:free
OPENROUTER_BASE_URL
string
Base URL for the OpenRouter API. Follows the OpenAI-compatible endpoint format.Default: https://openrouter.ai/api/v1

LLM — Ollama

These variables apply when LLM_PROVIDER=ollama.
OLLAMA_BASE_URL
string
URL of the locally running Ollama server. When using Docker Compose, set this to http://host.docker.internal:11434 so the container can reach the host process.Default: http://localhost:11434
OLLAMA_MODEL
string
Model name to use for inference. Must already be pulled with ollama pull <model>.Examples: gemma4:e4b, phi3:mini, qwen2.5:0.5bDefault: mistral
OLLAMA_TIMEOUT_SECONDS
number
HTTP request timeout in seconds for calls to Ollama’s /api/chat endpoint. CPU inference for larger models can take 30–120 seconds — do not set this too low.Default: 120
OLLAMA_NUM_PREDICT
number
Maximum number of tokens the model may generate in a single response.Default: 1000
OLLAMA_NUM_THREADS
number
Number of CPU threads to allocate for Ollama inference. When unset, Ollama uses all available CPU cores. Useful for capping resource usage on shared servers.Default: all available cores

Optional paths & logging

INPUT_DIR
string
Filesystem path where WatcherAgent deposits downloaded email attachments, organized as {INPUT_DIR}/{docente_name}/.Default: data/input
STORAGE_DIR
string
Filesystem path where StorageAgent moves and stores compressed final documents, organized by teacher’s ID number (cedula).Default: data/storage
LOG_DIR
string
Directory for all log files generated by Loguru: watcher.log, audit.jsonl, operational.log, ocr.log, etc.Default: logs
AUDIT_RETENTION
string
Retention period for the audit.jsonl log file before older entries are pruned by Loguru’s rotation policy.Default: 90 days
AUDIT_ROTATION
string
File size threshold at which audit.jsonl is rotated (a new file is started and the old one is archived).Default: 50 MB
LOG_LEVEL
string
Minimum log level emitted by Loguru across all log sinks (watcher.log, operational.log, ocr.log, etc.). Valid values are standard Python log level names.Values: DEBUG | INFO | WARNING | ERROR | CRITICALDefault: INFO

Build docs developers (and LLMs) love