# pdf-tools/smart-extract-samples architecture

> Architecture diagram of the GitHub repository pdf-tools/smart-extract-samples, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pdf-tools/smart-extract-samples
- Repository: https://github.com/pdf-tools/smart-extract-samples

## Overview

Smart Extract is a Docker-packaged PDF extraction product. Users upload a PDF, choose or build a schema, submit it to the extraction API, and review structured results with confidence scores and source bounding boxes. The README documents batch and streaming endpoints, configurable Ollama/vLLM inference, and observability through metrics, logs, and traces. The repository contains deployment and monitoring configuration rather than worker or UI implementation source, so those product components have no source path; documented relationships are cited to the README.

Main entry points: [`infra/grafana-dashboards.yaml`](https://github.com/pdf-tools/smart-extract-samples/blob/main/infra/grafana-dashboards.yaml) (Grafana dashboards), [`infra/prometheus.yaml`](https://github.com/pdf-tools/smart-extract-samples/blob/main/infra/prometheus.yaml) (Prometheus), [`infra/loki.yaml`](https://github.com/pdf-tools/smart-extract-samples/blob/main/infra/loki.yaml) (Loki), [`infra/tempo.yaml`](https://github.com/pdf-tools/smart-extract-samples/blob/main/infra/tempo.yaml) (Tempo)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Extraction experience"]
  node_ui["Web UI"]
  node_schemas["Schema presets"]
  node_results["Extraction results"]
end

subgraph group_runtime["Extraction runtime"]
  node_api["Extraction API"]
  node_batch["Batch endpoint<br/>[extract.py]"]
  node_stream["Streaming endpoint<br/>[extract_stream.py]"]
end

subgraph group_inference["Inference engines"]
  node_ollama["Docker Ollama<br/>[docker-compose.yml]"]
  node_hostollama["Host Ollama<br/>[docker-compose.yml]"]
  node_vllm["vLLM<br/>[docker-compose.yml]"]
end

subgraph group_observability["Observability"]
  node_prometheus["Prometheus<br/>[prometheus.yaml]"]
  node_loki["Loki<br/>[loki.yaml]"]
  node_tempo["Tempo<br/>[tempo.yaml]"]
  node_grafana["Grafana dashboards"]
end

node_user(("Document user"))

node_user -->|"uploads PDF"| node_ui
node_user -->|"chooses schema"| node_schemas
node_ui -->|"submits extraction"| node_api
node_api -->|"returns results"| node_results
node_api -.->|"runs inference"| node_ollama
node_api -.->|"runs inference"| node_hostollama
node_api -.->|"runs inference"| node_vllm
node_api -->|"exports metrics"| node_prometheus
node_api -->|"sends logs"| node_loki
node_api -->|"sends traces"| node_tempo
node_prometheus -->|"feeds dashboards"| node_grafana
node_loki -->|"feeds dashboards"| node_grafana
node_tempo -->|"feeds dashboards"| node_grafana

click node_schemas "https://github.com/pdf-tools/smart-extract-samples/tree/main/samples/schemas"
click node_batch "https://github.com/pdf-tools/smart-extract-samples/blob/main/api-examples/python/extract.py"
click node_stream "https://github.com/pdf-tools/smart-extract-samples/blob/main/api-examples/python/extract_stream.py"
click node_ollama "https://github.com/pdf-tools/smart-extract-samples/blob/main/docker-compose/ollama/docker-compose.yml"
click node_hostollama "https://github.com/pdf-tools/smart-extract-samples/blob/main/docker-compose/ollama-local/docker-compose.yml"
click node_vllm "https://github.com/pdf-tools/smart-extract-samples/blob/main/docker-compose/vllm/docker-compose.yml"
click node_prometheus "https://github.com/pdf-tools/smart-extract-samples/blob/main/infra/prometheus.yaml"
click node_loki "https://github.com/pdf-tools/smart-extract-samples/blob/main/infra/loki.yaml"
click node_tempo "https://github.com/pdf-tools/smart-extract-samples/blob/main/infra/tempo.yaml"
click node_grafana "https://github.com/pdf-tools/smart-extract-samples/blob/main/infra/grafana-dashboards.yaml"

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_ui,node_schemas,node_results,node_user toneBlue
class node_api,node_batch,node_stream toneAmber
class node_ollama,node_hostollama,node_vllm toneMint
class node_prometheus,node_loki,node_tempo,node_grafana toneRose
```

## Components

### Extraction experience

- **Web UI**
- [Schema presets](https://github.com/pdf-tools/smart-extract-samples/tree/main/samples/schemas): `samples/schemas`
- **Extraction results**

### Extraction runtime

- **Extraction API**
- [Batch endpoint](https://github.com/pdf-tools/smart-extract-samples/blob/main/api-examples/python/extract.py): `api-examples/python/extract.py`
- [Streaming endpoint](https://github.com/pdf-tools/smart-extract-samples/blob/main/api-examples/python/extract_stream.py): `api-examples/python/extract_stream.py`

### Inference engines

- [Docker Ollama](https://github.com/pdf-tools/smart-extract-samples/blob/main/docker-compose/ollama/docker-compose.yml): `docker-compose/ollama/docker-compose.yml`
- [Host Ollama](https://github.com/pdf-tools/smart-extract-samples/blob/main/docker-compose/ollama-local/docker-compose.yml): `docker-compose/ollama-local/docker-compose.yml`
- [vLLM](https://github.com/pdf-tools/smart-extract-samples/blob/main/docker-compose/vllm/docker-compose.yml): `docker-compose/vllm/docker-compose.yml`

### Observability

- [Prometheus](https://github.com/pdf-tools/smart-extract-samples/blob/main/infra/prometheus.yaml): `infra/prometheus.yaml`
- [Loki](https://github.com/pdf-tools/smart-extract-samples/blob/main/infra/loki.yaml): `infra/loki.yaml`
- [Tempo](https://github.com/pdf-tools/smart-extract-samples/blob/main/infra/tempo.yaml): `infra/tempo.yaml`
- [Grafana dashboards](https://github.com/pdf-tools/smart-extract-samples/blob/main/infra/grafana-dashboards.yaml): `infra/grafana-dashboards.yaml`

### Other components

- **Document user**

## Connections

- Document user → Web UI: uploads PDF (evidence: `README.md`)
- Document user → Schema presets: chooses schema (evidence: `README.md`)
- Web UI → Extraction API: submits extraction (evidence: `README.md`)
- Extraction API → Extraction results: returns results (evidence: `README.md`)
- Extraction API → Docker Ollama: runs inference (evidence: `README.md`)
- Extraction API → Host Ollama: runs inference (evidence: `README.md`)
- Extraction API → vLLM: runs inference (evidence: `README.md`)
- Extraction API → Prometheus: exports metrics (evidence: `README.md`)
- Extraction API → Loki: sends logs (evidence: `README.md`)
- Extraction API → Tempo: sends traces (evidence: `README.md`)
- Prometheus → Grafana dashboards: feeds dashboards (evidence: `README.md`)
- Loki → Grafana dashboards: feeds dashboards (evidence: `README.md`)
- Tempo → Grafana dashboards: feeds dashboards (evidence: `README.md`)
