# hankookiniayo/ai_mini_project architecture

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

- Interactive diagram: https://gitdiagram.com/hankookiniayo/ai_mini_project
- Repository: https://github.com/hankookiniayo/ai_mini_project

## Overview

솔방울마켓 주문·배송 상담 에이전트입니다. 고객은 로그인한 뒤 주문·상품 또는 정책을 질문하고, 에이전트가 질문을 분류·계획해 MCP로 실제 쇼핑몰 데이터와 정책 근거를 조회한 다음 검증된 답변을 돌려줍니다. 주문 비교 분석, 하이브리드 정책 검색, 여러 LLM 백엔드와 세션 저장도 주요 기능입니다. 일부 API 경로와 MCP 내부 호출은 발췌에서 확인되지 않아, 관계는 README와 인용 가능한 소스 근거가 있는 경우만 표시했습니다.

Main entry points: [`agent/graph.py`](https://github.com/hankookiniayo/ai_mini_project/blob/main/agent/graph.py) (상담 그래프), [`server.py`](https://github.com/hankookiniayo/ai_mini_project/blob/main/server.py) (FastAPI·인증), [`mcp_server.py`](https://github.com/hankookiniayo/ai_mini_project/blob/main/mcp_server.py) (MCP 서비스), [`mcp_tools/policies.py`](https://github.com/hankookiniayo/ai_mini_project/blob/main/mcp_tools/policies.py) (정책 검색)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["고객 접점"]
  node_web["상담 화면<br/>[web_shop.html]"]
  node_api["FastAPI·인증<br/>[server.py]"]
  node_sessions[("대화 세션 저장<br/>[session_store.py]")]
end

subgraph group_agent["상담 에이전트"]
  node_supervisor["상담 그래프<br/>[graph.py]"]
  node_routing["분류·계획<br/>[planning.py]"]
  node_facts["근거 포맷<br/>[facts.py]"]
  node_validation["답변 검증<br/>[validators.py]"]
  node_llm["LLM 백엔드<br/>[fake_llm.py]"]
  node_mcp_client["MCP 클라이언트<br/>[mcp_client.py]"]
end

subgraph group_mcp["MCP 조회 서비스"]
  node_mcp_server["MCP 서비스<br/>[mcp_server.py]"]
  node_shop_tools["주문·상품 조회<br/>[shop.py]"]
  node_policy_search["정책 검색<br/>[policies.py]"]
  node_embeddings["임베딩<br/>[embeddings.py]"]
end

subgraph group_data["쇼핑몰 지식·데이터"]
  node_shop_repo["주문 저장소<br/>[shop_repo.py]"]
  node_shop_db[("쇼핑몰 데이터")]
  node_policy_docs["정책 문서"]
end

node_customer(("고객"))

node_customer -->|"질문 입력"| node_web
node_web -->|"API 요청"| node_api
node_api -->|"실행·스트리밍"| node_supervisor
node_api -->|"대화 이력 저장"| node_sessions
node_api -->|"화면 데이터 조회"| node_shop_tools
node_supervisor -->|"계획 보정"| node_routing
node_supervisor -->|"분류·답변 생성"| node_llm
node_supervisor -->|"MCP 조회 요청"| node_mcp_client
node_supervisor -->|"근거 구성"| node_facts
node_supervisor -->|"답변 검증"| node_validation
node_mcp_client -->|"도구 호출"| node_mcp_server
node_mcp_server -->|"도구 제공"| node_shop_tools
node_mcp_server -->|"검색 도구 제공"| node_policy_search
node_shop_tools -->|"저장소 조회"| node_shop_repo
node_shop_repo -->|"데이터 읽기"| node_shop_db
node_policy_search -->|"벡터 임베딩"| node_embeddings
node_policy_search -->|"정책 카탈로그 읽기"| node_policy_docs

click node_web "https://github.com/hankookiniayo/ai_mini_project/blob/main/web_shop.html"
click node_api "https://github.com/hankookiniayo/ai_mini_project/blob/main/server.py"
click node_sessions "https://github.com/hankookiniayo/ai_mini_project/blob/main/agent/session_store.py"
click node_supervisor "https://github.com/hankookiniayo/ai_mini_project/blob/main/agent/graph.py"
click node_routing "https://github.com/hankookiniayo/ai_mini_project/blob/main/agent/planning.py"
click node_facts "https://github.com/hankookiniayo/ai_mini_project/blob/main/agent/facts.py"
click node_validation "https://github.com/hankookiniayo/ai_mini_project/blob/main/agent/validators.py"
click node_llm "https://github.com/hankookiniayo/ai_mini_project/blob/main/agent/fake_llm.py"
click node_mcp_client "https://github.com/hankookiniayo/ai_mini_project/blob/main/agent/mcp_client.py"
click node_mcp_server "https://github.com/hankookiniayo/ai_mini_project/blob/main/mcp_server.py"
click node_shop_tools "https://github.com/hankookiniayo/ai_mini_project/blob/main/mcp_tools/shop.py"
click node_policy_search "https://github.com/hankookiniayo/ai_mini_project/blob/main/mcp_tools/policies.py"
click node_embeddings "https://github.com/hankookiniayo/ai_mini_project/blob/main/mcp_tools/embeddings.py"
click node_shop_repo "https://github.com/hankookiniayo/ai_mini_project/blob/main/mcp_tools/shop_repo.py"
click node_shop_db "https://github.com/hankookiniayo/ai_mini_project/tree/main/data/shop"
click node_policy_docs "https://github.com/hankookiniayo/ai_mini_project/tree/main/data/shop/policies"

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_web,node_api,node_sessions toneBlue
class node_supervisor,node_routing,node_facts,node_validation,node_llm,node_mcp_client toneAmber
class node_mcp_server,node_shop_tools,node_policy_search,node_embeddings toneMint
class node_shop_repo,node_shop_db,node_policy_docs toneRose
class node_customer toneIndigo
```

## Components

### 고객 접점

- [상담 화면](https://github.com/hankookiniayo/ai_mini_project/blob/main/web_shop.html): `web_shop.html`
- [FastAPI·인증](https://github.com/hankookiniayo/ai_mini_project/blob/main/server.py): `server.py`
- [대화 세션 저장](https://github.com/hankookiniayo/ai_mini_project/blob/main/agent/session_store.py): `agent/session_store.py`

### 상담 에이전트

- [상담 그래프](https://github.com/hankookiniayo/ai_mini_project/blob/main/agent/graph.py): `agent/graph.py`
- [분류·계획](https://github.com/hankookiniayo/ai_mini_project/blob/main/agent/planning.py): `agent/planning.py`
- [근거 포맷](https://github.com/hankookiniayo/ai_mini_project/blob/main/agent/facts.py): `agent/facts.py`
- [답변 검증](https://github.com/hankookiniayo/ai_mini_project/blob/main/agent/validators.py): `agent/validators.py`
- [LLM 백엔드](https://github.com/hankookiniayo/ai_mini_project/blob/main/agent/fake_llm.py): `agent/fake_llm.py`
- [MCP 클라이언트](https://github.com/hankookiniayo/ai_mini_project/blob/main/agent/mcp_client.py): `agent/mcp_client.py`

### MCP 조회 서비스

- [MCP 서비스](https://github.com/hankookiniayo/ai_mini_project/blob/main/mcp_server.py): `mcp_server.py`
- [주문·상품 조회](https://github.com/hankookiniayo/ai_mini_project/blob/main/mcp_tools/shop.py): `mcp_tools/shop.py`
- [정책 검색](https://github.com/hankookiniayo/ai_mini_project/blob/main/mcp_tools/policies.py): `mcp_tools/policies.py`
- [임베딩](https://github.com/hankookiniayo/ai_mini_project/blob/main/mcp_tools/embeddings.py): `mcp_tools/embeddings.py`

### 쇼핑몰 지식·데이터

- [주문 저장소](https://github.com/hankookiniayo/ai_mini_project/blob/main/mcp_tools/shop_repo.py): `mcp_tools/shop_repo.py`
- [쇼핑몰 데이터](https://github.com/hankookiniayo/ai_mini_project/tree/main/data/shop): `data/shop`
- [정책 문서](https://github.com/hankookiniayo/ai_mini_project/tree/main/data/shop/policies): `data/shop/policies`

### Other components

- **고객**

## Connections

- 고객 → 상담 화면: 질문 입력 (evidence: `README.md`)
- 상담 화면 → FastAPI·인증: API 요청 (evidence: `README.md`)
- FastAPI·인증 → 상담 그래프: 실행·스트리밍 (evidence: `server.py`)
- FastAPI·인증 → 대화 세션 저장: 대화 이력 저장 (evidence: `server.py`)
- FastAPI·인증 → 주문·상품 조회: 화면 데이터 조회 (evidence: `mcp_tools/shop.py`)
- 상담 그래프 → 분류·계획: 계획 보정 (evidence: `agent/graph.py`)
- 상담 그래프 → LLM 백엔드: 분류·답변 생성 (evidence: `agent/graph.py`)
- 상담 그래프 → MCP 클라이언트: MCP 조회 요청 (evidence: `agent/graph.py`)
- 상담 그래프 → 근거 포맷: 근거 구성 (evidence: `agent/facts.py`)
- 상담 그래프 → 답변 검증: 답변 검증 (evidence: `agent/graph.py`)
- MCP 클라이언트 → MCP 서비스: 도구 호출 (evidence: `agent/mcp_client.py`)
- MCP 서비스 → 주문·상품 조회: 도구 제공 (evidence: `mcp_server.py`)
- MCP 서비스 → 정책 검색: 검색 도구 제공 (evidence: `mcp_server.py`)
- 주문·상품 조회 → 주문 저장소: 저장소 조회 (evidence: `mcp_tools/shop.py`)
- 주문 저장소 → 쇼핑몰 데이터: 데이터 읽기 (evidence: `mcp_tools/shop_repo.py`)
- 정책 검색 → 임베딩: 벡터 임베딩 (evidence: `mcp_tools/policies.py`)
- 정책 검색 → 정책 문서: 정책 카탈로그 읽기 (evidence: `mcp_tools/policies.py`)
