How atul2501/lt_foods_pr works
LT Foods Invoice Extraction API accepts PDFs from SAP uploads and email, extracts and verifies invoice data, then returns SAP ZFTVIA contract JSON. Its key reliability boundary is deterministic grounding and business-rule validation after LLM structuring. The README documents both the upload/poll API and email polling, plus optional SAP RFC push. Relationships within the pipeline are supported by the run-module reference index and README workflow; unsampled implementation details are not inferred beyond those references.
Main entry points: run.py Pipeline runner · ingest.py Email ingestion · invoices.py Invoice API · llm_structurer.py LLM structuring
Components 23
PDF intake
- Invoice API
app/api/routers/invoices.py - Email poller
app/email_ingest/runner.py - Email ingestion
app/email_ingest/ingest.py
Extraction and validation
- Pipeline runner
app/pipeline/run.py - PDF triage
app/pipeline/triage.py - Text extraction
app/pipeline/text_extract.py - Scanned-page OCR
app/pipeline/ocr.py - Text normalization
app/pipeline/normalize.py - LLM structuring
app/pipeline/llm_structurer.py - Extraction schema
app/schemas/invoice_schema.py - Field grounding
app/pipeline/grounding.py - Business rules
app/pipeline/business_rules.py - Result status
app/pipeline/status.py
API and results
- Contract mapping
app/pipeline/to_response.py - API result schema
app/schemas/envelope.py - File result store
app/storage/results_store.py
External integrations
- IMAP mailbox
- Ollama client
app/services/ollama_client.py - Ollama model
- SAP RFC push
app/sap/push.py - SAP RFC endpoint
Other components
- SAP/API caller
- Invoice sender
Connections 25
- SAP/API caller → Invoice API: uploads PDF
- Invoice sender → IMAP mailbox: sends invoice
- Email poller → Email ingestion: runs polling
app/email_ingest/runner.py - Email ingestion → IMAP mailbox: fetches messages
- Invoice API → Pipeline runner: starts extraction
app/api/routers/invoices.py - Email ingestion → Pipeline runner: extracts PDFs
app/email_ingest/ingest.py - Pipeline runner → PDF triage: classifies pages
app/pipeline/run.py - Pipeline runner → Text extraction: extracts digital text
app/pipeline/run.py - Pipeline runner → Scanned-page OCR: OCRs scanned pages
app/pipeline/run.py - Pipeline runner → Text normalization: normalizes text
app/pipeline/run.py - Pipeline runner → LLM structuring: structures text
app/pipeline/run.py - LLM structuring → Ollama client: requests generation
app/pipeline/llm_structurer.py - Ollama client → Ollama model: sends prompt
- LLM structuring → Extraction schema: validates output
app/pipeline/llm_structurer.py - Pipeline runner → Field grounding: verifies fields
app/pipeline/run.py - Pipeline runner → Business rules: checks invoice
app/pipeline/run.py - Pipeline runner → Result status: assigns status
app/pipeline/run.py - Invoice API → Contract mapping: maps results
app/api/routers/invoices.py - Email ingestion → Contract mapping: maps results
app/email_ingest/ingest.py - Contract mapping → API result schema: builds contract
app/pipeline/to_response.py - Invoice API → File result store: reads and claims
app/api/routers/invoices.py - Email ingestion → File result store: writes pending results
app/email_ingest/ingest.py - File result store → SAP/API caller: returns contract JSON
- Email ingestion → SAP RFC push: optionally pushes PDF
app/email_ingest/ingest.py - SAP RFC push → SAP RFC endpoint: calls RFC