Operational guidance for running, monitoring, and troubleshooting the service.
- Validate
.envcontains at least:LAST_MODIFIED- Optionally
GEMINI_API_KEYand other tuning vars
- Ensure required files/dirs:
config/values.jsonreports/,preprocessing/,processed/
- Local/dev start:
make run # uvicorn app.main:app --host 0.0.0.0 --port 8000 - Health: service exposes a single endpoint
GET /process.
- Process current batch:
GET /process
- Force reprocess ignoring cache:
GET /process?force=true
- Trigger reprocess via timestamp change:
- Update
.envLAST_MODIFIEDand call/process
- Update
- Adjust throughput vs. cost/limits:
- Lower
PIPELINE_MAX_WORKERSandGEMINI_CONCURRENCYto reduce API pressure - Switch
GEMINI_MODEL(e.g.,gemini-1.5-flash) for cheaper/faster runs
- Lower
- Handle quota/rate limits:
- Set
GEMINI_FALLBACK_ON_QUOTA=trueto stub quota-hit files and continue batch
- Set
- Per-file outputs:
processed/[report].json - Consolidated:
processed/result.json - Preprocessed appendix PDFs:
preprocessing/[report].pdf
- Structured JSON logs via
structlogwithX-Request-Idcorrelation. Client may provideX-Request-Id; otherwise generated per request. - Metrics (logged):
- Counters:
reports.total,reports.processed,reports.failed - Timers:
pipeline.total,pipeline.per_file,pipeline.appendix_detection,pipeline.pdf_extract,pipeline.fields_extract,pipeline.stub_task
- Counters:
- File system errors: missing
values.json, permission issues, disk full - AI processing errors: Gemini SDK unavailable, quota/rate limits (unless fallback), timeouts, invalid responses
- Data processing errors: JSON parsing/invalid config
Remediation checklist:
- Confirm
config/values.jsonis present and valid JSON - Confirm
.envhas required keys; restart with updated env - Use
/process?force=trueafter.envchanges - Reduce concurrency and enable fallback when hitting 429s
- Inspect
processed/for partially generated outputs
- When a report is exactly 2 pages and an appendix preprocessing issue is detected, the system logs a manual preprocessing resolution event. Maintain a JSONL log in
troubleshooting/per the template.
- Run test suite:
make test
- Run behind a reverse proxy (optional)
- Persist
reports/,preprocessing/, andprocessed/volumes - Secure
.envand Gemini credentials