Products · DocFlow app

JSON and CSV output

Preview the final JSON, metadata and CSV before paying.

Version 1 · The app that connects the servicesDesigned, not builtModule 6 of 15

ProductRead MeSections

Read Me

DocFlow is the first app built from the 01scale platform services. It turns an uploaded invoice into reviewed JSON and CSV, by calling Upload, LLM Extraction, Human Review, Payment and Delivery in order.

It is deliberately thin. It keeps one record per invoice (which file, job, review and order belong together, and where the process is) and builds the invoice-specific results. Everything else is a service it calls.

This page covers DocFlow's own parts: the documents list, the JSON and CSV outputs, checkout, the success page and the downloads.

Why it exists

The process lives in one place

The order of steps is written once, in the app, so the services stay unaware of invoices and of each other.

The next app is a copy, not a rewrite

Procure-to-Pay would be another thin app calling the same services in a different order.

Results people can trust

The JSON is validated against a published schema and carries what was corrected and how sure the system was; the CSV opens cleanly in Excel and cannot run formulas.

In this version

  • The documents list with status and next action
  • Starting each service at the right moment, and reacting to their events
  • Building `result.json` (with metadata) and `result.csv` on demand from Review's latest values, nothing stored
  • Locked preview; downloads only after payment, checked on the server
  • Correcting values on the results page, before or after paying
  • Checkout at $5.00 and the success page
  • Asking Delivery to email when paid

Not in this version

  • Batches of documents: EXTRACTION-V2-E9, DOCFLOW-V2-E12
  • Paying with a saved card: PAYMENT-V2-E13
  • Anything a service does: it is designed in that service

How DocFlow connects the services

  1. DocFlow. Creates the document and Upload's file; after the upload, starts Extraction.
  2. Extraction. Tells DocFlow the job finished (extraction.job.completed).
  3. DocFlow. Sends the fields to Review as a task.
  4. DocFlow. When the person completes review: re-checks values with Extraction and completes the Review task.
  5. DocFlow. Whenever results are previewed or downloaded: builds the JSON and CSV from Review's latest values and Extraction's metadata. Nothing is stored.
  6. DocFlow. At checkout, asks Payment for an order at $5.00.
  7. Payment. Tells DocFlow the order is paid (payment.order.paid).
  8. DocFlow. Marks the document paid, asks Delivery for the email, and unlocks downloads.

Words used here

Process record
DocFlow's one row per invoice: the IDs of its parts in each service, and its status.
Reference
docflow:{document_id}: how DocFlow labels its jobs, tasks, orders and messages in the services.
CSV injection
A cell starting with =, +, - or @ can run as a formula in a spreadsheet; such cells are prefixed with '.

Quick start

These examples work once the service is built and deployed.

1. The CSV's columns

One row per line item, invoice columns repeated on each row: document_id, vendor_name, vendor_address, vendor_tax_id, invoice_number, invoice_date, due_date, bill_to_name, bill_to_address, currency, subtotal, tax_total, total, payment_terms, line_number, line_description, line_quantity, line_unit_price, line_amount. An invoice with no line items gives one row with the line columns empty.

document_id,vendor_name,…,line_number,line_description,line_quantity,line_unit_price,line_amount

2. Unlock only when paid

Every download checks the order on the server.

const { order } = await payment.get(`/orders/${doc.order_id}`);
if (order.status !== "paid") return problem(402, "payment_required");

Configuration

Environment variables on the service's own deployment. Secrets are never committed.

DOCFLOW_DATABASE_URLsecret
Neon connection string for the docflow_service role
DOCFLOW_PRICE_CENTS
500
DOCFLOW_CLIENT_SECRETsecret
DocFlow's client secret for Identity's POST /token, to get delegated tokens (Service access)
EVENT_ROUTES
Not needed: DocFlow emits no events. It is the target of docflow: routes in every service.
EVENTS_SIGNING_KEYsecret
32 random bytes, base64

Open questions

  • Decided by Nikhil on 17 Nov 2026 (ARCHITECTURE.md §12.8, #45): results are built on demand from Review's data and never stored; corrections are allowed after review and after payment; the JSON Schema is a file in the repository (schemas/invoice-v1.json), and serving it at a public address is nice to have, not required.
  • Returning a generated result directly (a few kilobytes) instead of through a storage link is a narrow exception to 'files never pass through the API', which is about stored files. Story DOCFLOW-V1-E7-02 AC1 is changed to match.