# skn29teacher/ai4_section02 architecture

> Architecture diagram of the GitHub repository skn29teacher/ai4_section02, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/skn29teacher/ai4_section02
- Repository: https://github.com/skn29teacher/ai4_section02

## Overview

This repository is a Korean-language, hands-on curriculum for building single-agent reasoning and AI orchestration systems, rather than one deployable application. Its examples progress from prompting and structured output through tool use and routing, then to memory, vector search, hybrid RAG, and evaluation. The graph highlights the principal integrated examples and the README’s major capability areas. Many lesson files were not sampled, so their internal calls are omitted; the graph represents them as independent labs where appropriate.

Main entry points: [`U2-09-Tool-Routing/s6_hybrid_conditional_router.py`](https://github.com/skn29teacher/ai4_section02/blob/main/U2-09-Tool-Routing/s6_hybrid_conditional_router.py) (Hybrid router), [`CoT_ReAct_KDT_8Sessions/travel_mvp/planner.py`](https://github.com/skn29teacher/ai4_section02/blob/main/CoT_ReAct_KDT_8Sessions/travel_mvp/planner.py) (Travel planner), [`U2_13_RAGAS/s5_hybrid_rag_pipeline.py`](https://github.com/skn29teacher/ai4_section02/blob/main/U2_13_RAGAS/s5_hybrid_rag_pipeline.py) (Hybrid RAG), [`agent_orchestration_mvp/main.py`](https://github.com/skn29teacher/ai4_section02/blob/main/agent_orchestration_mvp/main.py) (Data-query orchestrator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_reasoning["Reasoning and routing"]
  node_structured["Structured output<br/>[main.py]"]
  node_injection["Injection defense"]
  node_routingrules["Rule-based routing"]
  node_routingintent["Intent routing"]
  node_routingbranches["Route branches"]
  node_hybridrouter["Hybrid router"]
end

subgraph group_tools["Tools and integrations"]
  node_functionjson["Function calling"]
  node_dynamictools["Dynamic tool binding"]
  node_mcp["MCP examples"]
  node_multitool["Subway tool agent"]
  node_subwaycache["Arrival cache"]
  node_routingbackend["Mock API tools"]
end

subgraph group_knowledge["Memory and RAG"]
  node_embeddings["Embedding search"]
  node_sessionmemory["Session memory"]
  node_pgschema[("Hybrid KB schema")]
  node_ingest["KorQuAD ingestion"]
  node_search["Keyword/vector search"]
  node_fusion["RRF fusion"]
  node_rag["Hybrid RAG"]
  node_ragas["RAG evaluation"]
end

subgraph group_products["Applied examples"]
  node_orchestration["Data-query orchestrator<br/>[main.py]"]
  node_intentanalysis["Intent analysis<br/>[intent_analysis.py]"]
  node_customtools["Custom tools<br/>[custom_tools.py]"]
  node_travelintent["Travel intent parsing<br/>[intent.py]"]
  node_travelmodels["Travel domain models<br/>[models.py]"]
  node_travelplanner["Travel planner<br/>[planner.py]"]
  node_travelproviders["Travel providers<br/>[providers.py]"]
  node_catalogpipeline["Product QA pipeline<br/>[pipeline.py]"]
end

node_learner(("Learner"))

node_hybridrouter -->|"checks rules"| node_routingrules
node_hybridrouter -->|"classifies intent"| node_routingintent
node_hybridrouter -->|"starts API"| node_routingbackend
node_hybridrouter -->|"dispatches routes"| node_routingbranches
node_ingest -->|"initializes schema"| node_pgschema
node_rag -->|"retrieves contexts"| node_search
node_rag -->|"runs hybrid search"| node_fusion
node_ragas -->|"evaluates output"| node_rag
node_orchestration -->|"analyzes intent"| node_intentanalysis
node_orchestration -->|"executes tools"| node_customtools
node_travelplanner -->|"parses request"| node_travelintent
node_travelplanner -->|"uses domain types"| node_travelmodels
node_travelplanner -->|"queries providers"| node_travelproviders
node_catalogpipeline -.->|"uses structured output"| node_structured

click node_structured "https://github.com/skn29teacher/ai4_section02/blob/main/U2-03_Structured_Output/main.py"
click node_injection "https://github.com/skn29teacher/ai4_section02/tree/main/U2-04_Prompt-Injection_LangSmith"
click node_functionjson "https://github.com/skn29teacher/ai4_section02/tree/main/U2-05_FunctionCallingJson"
click node_dynamictools "https://github.com/skn29teacher/ai4_section02/tree/main/U2-06_LLM%EB%B0%94%EC%9D%B8%EB%94%A9_%EB%8F%99%EC%A0%81%ED%95%A8%EC%88%98%ED%98%B8%EC%B6%9C"
click node_mcp "https://github.com/skn29teacher/ai4_section02/tree/main/U2-07_MCP"
click node_multitool "https://github.com/skn29teacher/ai4_section02/blob/main/U2-08-Multi-Tool-%EB%8B%A8%EC%9D%BC%EC%97%90%EC%9D%B4%EC%A0%84%ED%8A%B8/mini_prj/seoul_subway_multi_tool_agent.py"
click node_subwaycache "https://github.com/skn29teacher/ai4_section02/blob/main/U2-08-Multi-Tool-%EB%8B%A8%EC%9D%BC%EC%97%90%EC%9D%B4%EC%A0%84%ED%8A%B8/mini_prj/subway_arrival_cache.py"
click node_routingrules "https://github.com/skn29teacher/ai4_section02/blob/main/U2-09-Tool-Routing/s2_rule_based_router.py"
click node_routingintent "https://github.com/skn29teacher/ai4_section02/blob/main/U2-09-Tool-Routing/s3_llm_intent_router.py"
click node_routingbackend "https://github.com/skn29teacher/ai4_section02/blob/main/U2-09-Tool-Routing/s4_backend_and_tools.py"
click node_routingbranches "https://github.com/skn29teacher/ai4_section02/blob/main/U2-09-Tool-Routing/s5_branch_sub_piplelines.py"
click node_hybridrouter "https://github.com/skn29teacher/ai4_section02/blob/main/U2-09-Tool-Routing/s6_hybrid_conditional_router.py"
click node_embeddings "https://github.com/skn29teacher/ai4_section02/tree/main/U2-10-TextEmbedding_FAISS"
click node_sessionmemory "https://github.com/skn29teacher/ai4_section02/tree/main/U2-11-Session-Memory"
click node_pgschema "https://github.com/skn29teacher/ai4_section02/blob/main/U2_13_RAGAS/s1_hybrid_schema_and_indexes.py"
click node_ingest "https://github.com/skn29teacher/ai4_section02/blob/main/U2_13_RAGAS/s2_korquad_ingest_for_hybrid.py"
click node_search "https://github.com/skn29teacher/ai4_section02/blob/main/U2_13_RAGAS/s3_keyword_vs_vector_search.py"
click node_fusion "https://github.com/skn29teacher/ai4_section02/blob/main/U2_13_RAGAS/s4_hybrid_rrf_and_weighted_fusion.py"
click node_rag "https://github.com/skn29teacher/ai4_section02/blob/main/U2_13_RAGAS/s5_hybrid_rag_pipeline.py"
click node_ragas "https://github.com/skn29teacher/ai4_section02/blob/main/U2_13_RAGAS/s6_ragas_v04_core_metrics.py"
click node_orchestration "https://github.com/skn29teacher/ai4_section02/blob/main/agent_orchestration_mvp/main.py"
click node_intentanalysis "https://github.com/skn29teacher/ai4_section02/blob/main/agent_orchestration_mvp/intent_analysis.py"
click node_customtools "https://github.com/skn29teacher/ai4_section02/blob/main/agent_orchestration_mvp/custom_tools.py"
click node_travelintent "https://github.com/skn29teacher/ai4_section02/blob/main/CoT_ReAct_KDT_8Sessions/travel_mvp/intent.py"
click node_travelmodels "https://github.com/skn29teacher/ai4_section02/blob/main/CoT_ReAct_KDT_8Sessions/travel_mvp/models.py"
click node_travelplanner "https://github.com/skn29teacher/ai4_section02/blob/main/CoT_ReAct_KDT_8Sessions/travel_mvp/planner.py"
click node_travelproviders "https://github.com/skn29teacher/ai4_section02/blob/main/CoT_ReAct_KDT_8Sessions/travel_mvp/providers.py"
click node_catalogpipeline "https://github.com/skn29teacher/ai4_section02/blob/main/LangChain_20261117_DataEdition/app/pipeline.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_structured,node_injection,node_routingrules,node_routingintent,node_routingbranches,node_hybridrouter toneBlue
class node_functionjson,node_dynamictools,node_mcp,node_multitool,node_subwaycache,node_routingbackend toneAmber
class node_embeddings,node_sessionmemory,node_pgschema,node_ingest,node_search,node_fusion,node_rag,node_ragas toneMint
class node_orchestration,node_intentanalysis,node_customtools,node_travelintent,node_travelmodels,node_travelplanner,node_travelproviders,node_catalogpipeline toneRose
class node_learner toneIndigo
```

## Components

### Reasoning and routing

- [Structured output](https://github.com/skn29teacher/ai4_section02/blob/main/U2-03_Structured_Output/main.py): `U2-03_Structured_Output/main.py`
- [Injection defense](https://github.com/skn29teacher/ai4_section02/tree/main/U2-04_Prompt-Injection_LangSmith): `U2-04_Prompt-Injection_LangSmith`
- [Rule-based routing](https://github.com/skn29teacher/ai4_section02/blob/main/U2-09-Tool-Routing/s2_rule_based_router.py): `U2-09-Tool-Routing/s2_rule_based_router.py`
- [Intent routing](https://github.com/skn29teacher/ai4_section02/blob/main/U2-09-Tool-Routing/s3_llm_intent_router.py): `U2-09-Tool-Routing/s3_llm_intent_router.py`
- [Route branches](https://github.com/skn29teacher/ai4_section02/blob/main/U2-09-Tool-Routing/s5_branch_sub_piplelines.py): `U2-09-Tool-Routing/s5_branch_sub_piplelines.py`
- [Hybrid router](https://github.com/skn29teacher/ai4_section02/blob/main/U2-09-Tool-Routing/s6_hybrid_conditional_router.py): `U2-09-Tool-Routing/s6_hybrid_conditional_router.py`

### Tools and integrations

- [Function calling](https://github.com/skn29teacher/ai4_section02/tree/main/U2-05_FunctionCallingJson): `U2-05_FunctionCallingJson`
- [Dynamic tool binding](https://github.com/skn29teacher/ai4_section02/tree/main/U2-06_LLM%EB%B0%94%EC%9D%B8%EB%94%A9_%EB%8F%99%EC%A0%81%ED%95%A8%EC%88%98%ED%98%B8%EC%B6%9C): `U2-06_LLM바인딩_동적함수호출`
- [MCP examples](https://github.com/skn29teacher/ai4_section02/tree/main/U2-07_MCP): `U2-07_MCP`
- [Subway tool agent](https://github.com/skn29teacher/ai4_section02/blob/main/U2-08-Multi-Tool-%EB%8B%A8%EC%9D%BC%EC%97%90%EC%9D%B4%EC%A0%84%ED%8A%B8/mini_prj/seoul_subway_multi_tool_agent.py): `U2-08-Multi-Tool-단일에이전트/mini_prj/seoul_subway_multi_tool_agent.py`
- [Arrival cache](https://github.com/skn29teacher/ai4_section02/blob/main/U2-08-Multi-Tool-%EB%8B%A8%EC%9D%BC%EC%97%90%EC%9D%B4%EC%A0%84%ED%8A%B8/mini_prj/subway_arrival_cache.py): `U2-08-Multi-Tool-단일에이전트/mini_prj/subway_arrival_cache.py`
- [Mock API tools](https://github.com/skn29teacher/ai4_section02/blob/main/U2-09-Tool-Routing/s4_backend_and_tools.py): `U2-09-Tool-Routing/s4_backend_and_tools.py`

### Memory and RAG

- [Embedding search](https://github.com/skn29teacher/ai4_section02/tree/main/U2-10-TextEmbedding_FAISS): `U2-10-TextEmbedding_FAISS`
- [Session memory](https://github.com/skn29teacher/ai4_section02/tree/main/U2-11-Session-Memory): `U2-11-Session-Memory`
- [Hybrid KB schema](https://github.com/skn29teacher/ai4_section02/blob/main/U2_13_RAGAS/s1_hybrid_schema_and_indexes.py): `U2_13_RAGAS/s1_hybrid_schema_and_indexes.py`
- [KorQuAD ingestion](https://github.com/skn29teacher/ai4_section02/blob/main/U2_13_RAGAS/s2_korquad_ingest_for_hybrid.py): `U2_13_RAGAS/s2_korquad_ingest_for_hybrid.py`
- [Keyword/vector search](https://github.com/skn29teacher/ai4_section02/blob/main/U2_13_RAGAS/s3_keyword_vs_vector_search.py): `U2_13_RAGAS/s3_keyword_vs_vector_search.py`
- [RRF fusion](https://github.com/skn29teacher/ai4_section02/blob/main/U2_13_RAGAS/s4_hybrid_rrf_and_weighted_fusion.py): `U2_13_RAGAS/s4_hybrid_rrf_and_weighted_fusion.py`
- [Hybrid RAG](https://github.com/skn29teacher/ai4_section02/blob/main/U2_13_RAGAS/s5_hybrid_rag_pipeline.py): `U2_13_RAGAS/s5_hybrid_rag_pipeline.py`
- [RAG evaluation](https://github.com/skn29teacher/ai4_section02/blob/main/U2_13_RAGAS/s6_ragas_v04_core_metrics.py): `U2_13_RAGAS/s6_ragas_v04_core_metrics.py`

### Applied examples

- [Data-query orchestrator](https://github.com/skn29teacher/ai4_section02/blob/main/agent_orchestration_mvp/main.py): `agent_orchestration_mvp/main.py`
- [Intent analysis](https://github.com/skn29teacher/ai4_section02/blob/main/agent_orchestration_mvp/intent_analysis.py): `agent_orchestration_mvp/intent_analysis.py`
- [Custom tools](https://github.com/skn29teacher/ai4_section02/blob/main/agent_orchestration_mvp/custom_tools.py): `agent_orchestration_mvp/custom_tools.py`
- [Travel intent parsing](https://github.com/skn29teacher/ai4_section02/blob/main/CoT_ReAct_KDT_8Sessions/travel_mvp/intent.py): `CoT_ReAct_KDT_8Sessions/travel_mvp/intent.py`
- [Travel domain models](https://github.com/skn29teacher/ai4_section02/blob/main/CoT_ReAct_KDT_8Sessions/travel_mvp/models.py): `CoT_ReAct_KDT_8Sessions/travel_mvp/models.py`
- [Travel planner](https://github.com/skn29teacher/ai4_section02/blob/main/CoT_ReAct_KDT_8Sessions/travel_mvp/planner.py): `CoT_ReAct_KDT_8Sessions/travel_mvp/planner.py`
- [Travel providers](https://github.com/skn29teacher/ai4_section02/blob/main/CoT_ReAct_KDT_8Sessions/travel_mvp/providers.py): `CoT_ReAct_KDT_8Sessions/travel_mvp/providers.py`
- [Product QA pipeline](https://github.com/skn29teacher/ai4_section02/blob/main/LangChain_20261117_DataEdition/app/pipeline.py): `LangChain_20261117_DataEdition/app/pipeline.py`

### Other components

- **Learner**

## Connections

- Hybrid router → Rule-based routing: checks rules (evidence: `U2-09-Tool-Routing/s6_hybrid_conditional_router.py`)
- Hybrid router → Intent routing: classifies intent (evidence: `U2-09-Tool-Routing/s6_hybrid_conditional_router.py`)
- Hybrid router → Mock API tools: starts API (evidence: `U2-09-Tool-Routing/s6_hybrid_conditional_router.py`)
- Hybrid router → Route branches: dispatches routes (evidence: `U2-09-Tool-Routing/s6_hybrid_conditional_router.py`)
- KorQuAD ingestion → Hybrid KB schema: initializes schema (evidence: `U2_13_RAGAS/s2_korquad_ingest_for_hybrid.py`)
- Hybrid RAG → Keyword/vector search: retrieves contexts (evidence: `U2_13_RAGAS/s5_hybrid_rag_pipeline.py`)
- Hybrid RAG → RRF fusion: runs hybrid search (evidence: `U2_13_RAGAS/s5_hybrid_rag_pipeline.py`)
- RAG evaluation → Hybrid RAG: evaluates output (evidence: `U2_13_RAGAS/s6_ragas_v04_core_metrics.py`)
- Data-query orchestrator → Intent analysis: analyzes intent (evidence: `agent_orchestration_mvp/main.py`)
- Data-query orchestrator → Custom tools: executes tools (evidence: `agent_orchestration_mvp/main.py`)
- Travel planner → Travel intent parsing: parses request (evidence: `CoT_ReAct_KDT_8Sessions/travel_mvp/planner.py`)
- Travel planner → Travel domain models: uses domain types (evidence: `CoT_ReAct_KDT_8Sessions/travel_mvp/planner.py`)
- Travel planner → Travel providers: queries providers (evidence: `CoT_ReAct_KDT_8Sessions/travel_mvp/planner.py`)
- Product QA pipeline → Structured output: uses structured output
