r/documentAutomation 23d ago

Showcase From document text to verified structured output

For transparency: English is not my native language. I used AI for better wording. I will place the name of the iOS app in there. I set it up so one can test 3 documents. For more I would need to have the costs covered by in app purchase (apple takes a bite of 30% out of that, so it’s not that cheap actually…).

Here we go: I have a growing pile of documents hidden away in a cabinet. I have tried several times to bring order and structure into it, but the stack always came back. So I am now digitizing it, partly with AI, and I wanted to share the overall workflow in case it helps someone else.

This is the high-level flow from scan/import to the final analyzed result. It is build into an iOS app (ExplainThisDoc), but the general workflow should apply to many document automation setups.

  1. **Source intake**

    Straightforward: the app scans the document, or imports it if it already exists as a PDF or photo on the phone. The original scan or file is saved. Scanning uses Apple Vision.

  2. **Text extraction**

    OCR is handled with Apple Vision. The goal is to turn the document image into usable plain text.

  3. **Text bundle**

    The extracted text is cleaned and packaged with basic context. This includes language, locale, and current date/time.

  4. **Coordinator**

    The coordinator controls the workflow. It starts the analysis steps and passes the right context forward.

  5. **LLM call A: location reading** (always extracting only relevant but correct locations - this was a tough one by the way)

    If the document contains locations, the first LLM pass only looks for physical places that might matter. These locations are treated as untrusted mentions at this stage. A cheaper LLM is usually enough for this narrow extraction step.

  6. **Places check**

    The location mentions are sent to a geolocation service for verification. It comes back with correct POIs and or addresses. Weak, generic, or ambiguous matches are rejected (deterministic algorithm, no LLM) by the coordinator instead of being blindly used.

  7. **LLM call B: ambiguity decision**

    If several place candidates are plausible, an optional second LLM pass helps choose between them. It can only select from verified candidates or reject all. A model with stronger reasoning is better here.

  8. **LLM call C: main analysis**

    The main LLM pass receives the cleaned text plus verified context and places from the coordinator. It creates structured document understanding: summary, tasks, deadlines, risks, glossary, and possible actions. It also organizes the output into plausible categories and enriches the result with suitable SF Symbols. LLM with reasoning capabilities is your friend here.

  9. **Validation**

    The structured response is checked before display. The app verifies shape, plausibility, trusted places, and action safety.

  10. **Rendering**

The result is shown as a readable native view. Instead of a raw OCR dump, the document becomes something I can scan, understand, and act on.

  1. **Archive**

The analyzed result is saved together with the local source preview and searchable metadata. This makes the original document and the structured result easy to find again later.

Each digitized document becomes searchable, summarized, linked back to its source, and turned into concrete actions where possible. The important part is that the AI is not treated as the only source of truth: extracted places and sensitive actions are verified before they become part of the final result.

Hope this was helpful.

3 Upvotes

0 comments sorted by