@@ -79,6 +79,7 @@ langgraph-init/
7979## 🏗️ 아키텍처
8080
8181### 계층 구조
82+
8283```
8384┌─────────────────────────────────────────┐
8485│ FastAPI Controller │ # HTTP 엔드포인트
@@ -97,7 +98,9 @@ langgraph-init/
9798```
9899
99100### BaseNode 패턴
101+
100102모든 노드는 ` BaseNode ` 를 상속받아 일관된 인터페이스 제공:
103+
101104- 자동 로깅 (시작/종료, 소요시간)
102105- 예외 처리 (ValueError → 400, Exception → 500)
103106- 비동기 실행 (` async def execute() ` )
@@ -132,6 +135,7 @@ cp .env.example .env
132135```
133136
134137** .env 예시:**
138+
135139``` bash
136140# === 모델 설정 ===
137141CHAT_MODEL=gpt-4o-mini
@@ -150,7 +154,7 @@ MONGODB_DB_NAME=langgraph_db
150154
151155# === API 서버 ===
152156API_HOST=0.0.0.0
153- API_PORT=8123
157+ API_PORT=8000
154158CORS_ORIGINS=http://localhost:3000,http://localhost:8000
155159
156160# === 로깅 ===
@@ -170,17 +174,17 @@ TZ=Asia/Seoul
170174python main.py
171175
172176# 또는 uvicorn 직접 실행
173- uvicorn main:app --reload --host 0.0.0.0 --port 8123
177+ uvicorn main:app --reload --host 0.0.0.0 --port 8000
174178```
175179
176180### 4. API 테스트
177181
178182``` bash
179183# 헬스 체크
180- curl http://localhost:8123 /api/v1/health
184+ curl http://localhost:8000 /api/v1/health
181185
182186# 채팅 요청
183- curl -X POST http://localhost:8123 /api/v1/chat \
187+ curl -X POST http://localhost:8000 /api/v1/chat \
184188 -H " Content-Type: application/json" \
185189 -d ' {
186190 "user_id": "user123",
@@ -194,12 +198,14 @@ curl -X POST http://localhost:8123/api/v1/chat \
194198### 5. API 문서 확인
195199
196200서버 실행 후 브라우저에서:
197- - ** Swagger UI** : http://localhost:8123/docs
198- - ** ReDoc** : http://localhost:8123/redoc
201+
202+ - ** Swagger UI** : http://localhost:8000/docs
203+ - ** ReDoc** : http://localhost:8000/redoc
199204
200205## 🔧 지원하는 모델
201206
202207### 채팅 모델
208+
203209``` bash
204210# OpenAI
205211CHAT_MODEL=gpt-4o
@@ -217,6 +223,7 @@ CHAT_MODEL=gemini-1.5-flash
217223```
218224
219225### 임베딩 모델
226+
220227``` bash
221228# OpenAI
222229EMBEDDING_MODEL=text-embedding-3-large
@@ -263,6 +270,7 @@ logger.error("에러 메시지")
263270```
264271
265272** 로그 출력 예시:**
273+
266274```
2672752025-10-29 14:30:25 KST [DEBUG] agents.nodes.example - [example] 노드 실행 시작
2682762025-10-29 14:30:25 KST [DEBUG] agents.nodes.example - 입력 메시지 수: 1
@@ -298,12 +306,13 @@ docker-compose down
298306
299307# 개별 빌드
300308docker build -t langgraph-app .
301- docker run -p 8123:8123 --env-file .env langgraph-app
309+ docker run -p 8000:8000 --env-file .env langgraph-app
302310```
303311
304312## 🎯 주요 개발 패턴
305313
306314### 1. DTO 기반 API 통신
315+
307316``` python
308317# Request DTO
309318class ChatRequestDTO (BaseModel ):
@@ -321,6 +330,7 @@ class ChatResponseDTO(BaseModel):
321330```
322331
323332### 2. Service 계층 패턴
333+
324334``` python
325335class ChatService :
326336 async def process_chat (self , request : ChatRequestDTO) -> ChatResponseDTO:
@@ -333,6 +343,7 @@ class ChatService:
333343```
334344
335345### 3. Repository 패턴
346+
336347``` python
337348class ChatHistoryRepository :
338349 async def save_chat (self , chat_history , message_pair ):
@@ -347,13 +358,15 @@ class ChatHistoryRepository:
347358## 💡 개발 팁
348359
349360### 모델 교체
361+
350362``` bash
351363# 환경변수만 변경하면 자동으로 다른 모델 사용
352364export CHAT_MODEL=claude-3-5-sonnet-20241022
353365export ANTHROPIC_API_KEY=sk-ant-...
354366```
355367
356368### 새로운 도구 추가
369+
357370``` python
358371# src/agents/tools/my_tool.py
359372from langchain_core.tools import tool
@@ -365,6 +378,7 @@ def my_custom_tool(query: str) -> str:
365378```
366379
367380### 프롬프트 관리
381+
368382``` python
369383# src/agents/prompts/prompt_provider.py 활용
370384class PromptProvider :
@@ -379,4 +393,3 @@ class PromptProvider:
379393- [ FastAPI 공식 문서] ( https://fastapi.tiangolo.com/ )
380394- [ MongoDB Python Driver] ( https://www.mongodb.com/docs/drivers/motor/ )
381395- [ Pydantic] ( https://docs.pydantic.dev/ )
382-
0 commit comments