From COBOL to GPT: A Three-Stage Architecture Pattern Guide for Connecting Legacy Systems and LLMs
"Our company's core business logic lives on a COBOL mainframe. We want to introduce a modern LLM to automate customer inquiries—but how do we connect these two worlds?"
If you have asked that question, you are already standing at the intersection of the enterprise's most valuable asset (core business logic) and its hottest technology trend (generative AI).
Reality, however, is unforgiving. Between the mainframe's tangled transaction code, decades of accumulated XML-based data formats, and the clean JSON API calls that modern LLMs expect, there is a massive wall of time. Closing that gap is the central challenge of enterprise AI architecture.
This article is not a recitation of abstract concepts. To solve the legacy-to-LLM integration problem that so many IT architects face, it presents a practically applicable three-stage architecture pattern (blueprint). Once you understand this roadmap, you can accelerate AI innovation without fearing technical debt.
🧱 Stage 1: Data Extraction and Standardization (The Extraction Layer)
The first problem to solve is the shape of the data. LLMs understand text best, but legacy system data often exists only as byte streams or fixed field orders.
The Legacy Data Dilemma: Structured, Unstructured, and Semi-Structured
Legacy data typically appears in these forms.
- Structured: Database tables (but access methods are often complex).
- Semi-structured: XML, JSON (but schemas are highly complex or inconsistent).
- Unstructured: Historical transaction log files, scanned documents (OCR required).
The goal of Stage 1 is to transform this data into a standardized schema that an LLM can understand.
💡 Solution Pattern: API Gateway and Transformation Layer
The core principle of this stage is no direct access. Wiring an LLM straight into legacy core logic seriously threatens system stability. Instead, we must put a safe gateway in front of it.
- API Gateway role: Accepts external requests and converts them into a form the legacy system understands (for example, a specific legacy API calling convention).
- Transformation Layer: This layer is the intelligent translator. For instance, it takes a
CUST_IDfield coming from COBOL and a<CustomerID>field coming from XML and maps both to a unified internal JSON schema field namedcustomer_uuid.
graph LR
A[외부 요청 (LLM/UI)] --> B(API Gateway);
B --> C{Transformation Layer};
C --> D[레거시 시스템 (COBOL/DB)];
D --> C;
C --> E[표준화된 JSON 응답];Core technology stack recommendation: Use an API Gateway (Kong, Apigee) and a message queue (Kafka, RabbitMQ) to guarantee asynchronous data processing.
⚙️ Stage 2: Building an Intelligent Intermediary (The Orchestration Layer)
Once data is extracted and standardized, you must control the flow of requests. LLMs are excellent at reasoning about what to do, but they have no authority to actually execute anything.
The orchestration layer fills that gap. This layer acts as the conductor between the LLM and the legacy system.
🔍 Applying a Legacy-Friendly Version of Function Calling
Modern LLMs can invoke external APIs through Function Calling. We need to reinterpret that idea for a legacy environment.
When the orchestration layer receives the LLM's output, it concludes, "The user asked question A, so I should call the get_customer_status(customer_uuid) function that we standardized in Stage 1," and then it runs that function.
⚠️ Warning: Direct Connection (Bad) vs. Via Orchestration Layer (Good)
| Category | Direct Connection (Bad Practice) | Via Orchestration Layer (Good Practice) |
|---|---|---|
| Implementation | Embed legacy API call logic directly in the LLM prompt | LLM $\rightarrow$ Orchestrator $\rightarrow$ API Gateway $\rightarrow$ Legacy |
| Stability | Very low. A small LLM error can bring down the entire system. | Very high. Every call goes through a controlled gateway. |
| Debugging | Nearly impossible. | Straightforward. Logs can be traced at each stage (request, transformation, execution). |
| Security/Governance | Weak. High risk of exposing sensitive information. | Strong. Access control (RBAC) and transaction validation are possible. |
Core technology stack recommendation: Use LLM frameworks (LangChain, LlamaIndex) and a workflow engine (Temporal, Apache Airflow) to define the sequence and exception handling of complex business logic in code.
🧠 Stage 3: Maximizing LLM Value (The Intelligence Layer)
With data standardized and system call flows under control, it is time for the LLM to show its true value. It should go beyond simply answering "What is the customer number?" and address why and so what should we do next.
The heart of this stage is applying the RAG (Retrieval-Augmented Generation) pattern to the legacy knowledge base.
📚 Scenario: Generating Answers from Legacy Manuals
Suppose a customer asks, "What business logic does this abnormal transaction log from last month (XML attached) represent?"
- Retrieval: The system analyzes the attached log and searches hundreds of pages of internally stored operations manuals (PDF, Wiki) for related keywords and patterns.
- Augmentation: It pulls the retrieved manual clauses (Context) and attaches them to the prompt together with the user's question.
- Generation: Based on this [question + manual clauses], the LLM produces an evidence-based answer such as, "This log should be processed according to section 3.2.1 of the manual, and an appeal to the responsible department is required."
This process is the core mechanism that prevents LLM hallucination and delivers grounded answers.
🚀 Summary: Three-Stage Data Flow
| Stage | Goal | Core Technologies | Output |
|---|---|---|---|
| 1. Data Preparation (Ingestion) | Structure unstructured/legacy data | ETL, OCR, vector embeddings | Searchable knowledge base (Vector DB) |
| 2. Logic Execution (Orchestration) | Execute complex business logic | LLM Agent, Function Calling | Extracted data fragments (Context) |
| 3. Response Generation (Generation) | Generate evidence-based final answers | RAG (Retrieval-Augmented Generation) | User-friendly, accurate answers |
Organically connecting these three stages is precisely the role of the AI agent, and that is the key to successfully integrating AI with legacy systems.
Nodelog는 모든 콘텐츠의 내용과 출처를 공개 전에 검토합니다. 환경(OS·버전)에 따라 결과가 달라질 수 있는 기술 정보는 공식 문서와 함께 확인하며, 검토 기준과 정정 원칙은 편집 정책에서 안내합니다. 오류를 발견하시면 이메일로 제보해 주세요 — 확인 후 신속히 정정합니다.
Comments
Be the first to comment.