Skip to content

Reference Architectures

Reference architectures cho thấy các layer kết hợp như thế nào trong hệ thống thật. Đây không phải product template. Đây là decision map: layer nào sở hữu trách nhiệm nào, framework nào nên lead và team thường overbuild ở đâu.

Architecture map

mermaid
flowchart TB
    A[Reference architecture choice] --> B[Team coding workflow]
    A --> C[RAG product feature]
    A --> D[Long-running agent app]
    A --> E[Internal agent platform]
    A --> F[Enterprise governed delivery]
    B --> B1[Spec/OpenSpec + harness + discipline]
    C --> C1[LangChain + RAG + evals]
    D --> D1[LangGraph + AI-DLC + tool gateway]
    E --> E1[Hermes + MCP + model router]
    F --> F1[AI-DLC + gates + audit + ops readiness]

Architecture 1: AI-assisted product engineering team

Stack khuyến nghị:

text
Spec Kit or OpenSpec + Codex/Claude/Hermes + Superpowers-style TDD + CI
LayerLựa chọnLý do
WorkflowSpec Kit cho feature lớn, OpenSpec cho lightweight changesgiữ intent và implementation aligned
HarnessCodex CLI, Claude Code hoặc Hermesthực hiện coding, terminal, repo operations
DisciplineSuperpowers-style TDD/reviewngăn agent code mà không có tests
VerificationCI tests và PR reviewbiến AI output thành engineering evidence bình thường

Dùng khi vấn đề chính là software delivery quality, không phải build production AI application.

Step-by-step:

  1. Định nghĩa khi nào change cần Spec Kit vs OpenSpec.
  2. Định nghĩa spec template tối thiểu với goals, non-goals, acceptance criteria và risks.
  3. Bắt buộc TDD hoặc test-first prompts cho behavior changes.
  4. Chỉ dùng harness để implement sau khi spec/change artifact được review.
  5. Bắt buộc CI và human PR review trước merge.

Architecture 2: Production RAG product feature

Stack khuyến nghị:

text
OpenSpec + LangChain + Data/RAG layer + evals/observability + CI eval gate
LayerLựa chọnLý do
Change controlOpenSpecproposal và spec delta nhẹ
AI app frameworkLangChainorchestration nhanh cho RAG và tools
Data layeringestion, parsing, chunking, vector/hybrid searchRAG quality phụ thuộc data pipeline
ObservabilityLangSmith, Langfuse, Phoenixtraces và evals cho retrieval/generation
CI gateretrieval và answer evalsngăn prompt/retriever/model regressions

Dùng cho chatbots, support assistants, documentation assistants hoặc knowledge search features.

Step-by-step:

  1. Định nghĩa allowed sources và data owners.
  2. Tạo golden dataset gồm user questions và expected evidence.
  3. Build RAG pipeline hẹp trước.
  4. Thêm citations và refusal behavior.
  5. Thêm traces và evals trước broad rollout.
  6. Thêm permission-aware retrieval trước khi dùng sensitive data.

Architecture 3: Long-running agent service

Stack khuyến nghị:

text
AI-DLC + LangGraph + tool gateway + evals + audit logs
LayerLựa chọnLý do
Delivery governanceAWS AI-DLCrisk, approval, NFR, audit
Runtime app frameworkLangGraphstateful graph, human-in-the-loop, long-running execution
ToolsTool gateway/MCP/OpenAPIexternal actions có kiểm soát
Evaluationnode evals và trajectory evalsverify state transitions và actions
Observabilitytraces và audit logsproduction debugging và accountability

Dùng khi AI system thực hiện multi-step work theo thời gian, cần memory/state hoặc có thể trigger external actions.

Step-by-step:

  1. Chạy AI-DLC inception cho risk, stakeholders, NFR và approval model.
  2. Thiết kế LangGraph state và node boundaries.
  3. Classify tools và actions theo risk.
  4. Gate write/destructive actions.
  5. Thêm node-level tests và full trajectory evals.
  6. Thêm traces, audit logs và rollback/runbook procedures.

Architecture 4: Internal agent platform with custom harness

Stack khuyến nghị:

text
Hermes + model router + MCP/tool gateway + OpenSpec + Superpowers-like skills
LayerLựa chọnLý do
Harness/runtimeHermesopen/customizable agent runtime
Model layermodel routerkiểm soát hosted và local models
Tool layerMCP/tool gatewaystandardized tool access và policy
WorkflowOpenSpeclightweight change artifacts
DisciplineSuperpowers-like skillsTDD, review, debugging, planning behavior

Dùng khi muốn sở hữu agent harness thay vì chỉ phụ thuộc managed coding CLIs.

Step-by-step:

  1. Định nghĩa vì sao Codex/Claude-style CLIs chưa đủ.
  2. Chọn model routes theo workload và data boundary.
  3. Thêm MCP/tool gateway trước khi expose internal systems.
  4. Pilot một repo với OpenSpec và tool set giới hạn.
  5. Thêm skills cho planning, TDD, review và debugging.
  6. Log tool calls và đo xem custom harness có cải thiện outcome không.

Architecture 5: Enterprise AI-DLC delivery system

Stack khuyến nghị:

text
AWS AI-DLC + Spec Kit/OpenSpec patterns + security governance + release readiness + observability
LayerLựa chọnLý do
LifecycleAWS AI-DLCgovern AI-driven delivery
RequirementsSpec Kit/OpenSpec conceptsacceptance criteria và change deltas rõ hơn
Securityrisk-tiered gatesngăn speed vượt accountability
Operationsrelease readiness và runbookslấp khoảng trống giữa construction và production
Observabilitytraces, CI, incident feedbackevidence cho production behavior

Dùng khi nhiều stakeholders, high-risk systems, regulated domains hoặc platform teams cần repeatable delivery governance.

Step-by-step:

  1. Định nghĩa risk tiers.
  2. Định nghĩa approval owners cho product, architecture, security, operations.
  3. Định nghĩa required artifacts theo tier.
  4. Dùng Spec Kit/OpenSpec patterns bên trong AI-DLC artifacts để tăng clarity.
  5. Thêm construction verification: tests, evals, security checks.
  6. Thêm operations verification: rollout, rollback, monitoring, incident feedback.

Cách chọn reference architecture

Vấn đề chínhChọn
Team muốn AI-assisted coding tốt hơnArchitecture 1
Product cần RAG hoặc knowledge assistantArchitecture 2
Product cần stateful autonomous workflowArchitecture 3
Platform team muốn custom open agent runtimeArchitecture 4
Enterprise cần audit, approvals, NFR, governanceArchitecture 5

Quy tắc kết hợp

Bắt đầu với một owner cho mỗi layer. Đừng kết hợp hai framework cùng claim một artifact trừ khi đã định nghĩa precedence rõ.

Ví dụ:

ArtifactOwner
Requirement specSpec Kit hoặc OpenSpec, không dùng cả hai cho cùng feature
Lifecycle approvalAI-DLC
Agent executionCodex/Claude/Hermes
AI app runtimeLangChain hoặc LangGraph
Tool permissionsTool gateway
Production proofEvals và observability

Built as a static bilingual AI engineering stack guide.