System design / VOLTFILL

Architecture & C4

PDFの解析・画像化とJevへの送信
構成・処理・C4の5図。

VIEW 01 / 05

構成と役割

文字抽出・画像化・評価の関係。

入力解析実行原文と座標画像入力時PNG + transformPOST / batches応答本文を保持決定・検証メタデータのみINPUTPDF と抽出定義PDF / JSON schemaENTRY POINTCLI / HTTP / Rust共通の voltfill-core を呼ぶPDF-PROBE · NATIVE-FREEPDF ソース解析pdf-inspector + lopdf文字・位置・ページ構造VOLTFILL-CORE抽出エンジン依存する質問を段階実行独立した質問をバッチ化PDF-RENDER · OPTIONALPDF ページの画像化PNG + 座標変換情報PDFium / Hayro を選択EXTERNAL · HTTPSJev API質問 + テキスト / PNGリクエスト許可が必要RETURN VALUE結果と元レスポンスFields / Evidence / usageOBSERVABILITY構造化ログOpenTelemetry / OTLP

再利用可能な基盤 crate

矢印は依存方向。基盤はスキーマ・Evidence不要で、coreが抽出・全体計測・field/page関連を持ちます。既存API・描画feature既定オフを維持。画像PDFも調査・描画できますが、抽出には原文Evidenceが必要です。

voltfill-coreEvidence / schema / enginepdf-probePDF / source / geometrypdf-renderPNG / transformjev-clientrequest / transport / recordingotel-logOTLP JSON ログ
内部の処理・データ外部API通信任意の機能
図の要素を選択

クリック/Tab → Enterで詳細。

文字抽出

文字・位置をローカルで取得。画像化とは別処理。

画像化

Vision / Hybrid用のPNGと座標変換を保持。

結果とログ

原応答と運用ログを分離。ログレベルは結果に影響しない。

Mermaidの詳細モデルを表示
flowchart LR
    Files[PDF + schema] --> CLI[CLI]
    Upload[Multipart PDF + schema + options] --> Server[Axum server]
    Caller[Rust caller] --> Engine
    CLI --> Engine[Extraction engine]
    Server --> Engine
    Engine --> Snapshot[pdf-probe: bounded PDF snapshot]
    Snapshot --> Candidates[Source candidates + geometry]
    Snapshot --> Renderer[pdf-render: optional PDFium / Hayro]
    Candidates --> Plan[Dependency waves + compatible batches]
    Renderer --> Plan
    Plan --> Evaluator[Injected Evaluator]
    Evaluator --> Fixture[Fixture evaluator]
    Evaluator --> Remote[Remote evaluator]
    Remote --> Admission[jev-client: limits + retries + recording]
    Admission --> Jev[Jev HTTPS API]
    Evaluator --> Resolve[Resolve + validate + provenance check]
    Candidates --> Resolve
    Resolve --> Report[Fields + Evidence + usage + jev_responses]
    Remote --> Originals[Original attempt bodies]
    Originals --> Report
    Engine --> Logs[OpenTelemetry SDK logs]
VIEW 02 / 05

実行シーケンス

質問の依存・送信制御・原応答の返却。

PDF + schema + options解析 / 必要なページを描画原文・位置・画像互換な独立質問をバッチ化設定した上限内でPOSTHTTP status + 応答本文answers / errors / usage部分成功 + Evidence + 応答本文検証前に応答本文を保持HOST呼び出し元COREEngineLOCALPDF / 画像CONTROLEvaluatorHTTPSJev
内部の処理・データ外部API通信任意の機能
図の要素を選択

クリック/Tab → Enterで詳細。

送信前

頻度・トークン・並列・推定文脈量・期限を制限する。質問を分割し、1件でも超過なら原文を切らず送信前に非対応とする。再試行も推定量を予約して同じ上限を適用。同期解析・描画は期限で強制中断できない。

再試行

上限付き指数バックオフ+jitterで待つ。Retry-Afterより早く再送せず、初回込み1〜3試行。

並列とバッチ

独立質問をバッチ化し、並列・送信上限内で実行。

Mermaidの詳細モデルを表示
sequenceDiagram
    participant Adapter as CLI / HTTP / library caller
    participant Engine
    participant PDF as Snapshot / candidates / renderer
    participant Eval as Evaluator
    participant Control as Execution controller
    participant API as Jev
    Adapter->>Engine: PDF + validated schema + options
    Engine->>PDF: Build snapshot; prepare scoped source/images
    loop Dependency waves
        Engine->>Eval: Compatible independent question batches
        loop Each attempt within configured bounds
            Eval->>Control: Reserve request/tokens/cost; await admission
            Control-->>Eval: Permit or bounded failure
            Eval->>API: HTTPS request
            API-->>Eval: HTTP status + original body
            Eval->>Eval: Retain original body before validation
            opt Retryable and budget/deadline allows
                Eval->>Control: Wait exponential backoff + jitter / Retry-After
            end
        end
        Eval-->>Engine: Answers/errors + usage + original responses
        Engine->>Engine: Resolve source, validate, check provenance
    end
    Engine-->>Adapter: Partial report or error with received responses
VIEW 03 / 05

C4 · System context

利用者・アプリ・外部サービスとの関係。

PDF + schema質問 / 対象データHTTP responseJSON / Rust valuesPERSON利用者・開発者PDFと質問を定義Evidenceを確認するSYSTEMVOLTFILLPDFから構造化値を抽出原文と位置を根拠として返すEXTERNAL SYSTEMJev APIテキスト・画像の質問評価EXTERNAL SYSTEM呼び出し元のアプリ結果の確認・保存・後続処理
内部の処理・データ外部API通信任意の機能
図の要素を選択

クリック/Tab → Enterで詳細。

入力

入力はPDFと抽出スキーマ。

Jevへ送るデータ

指定範囲の文字・PNG・質問だけを送り、PDF自体は送らない。

結果の取り扱い

原文・座標を含む結果の保存先・公開範囲は呼び出し元で管理。

Mermaidの詳細モデルを表示
C4Context
    title VOLTFILL system context
    Person(user, "User / application developer", "Defines questions and reviews source-backed values")
    System(voltfill, "VOLTFILL", "Extracts structured values and Evidence from PDFs")
    System_Ext(jev, "Jev API", "Evaluates declared text/image questions")
    System_Ext(consumer, "Consuming application", "Reviews results and owns downstream actions")
    Rel(user, voltfill, "Supplies PDF, schema and explicit execution permissions")
    Rel(voltfill, jev, "Sends scoped text/images and questions when enabled", "HTTPS")
    Rel(voltfill, consumer, "Returns evaluation-only fields, Evidence, usage and original responses", "JSON / Rust values")
VIEW 04 / 05

C4 · Containers

CLI・HTTPサーバーのプロセスと外部接続。

VOLTFILL · ALTERNATIVE EXECUTABLE HOSTSCLIHTTP multipartHTTPSHTTPSOTel SDKOTel SDKPERSON / CLIENT呼び出し元ファイル / multipartRUST EXECUTABLEvoltfill runvoltfill-coreをリンクファイル入力 → JSON出力AXUM / TOKIOvoltfill servevoltfill-coreをリンクspawn_blockingで実行EXTERNAL · HTTPSJev API明示した接続先LOCAL / OPT-IN COLLECTORログ出力先既定は無効 / OTLP JSONL
内部の処理・データ外部API通信任意の機能
図の要素を選択

クリック/Tab → Enterで詳細。

起動と設定

run / serve共通の資源・送信制限と任意の描画featureは設定ガイドの起動設定を参照してください。

HTTP受付

上限はPDF 16 MiB・schema 1 MiB・options 64 KiB、期限30秒。実行中は429で拒否。

公開・隔離の設定

既定はループバック。外部待ち受け・Origin付き抽出はBearer必須。実APIの画像抽出は起動時に--allow-imagesを指定。TLS終端・不正PDF対策の隔離は運用側で用意する。

Mermaidの詳細モデルを表示
C4Container
    title VOLTFILL runtime containers
    Person(user, "Caller", "Local user or HTTP client")
    System_Boundary(voltfill, "VOLTFILL") {
        Container(cli, "voltfill run", "Rust executable", "Validates files/options, invokes core and emits JSON")
        Container(server, "voltfill serve", "Rust / Axum / Tokio", "Authenticates multipart uploads and admits bounded jobs")
    }
    System_Ext(jev, "Jev API", "Configured HTTPS model endpoint")
    System_Ext(sink, "Log writer / optional collector", "Disabled by default; local OTLP JSONL when enabled; caller-configured SDK exporter for forwarding")
    Rel(user, cli, "Provides PDF/schema files and flags")
    Rel(user, server, "Uploads PDF/schema/options", "HTTP multipart; Bearer when required")
    Rel(cli, jev, "Evaluates batches through linked core", "HTTPS")
    Rel(server, jev, "Evaluates batches through linked core / blocking worker", "HTTPS")
    Rel(cli, sink, "Emits structured events", "OpenTelemetry SDK")
    Rel(server, sink, "Emits structured events", "OpenTelemetry SDK")
VIEW 05 / 05

C4 · Components

共通コアと基盤 crate の役割、返却データの流れ。

CLI OR HTTP SERVER PROCESS · LINKED COMPONENTSvalidated schemainspectplansource / imagesbounded execution応答本文・使用量answerscanonical sourcereportsafe metadataschemaSchema質問・依存・型を検証engineEnginewaves / batches / strategyloggingTelemetryotel-log / OTLP JSONpdf-probe / pdf-renderPDF source文字・位置・品質検査PDFium / Hayro で画像化evaluateEvaluatorFixture / Remotejev-clientExecution / HTTP送信上限・並列・再試行明示HTTPS接続先engine / validateResolver / Validator原文・型・出典を確認modelResult model部分成功 + 応答本文
内部の処理・データ外部API通信任意の機能
図の要素を選択

クリック/Tab → Enterで詳細。

原文との対応

原文と正規化値を分け、同文でも位置が違えば別候補とする。部分調査で文書全体の不存在は断定しない。

レスポンスの保持

本文はUTF-8なら原文字列、それ以外はバイト列で保持。未知キー・検証失敗・再試行も残す。受信失敗・容量上限を示し、不完全・未受信ならbody_completeはfalse。

抽出できる条件

抽出には文字・座標が必要。文字コードと表示が異なるPDFは非対応の場合がある。

Mermaidの詳細モデルを表示
C4Component
    title Voltfill linked crates and components
    Container_Boundary(host, "CLI or HTTP server process") {
        Component(adapter, "Host adapter", "CLI / Axum", "Supplies inputs, options and evaluator")
        Component(schema, "Schema", "schema", "Validates fields, dependencies, modalities and resolver rules")
        Component(engine, "Engine", "engine", "Schedules dependency waves and compatible independent batches")
        Component(pdf, "PDF snapshot", "pdf-probe", "Bounds source inspection and validates page metadata")
        Component(source, "Source index", "core::candidates + probe::geometry", "Tracks original runs, coordinates and canonical Evidence")
        Component(render, "Renderer", "pdf-render features", "Produces bounded PNGs and transform ledgers")
        Component(eval, "Evaluator", "evaluate", "Fixture or remote question evaluation")
        Component(transport, "Execution and HTTP", "jev-client", "Applies configured limits, concurrency and retries")
        Component(validation, "Resolution and validation", "engine + validate", "Checks source, mappings, acceptance and provenance")
        Component(model, "Result model", "model", "Partial field results, Evidence, usage and original response bodies")
        Component(logging, "Telemetry logger", "logging over otel-log", "Compatibility layer; otel-log writes the OTLP JSONL output")
    }
    System_Ext(jev, "Jev API", "Text/image evaluation")
    Rel(adapter, schema, "Parses form")
    Rel(adapter, engine, "Calls extraction")
    Rel(engine, pdf, "Inspects PDF")
    Rel(pdf, source, "Provides source runs")
    Rel(engine, render, "Requests scoped page images")
    Rel(engine, eval, "Evaluates batches")
    Rel(eval, transport, "Requests bounded remote execution")
    Rel(transport, jev, "Sends explicit requests", "HTTPS")
    Rel(eval, validation, "Provides answers and usage")
    Rel(source, validation, "Supplies canonical source Evidence")
    Rel(validation, model, "Constructs field results")
    Rel(transport, model, "Retains each original received body")
    Rel(engine, logging, "Emits counts, statuses and durations")