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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qaechi_sink-1.0.0.tar.gz | 21.8 kB | With provenance | Details for qaechi_sink-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qaechi_sink-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for qaechi_sink-1.0.0-py3-none-any.whl |
Total release size: 43.1 kB
Release files / qaechi_sink-1.0.0.tar.gz
| Download URL | qaechi_sink-1.0.0.tar.gz |
|---|---|
| Size | 21.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ef018b1ab68a30aee933a829c827c9b04995d1af0267029bfd3d4a6063ade57
|
|
BLAKE2b-256 checksum How to use checksums |
6b3569a26c55b621d5645d0d2370149e0543f400aaa50b085ff3183251d57612
|
| 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 logRelease files / qaechi_sink-1.0.0-py3-none-any.whl
| Download URL | qaechi_sink-1.0.0-py3-none-any.whl |
|---|---|
| Size | 21.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0de8b4ff597d1d9ecfd8dd9a9dfe35e18ebcfb8105102f05639e9f0f7675d179
|
|
BLAKE2b-256 checksum How to use checksums |
9e42ea603a8a7634f0b83d6a70163b7f7e98ae1d16b3210381914a3cfd961b11
|
| 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 logSecurity for qaechi-sink 1.0.0
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.
Attestation for qaechi_sink-1.0.0.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 logA 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.