Skip to main content

qaechi-sink

Load finished qaechi jobs into the database you already run. The sink consumes result events from Kafka, fetches the values with their evidence from the parser, and writes them idempotently to PostgreSQL (Supabase, Neon, Amazon RDS), MySQL (MariaDB, Aurora), MongoDB (Atlas, DocumentDB) or an HTTPS webhook.

한국어 | How the modules fit together

qaechi.parse.results ──▶ qaechi-sink ──GET /results/{id}──▶ qaechi-parser
                              │
                              └──upsert──▶ PostgreSQL | MySQL | MongoDB | https://your-app

Run it

pip install "qaechi-sink[kafka,postgres]"      # or mysql, mongodb; the webhook needs no extra

export QAECHI_KAFKA_BOOTSTRAP_SERVERS=kafka:9092
export QAECHI_PARSER_URL=http://parser:3100
export QAECHI_INTERNAL_TOKEN=...               # the parser's token
export QAECHI_SINK_TARGET=postgresql://app:secret@db:5432/app

qaechi-sink check                              # connect and create the tables
qaechi-sink run

Run one or more replicas; they share the consumer group qaechi-sink.

Targets

QAECHI_SINK_TARGET Extra What is written
postgresql://... (Supabase: add ?sslmode=require) postgres Tables qaechi_extractions and qaechi_extraction_values
mysql://... (?ssl=true for managed services) mysql The same two tables
mongodb://... or mongodb+srv://... mongodb Collection qaechi_extractions, one document per job with the values embedded
https://... none One signed POST per job

Tables are created on first start (qaechi-sink check does it explicitly). Rename them with QAECHI_SINK_TABLE_PREFIX. On Supabase, enable Row Level Security on both tables before exposing them through the Supabase API.

Tables

qaechi_extractions: one row per job, the latest outcome.

Column
job_id primary key
document_id, doc_type what was parsed
status succeeded or failed
result_id, route, groundedness, error, attempts, finished_at from the result event
extraction the full result as JSON, including notes and payload

qaechi_extraction_values: one row per value, ready to query.

Column
job_id, path primary key. path is fields.total, lines[0].amount or total
label line label for lines[i]
value_text, value_number the value; numbers also in value_number
page, quote the evidence
confidence, verified verified = it has a quote and the quote was found in the source
-- Latest verified totals per document
SELECT e.document_id, v.value_number AS total, v.page, v.quote
FROM qaechi_extractions e JOIN qaechi_extraction_values v USING (job_id)
WHERE v.path = 'fields.total' AND v.verified AND e.status = 'succeeded';

Webhook

Each job is one POST with the job summary, the full extraction and the flattened values.

Header
X-qaechi-Signature sha256= HMAC-SHA256 of the raw body with QAECHI_SINK_WEBHOOK_SECRET. Check it
Idempotency-Key the job ID. A job can arrive more than once; deduplicate on it
traceparent W3C trace context when available

Answer 2xx when stored. 408, 429 and 5xx are retried; other 4xx go to the sink DLQ. Only https:// is accepted (http:// only for localhost).

Delivery

At least once, made safe by upserts: a redelivered event rewrites the same rows. A failed write is retried with backoff (QAECHI_SINK_MAX_RETRIES, default 5) and then copied to qaechi.sink.dlq with the reason in the qaechi-error header. The offset is committed only after the write or the DLQ copy, so nothing is lost when the database is down.

Settings

Variable Default
QAECHI_SINK_TARGET where to write (required)
QAECHI_KAFKA_BOOTSTRAP_SERVERS brokers (required)
QAECHI_PARSER_URL parser API to fetch values from. Unset = status only
QAECHI_INTERNAL_TOKEN the parser's internal token
QAECHI_SINK_INCLUDE_FAILED true also record failed jobs
QAECHI_SINK_TABLE_PREFIX qaechi_ table and collection prefix
QAECHI_SINK_WEBHOOK_SECRET HMAC key for webhook signatures
QAECHI_SINK_MAX_RETRIES 5 retries before the DLQ
QAECHI_KAFKA_TOPIC_RESULTS qaechi.parse.results
QAECHI_SINK_TOPIC_DLQ qaechi.sink.dlq
QAECHI_SINK_GROUP_ID qaechi-sink
QAECHI_KAFKA_CONF_* any librdkafka setting, e.g. SASL for Amazon MSK

Another database? Implement the four-method Target protocol in qaechi.sink.targets and pass it to qaechi.sink.runner.run(target=...).

License

Apache-2.0. See LICENSE.

Metadata

Release files for qaechi-sink 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qaechi-sink 1.0.1
File Size Uploaded Provenance Actions
qaechi_sink-1.0.1.tar.gz 21.8 kB With provenance Details for qaechi_sink-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for qaechi-sink 1.0.1
File Interpreter ABI Platform Actions
qaechi_sink-1.0.1-py3-none-any.whl Python 3 none any Details for qaechi_sink-1.0.1-py3-none-any.whl

Total release size: 43.1 kB

Release files / qaechi_sink-1.0.1.tar.gz

Download URL qaechi_sink-1.0.1.tar.gz
Size 21.8 kB
Tags Source
SHA-256 checksum
How to use checksums
388aa18e56cb81389887ee224c1c1699b815f7ca3cd44a1ad2ed544f096ded98
BLAKE2b-256 checksum
How to use checksums
62c84747fc1dbd22751338ff7f26a73ffe19a059f79b6387ef3de50d3ff1b901
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / qaechi_sink-1.0.1-py3-none-any.whl

Download URL qaechi_sink-1.0.1-py3-none-any.whl
Size 21.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32d2128dcfcafe93868d98c5c77e59eaf57bcefede4e243e19d7e312364fbda8
BLAKE2b-256 checksum
How to use checksums
15112bd852f9922562b6417903b9d059ec10ea7624f3f8bd43810f1c409ebebc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for qaechi-sink 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for qaechi_sink-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page