Hybrid Architecture for Enterprise Knowledge Base Q&A: Combining a Workflow Orchestration Platform with a Document Parsing Engine

    This article explains why a single framework rarely covers enterprise knowledge base Q&A requirements, and how to split the work between a workflow orchestration platform and a document parsing engine. It abstracts the capability boundaries of both, then walks through a layered hybrid design with a unified retrieval contract, port isolation and resource planning for containerized deployment, the offline ingestion and online Q&A pipelines, and evaluation, observability, and evolution practices. Readers will find interface definitions, deployment configuration, and integration code they can adapt.

    1. Background: Why a Single Framework Falls Short for Enterprise Requirements

    A common mistake in enterprise knowledge base Q&A is treating it as a matter of “picking one tool.” In practice, requirements usually span two distinct capability dimensions: deep understanding of complex documents, and orchestration of business processes with multi-model collaboration. The first concerns restoration accuracy for unstructured content such as scanned files, complex tables, and paragraphs that span pages. The second concerns engineering capabilities such as intent recognition, multi-turn dialogue, tool invocation, and human review checkpoints.

    The two capability areas rely on very different technology stacks. Document parsing focuses on layout analysis, optical character recognition, chunking strategies, and index construction. Process orchestration focuses on state machines, node scheduling, context passing, and integration with external tools. Forcing one framework to excel at both usually means a clear compromise on one side. A more pragmatic approach is layered decoupling: let the component that is good at orchestration act as the “brain,” let the component that is good at parsing act as the “senses,” and combine them through standard interfaces.

    2. Abstracting the Capability Boundaries of the Two Framework Types

    For a neutral discussion, the first type is referred to below as a “workflow orchestration platform” and the second as a “document parsing engine.”

    Typical characteristics of a workflow orchestration platform:

    • Low barrier to entry; a visual canvas is enough to build agents and task flows, so prototype validation cycles are short;
    • High modularity; nodes, tools, and model integrations are all replaceable, which makes secondary development easier;
    • Good ecosystem extensibility; external tools, function calls, and custom code nodes can be attached;
    • Cross-knowledge-base routing, automatically selecting the target base based on semantics;
    • The limitation is limited parsing depth for documents with complex layouts.

    Typical characteristics of a document parsing engine:

    • Strong layout and table restoration, with optical character recognition support for scanned and image-based documents;
    • Multiple built-in chunking templates that adapt to different layouts such as papers, contracts, and manuals;
    • Optimized for high throughput and low-latency retrieval, with a compact indexing and recall pipeline;
    • The limitation is weaker process orchestration, multi-model collaboration, and automatic cross-base routing.

    The conclusion is not either/or, but pushing capabilities down to where the bottleneck lies: parsing goes down to the underlying engine, orchestration stays in the upper platform.

    3. Overall Design of the Hybrid Architecture

    The recommended layered structure, from top to bottom: application layer (Q&A interface, embedding into business systems), orchestration layer (agents, workflows, tool nodes), retrieval service layer (the retrieval interface exposed by the document parsing engine), and data layer (raw file storage, vector index, metadata database).

    Three key design principles apply. First, the orchestration layer is unaware of the underlying index implementation and depends only on a unified retrieval contract. Second, document ingestion and online Q&A pipelines are separated; parsing and index rebuilding are offline tasks, which avoids blocking conversations. Third, all external calls have timeout, retry, and fallback strategies; when the retrieval service is unavailable, the system falls back to keyword retrieval or cached answers.

    A sketch of the unified retrieval contract:

    1. # The orchestration layer depends only on this contract; the underlying engine is replaceable
    2. class Retriever(Protocol):
    3. def retrieve(self, query: str, top_k: int = 8,
    4. kb_ids: list[str] | None = None,
    5. filters: dict | None = None) -> list[Chunk]: ...
    6. @dataclass
    7. class Chunk:
    8. text: str
    9. score: float
    10. source: str # document identifier
    11. page: int | None # page number/position, used for citation tracing
    12. metadata: dict

    4. Port Isolation and Resource Planning During Deployment

    Both types of components are commonly recommended for containerized deployment. When they coexist on the same machine, the most frequent failure is a port binding conflict. In a container orchestration file, the port mapping format is “host port:container port”; for example, 80:80 forwards host port 80 to container port 80, where port 80 inside the container usually serves plaintext HTTP requests and 443 serves encrypted HTTPS requests.

    The fix is to change only the host side and leave the container side unchanged, mapping the service that starts first to a non-default port:

    1. services:
    2. doc-engine:
    3. ports:
    4. - "8080:80" # host 8080 -> container 80
    5. - "8443:443"
    6. orchestrator:
    7. ports:
    8. - "3000:3000" # orchestration platform console

    If both services are exposed behind the same reverse proxy, route them by path prefix and let the proxy layer handle certificates and access control uniformly, so that neither service maintains its own TLS configuration. On the resource side, reserve more generous memory and temporary disk for the parsing engine, since optical character recognition and layout analysis are compute-intensive tasks. Deploying it on separate nodes from the orchestration service is recommended to prevent bulk ingestion from taking resources away from online Q&A.

    5. Integration: The Full Pipeline from Ingestion to Q&A

    Offline ingestion pipeline: file uploaded to object storage → parsing task triggered → layout analysis and character recognition → chunking by template and metadata generation → write to the vector index and metadata database → write back the document status. The state machine should include five states: pending parsing, parsing, indexing, available, and failed. Failed tasks enter a retry queue with the reason recorded, making it easier to determine whether the cause is file encryption, a blurry scan, or a chunking template mismatch.

    Online Q&A pipeline: intent recognition → decision on whether retrieval is needed → cross-base routing to select the target base → call the retrieval interface to fetch candidate chunks → reranking and deduplication → prompt assembly → model generation → citation tracing and sensitive word filtering → handoff to a human when necessary.

    Sample code for the orchestration layer calling the retrieval service:

    1. import os, requests
    2. RETRIEVE_URL = os.environ["RETRIEVE_ENDPOINT"] # injected by the deployment environment, not hardcoded
    3. def search(query: str, kb_ids: list[str], top_k: int = 8):
    4. resp = requests.post(
    5. f"{RETRIEVE_URL}/retrieval",
    6. json={"question": query, "kb_ids": kb_ids, "top_k": top_k},
    7. timeout=5,
    8. )
    9. resp.raise_for_status()
    10. return resp.json()["chunks"]
    11. def build_prompt(query: str, chunks: list[dict]) -> str:
    12. context = "\n".join(f"[{i+1}] {c['text']}" for i, c in enumerate(chunks))
    13. return (
    14. "Answer only from the material below. If the material is insufficient, "
    15. "state clearly that you cannot answer, and mark the citation numbers.\n"
    16. f"Material:\n{context}\n\nQuestion: {query}"
    17. )

    Three engineering details also matter. First, retrieval requests should carry tenant and permission identifiers, with row-level filtering on the server side to prevent unauthorized recall. Second, set chunk length and overlap windows; long tables should be kept whole rather than split row by row. Third, constraining the prompt to “no answer without evidence” can significantly reduce the hallucination rate.

    6. Evaluation, Observability, and Evolution

    Evaluation should happen at two levels. The retrieval layer focuses on recall rate, hit rate, and position bias, using a benchmark set of manually annotated question-answer pairs. The generation layer focuses on answer correctness, citation consistency, and refusal accuracy. Looking at the two sets of metrics separately is what makes it possible to tell whether the problem lies in parsing, recall, or generation.

    For observability, record a trace identifier, per-node latency, recalled chunk identifiers, and model version for each Q&A request. Send logs and metrics to a logging service and monitoring/alerting capability respectively, and configure alerts for items such as retrieval timeout rate and the backlog of failed tasks.

    On the evolution path, start with a single knowledge base and a single parsing template, validate the metrics, then extend to multi-base routing and a reranking model. If graph relationship reasoning is needed later, a graph-structured index can be introduced as a supplementary recall source, again connected through the unified retrieval contract so the orchestration layer stays unchanged. If reducing the cost of self-built deployment and operations is a goal, general-purpose capabilities such as container services, object storage, and managed vector retrieval on a cloud platform can be evaluated, keeping effort focused on parsing strategy and business orchestration, the two areas that create real differentiation.