# landing-ai/ade-python architecture

> Architecture diagram of the GitHub repository landing-ai/ade-python, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/landing-ai/ade-python
- Repository: https://github.com/landing-ai/ade-python

## Overview

1. **What this repo is**
   - This is a **generated Python SDK** (`landingai-ade`) for the **LandingAI Agentic Document Extraction REST API**.
   - It is not an application server; the main runtime boundary is: **your Python code → SDK client → HTTPS API**.

2. **Public entrypoints**
   - The package’s public surface is exposed from `src/landingai_ade/__init__.py`.
   - The README shows two primary client variants: **`LandingAIADE` (sync)** and **`AsyncLandingAIADE` (async)**, plus HTTP client adapters such as `DefaultHttpxClient` and `DefaultAioHttpClient`.

3. **Client architecture**
   - The core client stack lives in `src/landingai_ade/_base_client.py`, `src/landingai_ade/_client.py`, and `src/landingai_ade/_resource.py`.
   - This layer owns request construction, base URL/environment selection, authentication, retries, timeouts, and routing method calls to endpoint-specific resources.
   - The design is split into **sync and async implementations** with the same API shape.

4. **API surface / endpoint grouping**
   - Endpoint-specific operations are organized as resource modules under `src/landingai_ade/resources/`.
   - The repo tree shows `parse_jobs.py`, which handles the **long-running document processing job** flow: create job, fetch status, and list jobs.
   - Other high-level operations from the README—**parse, split, extract**—are represented through client methods and associated request/response types.

5. **HTTP and response handling**
   - `src/landingai_ade/_response.py` and `src/landingai_ade/_streaming.py` define how raw HTTP responses are wrapped, parsed, streamed, and optionally exposed to callers.
   - This is where the SDK separates:
     - **eager parsing** of JSON responses,
     - **raw-response access** for headers/status,
     - **streaming response access** for large payloads or incremental reads.

6. **Request serialization and file upload path**
   - `src/landingai_ade/_files.py`, `_qs.py`, and `_utils/_transform.py` handle turning Python inputs into HTTP-friendly payloads.
   - This matters because the SDK accepts:
     - local paths / bytes / multipart tuples for file uploads,
     - nested typed request objects,
     - query parameters and extra headers/body fields.
   - The library abstracts away the multipart and encoding details before the request reaches the API.

7. **Type system and response models**
   - Runtime models and typed request/response contracts live in `src/landingai_ade/_models.py` and `src/landingai_ade/types/`.
   - Responses are **Pydantic models**; request params are mostly **TypedDict-style** structures.
   - The `types/shared/` folder captures shared schema fragments such as metadata and grounding boxes, which suggests common response shapes reused across parse/extract flows.

8. **Domain helpers**
   - `src/landingai_ade/lib/schema_utils.py` and `url_utils.py` provide SDK-specific helpers for schema conversion and URL handling.
   - The README’s extraction example uses **Pydantic model → JSON Schema** conversion before sending data to the API, so schema handling is an important boundary in the extraction flow.

9. **Utility layer**
   - `src/landingai_ade/_utils/` contains cross-cutting support code for:
     - datetime parsing,
     - JSON encoding/decoding,
     - logging,
     - path and stream helpers,
     - sync/async compatibility,
     - typing and reflection helpers.
   - These utilities keep the endpoint code thin and centralize compatibility behavior across Python versions and async/sync modes.

10. **Error and retry model**
   - `src/landingai_ade/_exceptions.py` defines the SDK’s error taxonomy, mapping HTTP failures and connection issues into typed exceptions.
   - The README’s retry behavior is implemented in the client layer: connection errors, timeouts, rate limits, conflicts, and server errors are retried with exponential backoff.
   - This is a key operational boundary between user code and the API.

11. **Testing strategy**
   - `tests/` is organized by concern: client behavior, resources, response handling, streaming, files, model serialization, query strings, transforms, and utility functions.
   - The tests mirror the architecture of the SDK rather than the API domain, which is typical for a generated library: they validate transport behavior, type handling, and endpoint wrappers.

12. **Packaging, release, and developer tooling**
   - The repo is packaged with `pyproject.toml` and ships `py.typed`, so type information is part of the distribution.
   - CI and release automation live in `.github/workflows/`, with separate workflows for CI, PyPI publish, and release checks.
   - Local/dev tooling includes `noxfile.py`, scripts for lint/format/test/bootstrap, and release-please metadata, indicating a strongly automated library release pipeline.

13. **Overall data flow**
   - Typical flow is: **caller constructs client → client serializes params/files → HTTP request goes to LandingAI ADE REST API → response is wrapped/validated by Pydantic models → caller consumes parsed data or raw/streaming response**.
   - For large documents, the flow shifts to **async parse-job creation → polling via job endpoints → retrieval of status/list results**, rather than a single synchronous request.

14. **Architecture boundary to draw**
   - The most important boundary is the **SDK boundary vs. the external REST API**.
   - Inside the repo, the architecture is a layered client library: **public client API → resource methods → transport/response layer → utility/type/model layer**.
   - There is no internal service mesh or database; the only external dependency that materially shapes the architecture is the **LandingAI ADE API over HTTP**.

Main entry points: [`src/landingai_ade/_base_client.py`](https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_base_client.py) (Base client), [`src/landingai_ade/_client.py`](https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_client.py) (Sync client), [`src/landingai_ade/_response.py`](https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_response.py) (Responses), [`src/landingai_ade/resources/parse_jobs.py`](https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/resources/parse_jobs.py) (Parse jobs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_src["SDK source"]
  node_public_api["Public API<br/>package exports<br/>[__init__.py]"]
  node_sync_client["Sync client<br/>[_client.py]"]
  node_async_client["Async client<br/>[_client.py]"]
  node_base_client["Base client<br/>transport core<br/>[_base_client.py]"]
  node_resource_base["Resource base<br/>resource routing<br/>[_resource.py]"]
  node_parse_jobs["Parse jobs<br/>endpoint resource<br/>[parse_jobs.py]"]
  node_response_layer["Responses<br/>response wrapper<br/>[_response.py]"]
  node_streaming_layer["Streaming<br/>stream support<br/>[_streaming.py]"]
  node_serialization["Serialization<br/>payload transform<br/>[_files.py]"]
  node_utils["Utilities<br/>cross-cutting helpers"]
  node_schema_helpers["Schema helpers<br/>domain helpers<br/>[schema_utils.py]"]
  node_errors["Errors<br/>exception taxonomy<br/>[_exceptions.py]"]
end

subgraph group_types["Contracts"]
  node_models["Models<br/>[_models.py]"]
  node_request_types["Request types<br/>typed dicts"]
  node_response_types["Response types<br/>pydantic types"]
end

subgraph group_tests["Tests"]
  node_client_tests["Client tests<br/>sdk tests<br/>[test_client.py]"]
  node_runtime_tests["Runtime tests<br/>utility tests<br/>[test_response.py]"]
end

subgraph group_tooling["Tooling"]
  node_packaging_tooling["CI & release<br/>automation<br/>[pyproject.toml]"]
end

node_external_api[("LandingAI ADE API<br/>external REST API")]

node_public_api -->|"exports"| node_sync_client
node_public_api -->|"exports"| node_async_client
node_sync_client -->|"uses"| node_base_client
node_async_client -->|"uses"| node_base_client
node_base_client -->|"binds"| node_resource_base
node_resource_base -->|"implements"| node_parse_jobs
node_parse_jobs -->|"accepts"| node_request_types
node_parse_jobs -->|"returns"| node_response_types
node_sync_client -->|"serializes"| node_serialization
node_async_client -->|"serializes"| node_serialization
node_serialization -->|"uses"| node_utils
node_response_layer -->|"wraps"| node_streaming_layer
node_response_layer -->|"parses"| node_models
node_models -->|"aligns"| node_response_types
node_schema_helpers -->|"supports"| node_request_types
node_base_client -->|"receives"| node_response_layer
node_base_client -->|"maps"| node_errors
node_base_client -->|"calls"| node_external_api
node_runtime_tests -.->|"verifies"| node_response_layer
node_client_tests -.->|"verifies"| node_sync_client
node_packaging_tooling -.->|"ships"| node_public_api

click node_public_api "https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/__init__.py"
click node_sync_client "https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_client.py"
click node_async_client "https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_client.py"
click node_base_client "https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_base_client.py"
click node_resource_base "https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_resource.py"
click node_parse_jobs "https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/resources/parse_jobs.py"
click node_response_layer "https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_response.py"
click node_streaming_layer "https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_streaming.py"
click node_serialization "https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_files.py"
click node_utils "https://github.com/landing-ai/ade-python/tree/main/src/landingai_ade/_utils"
click node_schema_helpers "https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/lib/schema_utils.py"
click node_errors "https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_exceptions.py"
click node_models "https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_models.py"
click node_request_types "https://github.com/landing-ai/ade-python/tree/main/src/landingai_ade/types"
click node_response_types "https://github.com/landing-ai/ade-python/tree/main/src/landingai_ade/types"
click node_client_tests "https://github.com/landing-ai/ade-python/blob/main/tests/api_resources/test_client.py"
click node_runtime_tests "https://github.com/landing-ai/ade-python/blob/main/tests/test_response.py"
click node_packaging_tooling "https://github.com/landing-ai/ade-python/blob/main/pyproject.toml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public_api,node_sync_client,node_async_client,node_base_client,node_resource_base,node_parse_jobs,node_response_layer,node_streaming_layer,node_serialization,node_utils,node_schema_helpers,node_errors toneBlue
class node_models,node_request_types,node_response_types toneAmber
class node_client_tests,node_runtime_tests toneMint
class node_packaging_tooling toneRose
class node_external_api toneNeutral
```

## Components

### SDK source

Generated client library and runtime helpers.

- [Public API](https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/__init__.py): package exports · Top-level package surface exposed from src/landingai_ade/__init__.py. · `src/landingai_ade/__init__.py`
- [Sync client](https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_client.py): client · Synchronous LandingAIADE entrypoint and method surface. · `src/landingai_ade/_client.py`
- [Async client](https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_client.py): client · AsyncLandingAIADE entrypoint with the same API shape as the sync client. · `src/landingai_ade/_client.py`
- [Base client](https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_base_client.py): transport core · Shared request construction, auth, retries, timeout, and environment selection. · `src/landingai_ade/_base_client.py`
- [Resource base](https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_resource.py): resource routing · Common resource wrapper that binds client methods to API endpoint groups. · `src/landingai_ade/_resource.py`
- [Parse jobs](https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/resources/parse_jobs.py): endpoint resource · Long-running document job operations: create, get status, and list. · `src/landingai_ade/resources/parse_jobs.py`
- [Responses](https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_response.py): response wrapper · Raw, parsed, and streaming response handling around HTTP results. · `src/landingai_ade/_response.py`
- [Streaming](https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_streaming.py): stream support · Incremental and large-payload response access. · `src/landingai_ade/_streaming.py`
- [Serialization](https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_files.py): payload transform · Query-string, multipart, file, and object-to-HTTP transformations. · `src/landingai_ade/_files.py`
- [Utilities](https://github.com/landing-ai/ade-python/tree/main/src/landingai_ade/_utils): cross-cutting helpers · Datetime, JSON, logging, path, sync/async, reflection, and typing helpers. · `src/landingai_ade/_utils`
- [Schema helpers](https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/lib/schema_utils.py): domain helpers · Schema conversion and URL helpers used by extraction and request building. · `src/landingai_ade/lib/schema_utils.py`
- [Errors](https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_exceptions.py): exception taxonomy · Typed exceptions for HTTP failures, connection issues, and retries. · `src/landingai_ade/_exceptions.py`

### Contracts

Typed request and response models used by the SDK.

- [Models](https://github.com/landing-ai/ade-python/blob/main/src/landingai_ade/_models.py): runtime models · Pydantic response models and supporting runtime model definitions. · `src/landingai_ade/_models.py`
- [Request types](https://github.com/landing-ai/ade-python/tree/main/src/landingai_ade/types): typed dicts · Typed request parameter structures for parse, split, extract, and jobs. · `src/landingai_ade/types`
- [Response types](https://github.com/landing-ai/ade-python/tree/main/src/landingai_ade/types): pydantic types · Typed response objects and shared schema fragments. · `src/landingai_ade/types`

### Tests

Behavioral tests mirroring the client architecture.

- [Client tests](https://github.com/landing-ai/ade-python/blob/main/tests/api_resources/test_client.py): sdk tests · Tests for client behavior, resources, response handling, and serialization. · `tests/api_resources/test_client.py`
- [Runtime tests](https://github.com/landing-ai/ade-python/blob/main/tests/test_response.py): utility tests · Tests for files, response, streaming, transforms, and utility helpers. · `tests/test_response.py`

### Tooling

Packaging, CI, release, and local development automation.

- [CI & release](https://github.com/landing-ai/ade-python/blob/main/pyproject.toml): automation · Packaging, linting, testing, CI, and publish workflows. · `pyproject.toml`

### Other components

- **LandingAI ADE API**: external REST API · Remote HTTP boundary consumed by the SDK.

## Connections

- Public API → Sync client: exports · Public package surface exposes the sync client.
- Public API → Async client: exports · Public package surface exposes the async client.
- Sync client → Base client: uses · Sync client delegates transport concerns to the shared base client.
- Async client → Base client: uses · Async client delegates transport concerns to the shared base client.
- Base client → Resource base: binds · Base client provides the machinery used by resource wrappers.
- Resource base → Parse jobs: implements · Resource layer exposes parse job endpoints.
- Parse jobs → Request types: accepts · Endpoint methods consume typed request payloads.
- Parse jobs → Response types: returns · Endpoint methods return typed response models.
- Sync client → Serialization: serializes · Client prepares files, query strings, and request bodies before send.
- Async client → Serialization: serializes · Async client shares the same payload transformation layer.
- Serialization → Utilities: uses · Serialization relies on shared helpers for encoding and transforms.
- Responses → Streaming: wraps · Response handling can expose streaming access.
- Responses → Models: parses · Parsed responses are validated into Pydantic models.
- Models → Response types: aligns · Runtime models correspond to typed response contracts.
- Schema helpers → Request types: supports · Schema conversion feeds extraction request construction.
- Base client → Responses: receives · Transport layer hands raw responses to the response wrapper.
- Base client → Errors: maps · HTTP and connection failures become typed SDK exceptions.
- Base client → LandingAI ADE API: calls · Client issues HTTPS requests to the LandingAI ADE API.
- Runtime tests → Responses: verifies · Tests cover response parsing and streaming behavior.
- Client tests → Sync client: verifies · Tests cover client routing and resource behavior.
- CI & release → Public API: ships · Packaging and release automation publish the SDK surface.
