Skip to content

🚀 Running The Service

Boot sequence, configuration, and operational runbooks.


🏃 Boot

1
2
3
4
5
6
# API (OpenAPI-first app from openapi.yaml)
.venv\Scripts\python.exe main.py
#  → http://localhost:8000, /openapi.json, /docs (per spec config)

# Worker (poll loop)
.venv\Scripts\python.exe worker.py

main.py calls init() (wiring from init.py), registers handlers, and serves. worker.py runs poll_fetch_requests(resources) in a loop.


🔌 Configuration

Everything is env-var driven (see Reports & Caching for the full table). Minimal .env:

1
2
3
4
5
6
7
MONGO_URI=mongodb://localhost:27017
MONGO_DB=khata
REDIS_URL=redis://localhost:6379/0
WORKER_POLL_MIN=5
WORKER_POLL_MAX=60
WORKER_MAX_RETRIES=3
DEBUG=1

Secret-ish values (LLM keys, IMAP creds) go through the secrets adapter in infra/adaptors/ — never commit real keys.


🧑💻 Local Workflow

1
2
3
4
5
6
7
pip install -e ".[dev]"

# seed / smoke
.venv\Scripts\pytest.exe tests\unit -q

# CLI against the live service
.venv\Scripts\python.exe -m interfaces.fetch_request.cli list

Requires MongoDB (and Redis for the cache mirror). A local Mongo on mongodb://localhost:27017 is the default dev target.


⚙️ Production Notes

  • Run API and worker as separate processes/service units.
  • Keep WORKER_MAX_RETRIES bounded so poisoned fetch requests fail fast.
  • Point REDIS_URL at a real Redis before enabling the HTTP cache.
  • Fetch requests flip paused on ambiguity; a resolver (LLM) must be wired to auto-advance them.

Fetch Request Workflow · Development · Development — Environment