Fond facade
Each Legifrance fond (Code, Juri, LODA, KALI…) has its own facade in
pylegifrance/fonds/. A facade:
- takes a
LegifranceClient(and an optionalfondparameter to pick the base — e.g.CODE_DATEvsCODE_ETAT); - exposes
.search()which returns a fluent builder (see/en/concepts/builder-pattern); - exposes
.fetch_*()methods returning fetchers (a more focused builder pattern).
Design invariant
Section titled “Design invariant”Anything outside
pylegifrance/fonds/*andpylegifrance/__init__.pyis considered internal.
Users never instantiate the models/generated/ models directly — they always
go through the facade, which composes domain models (models/<fond>/) and
converts them to generated DTOs (to_generated()) before the API call.
Benefits
Section titled “Benefits”- Public stability: the Legifrance OpenAPI schema can change without breaking the pylegifrance API.
- Ergonomics: the facade offers shortcuts (e.g.
search("word")for simple cases). - Enrichment: objects returned by the facade have business methods (e.g.
decision.at(date)) absent from the raw DTO.