Domain
domain
Summary
The Expenses Service domain layer: business knowledge, models, ports, enrichment and fetch pipelines, with zero I/O.
The domain package holds the rules of the Expenses Service: pydantic models, abstract ports, and the enrichment/fetch pipeline logic. No module here touches the network, the database, or user-facing HTTP; all external effects flow through ports implemented by the infrastructure layer and injected at the composition root.
Installation
Install the Expenses Service with its development tooling:
1 | |
Quick start
Resolve the lazily cached entity enrichment pipeline and run it over a minimal state payload:
1 2 3 4 5 6 | |
Core concepts
- Three-layer architecture:
interface(OpenAPI/FastAPI routes) →domain(business rules, zero I/O) →infra(MongoDB, SSE, OCR, LLM providers). Each layer imports only the one below it. - Models: pydantic schemas that validate the data the domain moves, from fetch requests to enriched expenses.
- Ports: abstract contracts the domain needs from the outside world;
infrastructure implementations are injected via
hexa.build. - Enrichment: rule-driven pipelines (entity + tags) that turn raw descriptions into payees and tags.
- Fetch pipeline: extracts expenses from pdf, email, xlsx, csv and LlamaParse sources, then enriches and persists them.
Notes
Guarantees:
- Domain code performs zero I/O; persistence, OCR, LLM calls and streaming happen only through injected ports and adaptors.
Lifecycle:
- The package is compiled statically by
doc-forgefrom its GSDFC docstrings; source remains the single source of truth.