# gns6351/pbl_space_gnu_com architecture

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

- Interactive diagram: https://gitdiagram.com/gns6351/pbl_space_gnu_com
- Repository: https://github.com/gns6351/pbl_space_gnu_com

## Overview

거울상담소는 플레이어의 걱정을 닮은 손님과 상담한 뒤, 플레이어가 건넨 조언을 자기 자신에게 돌려주는 자기성찰 게임입니다. 주 흐름은 걱정 접수·위험 확인, 손님 생성, 상담과 조언 판정, 거울 변환·점검, 판단 및 카드 보관입니다. README에는 mock 실행도 안내되어 있습니다. 게임 단계와 AI 호출·콘텐츠·저장 계층을 구분했습니다. 일부 연결은 발췌문과 SOURCE INDEX에서 확인된 범위만 표시했으며, 앱 클라이언트는 저장소에 아직 없습니다.

Main entry points: [`ai-server/src/app.js`](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/app.js) (Express 앱), [`ai-server/src/game/router.js`](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/router.js) (게임 API 라우터), [`ai-server/src/game/engine.js`](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/engine.js) (게임 AI 엔진), [`ai-server/src/game/content.js`](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/content.js) (게임 콘텐츠 로더)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["서버 진입"]
  node_server["HTTP 서버<br/>[server.js]"]
  node_app["Express 앱<br/>[app.js]"]
end

subgraph group_game["게임 진행"]
  node_router["게임 API 라우터<br/>[router.js]"]
  node_flow["세션 단계 흐름<br/>[flow.js]"]
  node_sim["게임 시뮬레이션<br/>[sim.js]"]
  node_cli["시뮬레이션 CLI<br/>[game-cli.js]"]
  node_csv["CSV 변환<br/>[csv.js]"]
end

subgraph group_ai["AI 처리"]
  node_engine["게임 AI 엔진<br/>[engine.js]"]
  node_safety["안전 규칙<br/>[safety.js]"]
  node_judges["응답 판정기<br/>[judges.js]"]
  node_format["거울 형식 검사<br/>[format.js]"]
  node_ask["LLM 호출·검사<br/>[ask.js]"]
  node_llm["LLM 어댑터<br/>[client.js]"]
  node_mocks["모의 응답<br/>[mocks.js]"]
end

subgraph group_data["콘텐츠와 상태"]
  node_config["설정·프롬프트 로더<br/>[config.js]"]
  node_content["게임 콘텐츠 로더<br/>[content.js]"]
  node_prompts["게임 프롬프트·규칙"]
  node_gamecontent["게임 설정·예시<br/>[game.json]"]
  node_store[("세션·카드 저장소<br/>[store.js]")]
end

node_player(("플레이어"))
node_gemini{{"Gemini API"}}

node_player -->|"게임 API 요청"| node_app
node_server -->|"호스팅"| node_app
node_app -->|"설정 로드"| node_config
node_app -->|"어댑터 생성"| node_llm
node_app -->|"mock 주입"| node_mocks
node_app -->|"라우트 등록"| node_router
node_router -->|"콘텐츠 로드"| node_content
node_router -->|"안전 규칙 생성"| node_safety
node_router -->|"단계 처리"| node_flow
node_router -->|"상태 저장·조회"| node_store
node_flow -->|"AI 작업 요청"| node_engine
node_engine -->|"프롬프트 호출"| node_ask
node_engine -->|"출력 판정"| node_judges
node_engine -->|"변환 형식 검사"| node_format
node_ask -->|"프롬프트 렌더링"| node_config
node_llm -->|"생성 요청"| node_gemini
node_content -->|"프롬프트 로드"| node_config
node_content -->|"규칙·프롬프트 읽기"| node_prompts
node_content -->|"설정·예시 읽기"| node_gamecontent
node_cli -->|"시뮬레이션 실행"| node_sim
node_cli -->|"로컬 API 시작"| node_app
node_cli -->|"AI 어댑터 생성"| node_llm
node_cli -->|"보고서 변환"| node_csv
node_sim -->|"위험 사례 판정"| node_engine
node_sim -->|"테스트 데이터 로드"| node_content

click node_server "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/server.js"
click node_app "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/app.js"
click node_router "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/router.js"
click node_flow "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/flow.js"
click node_engine "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/engine.js"
click node_safety "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/safety.js"
click node_judges "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/judges.js"
click node_format "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/format.js"
click node_ask "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/llm/ask.js"
click node_llm "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/llm/client.js"
click node_config "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/config.js"
click node_content "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/content.js"
click node_prompts "https://github.com/gns6351/pbl_space_gnu_com/tree/claude/stoic-edison-k93t2v/ai-server/content/prompts"
click node_gamecontent "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/content/game.json"
click node_store "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/store.js"
click node_mocks "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/mocks.js"
click node_sim "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/sim.js"
click node_cli "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/scripts/game-cli.js"
click node_csv "https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/scripts/csv.js"

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_server,node_app toneBlue
class node_router,node_flow,node_sim,node_cli,node_csv toneAmber
class node_engine,node_safety,node_judges,node_format,node_ask,node_llm,node_mocks,node_gemini toneMint
class node_config,node_content,node_prompts,node_gamecontent,node_store toneRose
class node_player toneIndigo
```

## Components

### 서버 진입

- [HTTP 서버](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/server.js): `ai-server/src/server.js`
- [Express 앱](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/app.js): `ai-server/src/app.js`

### 게임 진행

- [게임 API 라우터](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/router.js): `ai-server/src/game/router.js`
- [세션 단계 흐름](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/flow.js): `ai-server/src/game/flow.js`
- [게임 시뮬레이션](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/sim.js): `ai-server/src/game/sim.js`
- [시뮬레이션 CLI](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/scripts/game-cli.js): `ai-server/scripts/game-cli.js`
- [CSV 변환](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/scripts/csv.js): `ai-server/scripts/csv.js`

### AI 처리

- [게임 AI 엔진](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/engine.js): `ai-server/src/game/engine.js`
- [안전 규칙](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/safety.js): `ai-server/src/game/safety.js`
- [응답 판정기](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/judges.js): `ai-server/src/game/judges.js`
- [거울 형식 검사](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/format.js): `ai-server/src/game/format.js`
- [LLM 호출·검사](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/llm/ask.js): `ai-server/src/llm/ask.js`
- [LLM 어댑터](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/llm/client.js): `ai-server/src/llm/client.js`
- [모의 응답](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/mocks.js): `ai-server/src/game/mocks.js`

### 콘텐츠와 상태

- [설정·프롬프트 로더](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/config.js): `ai-server/src/config.js`
- [게임 콘텐츠 로더](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/content.js): `ai-server/src/game/content.js`
- [게임 프롬프트·규칙](https://github.com/gns6351/pbl_space_gnu_com/tree/claude/stoic-edison-k93t2v/ai-server/content/prompts): `ai-server/content/prompts`
- [게임 설정·예시](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/content/game.json): `ai-server/content/game.json`
- [세션·카드 저장소](https://github.com/gns6351/pbl_space_gnu_com/blob/claude/stoic-edison-k93t2v/ai-server/src/game/store.js): `ai-server/src/game/store.js`

### Other components

- **플레이어**
- **Gemini API**

## Connections

- 플레이어 → Express 앱: 게임 API 요청 (evidence: `README.md`)
- HTTP 서버 → Express 앱: 호스팅 (evidence: `ai-server/src/server.js`)
- Express 앱 → 설정·프롬프트 로더: 설정 로드 (evidence: `ai-server/src/app.js`)
- Express 앱 → LLM 어댑터: 어댑터 생성 (evidence: `ai-server/src/app.js`)
- Express 앱 → 모의 응답: mock 주입 (evidence: `ai-server/src/app.js`)
- Express 앱 → 게임 API 라우터: 라우트 등록 (evidence: `ai-server/src/app.js`)
- 게임 API 라우터 → 게임 콘텐츠 로더: 콘텐츠 로드 (evidence: `ai-server/src/game/router.js`)
- 게임 API 라우터 → 안전 규칙: 안전 규칙 생성 (evidence: `ai-server/src/game/router.js`)
- 게임 API 라우터 → 세션 단계 흐름: 단계 처리 (evidence: `ai-server/src/game/router.js`)
- 게임 API 라우터 → 세션·카드 저장소: 상태 저장·조회 (evidence: `ai-server/src/game/router.js`)
- 세션 단계 흐름 → 게임 AI 엔진: AI 작업 요청 (evidence: `ai-server/src/game/flow.js`)
- 게임 AI 엔진 → LLM 호출·검사: 프롬프트 호출 (evidence: `ai-server/src/game/engine.js`)
- 게임 AI 엔진 → 응답 판정기: 출력 판정 (evidence: `ai-server/src/game/engine.js`)
- 게임 AI 엔진 → 거울 형식 검사: 변환 형식 검사 (evidence: `ai-server/src/game/engine.js`)
- LLM 호출·검사 → 설정·프롬프트 로더: 프롬프트 렌더링 (evidence: `ai-server/src/llm/ask.js`)
- LLM 어댑터 → Gemini API: 생성 요청 (evidence: `ai-server/src/llm/client.js`)
- 게임 콘텐츠 로더 → 설정·프롬프트 로더: 프롬프트 로드 (evidence: `ai-server/src/game/content.js`)
- 게임 콘텐츠 로더 → 게임 프롬프트·규칙: 규칙·프롬프트 읽기 (evidence: `ai-server/src/game/content.js`)
- 게임 콘텐츠 로더 → 게임 설정·예시: 설정·예시 읽기 (evidence: `ai-server/src/game/content.js`)
- 시뮬레이션 CLI → 게임 시뮬레이션: 시뮬레이션 실행 (evidence: `ai-server/scripts/game-cli.js`)
- 시뮬레이션 CLI → Express 앱: 로컬 API 시작 (evidence: `ai-server/scripts/game-cli.js`)
- 시뮬레이션 CLI → LLM 어댑터: AI 어댑터 생성 (evidence: `ai-server/scripts/game-cli.js`)
- 시뮬레이션 CLI → CSV 변환: 보고서 변환 (evidence: `ai-server/scripts/game-cli.js`)
- 게임 시뮬레이션 → 게임 AI 엔진: 위험 사례 판정 (evidence: `ai-server/src/game/sim.js`)
- 게임 시뮬레이션 → 게임 콘텐츠 로더: 테스트 데이터 로드 (evidence: `ai-server/src/game/sim.js`)
