Building an Enterprise RAG Knowledge Base: Combining an Orchestration Framework with a Deep Document Parsing Engine

    Enterprises building RAG (Retrieval-Augmented Generation) knowledge bases often face a choice between easy-to-use application orchestration frameworks and powerful document parsing engines. This article explains why you don't have to pick just one: it walks through a hybrid architecture that uses an orchestration framework as the main application layer while integrating a deep document parsing engine as an independent retrieval service via API. It covers the core design of the architecture, why knowledge base routing matters, practical container deployment tips including port conflict resolution, and a selection guide to help you decide the right approach based on your document complexity and workflow complexity.

    1. The Problem: A Dilemma in Enterprise Knowledge Base Q&A

    When implementing a RAG knowledge base, engineering teams typically face a classic architectural decision: should you choose an out-of-the-box, user-friendly application development framework that excels at workflow orchestration, or a retrieval engine built for deep document parsing and optimized for unstructured data?

    These two categories of open-source solutions represent different strengths of the RAG technology stack:

    • Application orchestration frameworks shine in usability and application-layer capabilities: visual workflows, agent components, multi-model scheduling, and knowledge base routing. Business users can quickly build a Q&A prototype, and developers can extend the system through modular design. However, these frameworks often struggle with complex documents such as scanned files, cross-page tables, and two-column PDF layouts.
    • Deep document parsing engines excel at fine-grained processing of raw data: built-in OCR, splitting templates tailored to different document types, and layout structure recognition. They prevent “garbage in, garbage out” problems at the parsing stage, but their application-layer capabilities are comparatively weak—workflow orchestration, agent collaboration, and external tool integrations are less flexible than in orchestration frameworks.

    In practice, the choice is not binary. The real question is: how do you combine them so that each one’s strengths operate within the same pipeline?

    2. The Core Idea Behind the Hybrid Architecture

    A mature hybrid approach works like this: use the application orchestration framework as the primary framework, responsible for user interaction, workflow orchestration, agent scheduling, and multi-model management; at the same time, deploy the document parsing engine as an independent retrieval service, integrated into the main framework via API.

    The overall pipeline looks like this:

    1. The user submits a question through the main framework’s chat interface or a business system.
    2. The orchestration layer’s workflow receives the request and performs preprocessing such as intent recognition, query rewriting, and routing.
    3. It calls the retrieval API exposed by the document parsing engine over HTTP to perform vector retrieval and reranking.
    4. The retrieval results are returned to the orchestration layer, assembled with prompt templates, and sent to the LLM to generate an answer.
    5. The orchestration layer handles post-processing, citation annotation, and logging.

    This architecture delivers three immediate benefits:

    • Complementary capabilities: You keep workflow orchestration and agent capabilities for complex business processes such as multi-turn conversations, conditional branches, and human review, while also gaining fine-grained document parsing—especially for difficult cases like PDFs, scanned files, and tables.
    • Separated responsibilities: The parsing service and the orchestration service are deployed and upgraded independently. Iterations to the parsing model don’t affect business workflow definitions, and vice versa.
    • Extensibility: API-based integration means you can later add other open-source retrieval frameworks or vector databases for specific business scenarios without redesigning the architecture.

    3. Why Knowledge Base Routing Deserves Special Attention

    In enterprise environments, there is rarely just one knowledge base—they are typically divided by department or business line. At that point, “cross-knowledge-base retrieval” becomes a key selection criterion.

    Some orchestration frameworks have built-in automatic knowledge base routing: the system determines, based on the semantics of the user’s question, which knowledge base to retrieve from—or even queries multiple knowledge bases in parallel and merges the results. In contrast, engines focused on document parsing usually take a “single-database” view by default, leaving multi-base scheduling to the application layer.

    This further validates the value of the hybrid architecture: the parsing engine focuses on “reading documents well,” while the orchestration framework focuses on “scheduling retrieval well”—together covering the weak points at different stages of the RAG pipeline.

    4. Deployment in Practice: Container Port Planning

    Both types of frameworks officially recommend containerized deployment. When they run on the same host machine, port conflicts are the first problem you need to solve.

    4.1 Understanding Port Mapping Syntax

    The port mapping format in container orchestration configs is A:B:

    • A is the host port—the port used for external access.
    • B is the container’s internal port—the port the service process actually listens on.

    For example, 80:80 maps the host’s port 80 to the container’s port 80. Typically, port 80 inside the container handles HTTP requests, and port 443 handles HTTPS.

    4.2 Principles for Resolving Conflicts

    If both services try to claim the host’s port 80, the second service to start will simply fail. The recommended approach:

    • Keep the container’s internal port unchanged (the service’s listening logic doesn’t need modification).
    • Change only the host port to an unused high-numbered port.

    For example, change 80:80 to 8080:80. External access now goes through port 8080, while the service inside the container still listens on 80. Similarly, 443:443 can become 8443:443.

    1. # Before (conflicts with the orchestration framework's ports)
    2. ports:
    3. - "80:80"
    4. - "443:443"
    5. # After (host ports staggered, container ports preserved)
    6. ports:
    7. - "8080:80"
    8. - "8443:443"

    After making this change, check two things: first, update the parsing engine’s external API address configuration so the orchestration framework calls the new host port; second, if there is a reverse proxy or gateway layer, update the upstream forwarding rules accordingly.

    4.3 Other Engineering Considerations

    • Network connectivity: If both services are on the same container network, the orchestration framework can access the parsing engine directly via service name plus container port, avoiding the host port layer—lower latency and more secure.
    • Secret management: The parsing engine’s API key should be injected via environment variables, not hard-coded in workflow configurations.
    • Resource isolation: Deep document parsing (especially OCR) is CPU-intensive. Set separate resource limits for the parsing service in your container orchestration config so peak load doesn’t drag down the orchestration service.

    5. A Selection Decision Guide

    A simple decision path:

    • Complex document formats dominate (scanned files, tables, mixed text-and-image layouts) and Q&A accuracy is the core KPI: prioritize parsing quality—make the parsing engine the centerpiece and keep the orchestration layer lightweight.
    • Complex business workflows dominate (multi-agent collaboration, approval flows, integrations with multiple systems) with relatively well-structured documents: make the orchestration framework primary; adequate parsing capability is sufficient.
    • Both are present (the reality for most mid-to-large enterprises): adopt the hybrid architecture described in this article—an orchestration framework as the main application, with the parsing engine integrated via API.

    Depending on the scenario, you can also bring in other general-purpose components to fill gaps, such as dedicated document loading and indexing frameworks, graph-based retrieval augmentation, or a standalone vector database. As long as the architecture stays “componentized and API-driven,” you can replace any part at low cost as your business evolves.

    6. Conclusion

    The hard part of implementing an enterprise RAG knowledge base is never “which framework to choose”—it’s understanding how heavy your document complexity and workflow complexity are, and assembling technical components accordingly. The hybrid architecture of an orchestration framework plus a parsing engine offers a balance point validated by extensive practice: API-based integration preserves flexibility, separation of responsibilities ensures maintainability, and together they deliver both retrieval quality and business capability.