# capstonefincode/fincode_web_prototype architecture

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

- Interactive diagram: https://gitdiagram.com/capstonefincode/fincode_web_prototype
- Repository: https://github.com/capstonefincode/fincode_web_prototype

## Overview

핀코드는 이메일 요약과 LLM 프롬프트 인젝션 실험·평가를 위한 보안 실험실입니다. 사용자는 웹에서 데이터를 관리하거나 이메일·첨부파일을 요약하고, 공격/정상 시나리오 및 단일·비교 모델 평가를 실행해 결과와 판정을 조회합니다. 주요 영역은 웹 워크플로, FastAPI API, 첨부 추출, BAZE 모델 호출, 방어 처리, 실험·평가와 PostgreSQL 기록입니다. README와 발췌된 소스에서 확인 가능한 연결만 표시했으며 일부 구현은 미열람이라 관련 링크는 생략했습니다.

Main entry points: [`backend/defenses/gateway.py`](https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/defenses/gateway.py) (요약 게이트웨이), [`public/app.js`](https://github.com/capstonefincode/fincode_web_prototype/blob/main/public/app.js) (실험 대시보드), [`backend/app.py`](https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/app.py) (FastAPI 서비스), [`backend/database.py`](https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/database.py) (실험 데이터 저장)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["웹 실험실"]
  node_dashboard["실험 대시보드<br/>[app.js]"]
  node_attack_results["공격 결과 보기<br/>[attack-results.js]"]
  node_historical_data["기존 실험 데이터<br/>[data.js]"]
end

subgraph group_api["API와 실행"]
  node_api["FastAPI 서비스<br/>[app.py]"]
  node_attachment_flow["첨부 업로드·추출<br/>[attachments.py]"]
  node_extractor["파일 텍스트 추출"]
  node_gateway["요약 게이트웨이<br/>[gateway.py]"]
end

subgraph group_defense["방어 처리"]
  node_input_filter["입력 탐지 필터<br/>[input_filter.py]"]
  node_separation["프롬프트 분리<br/>[separation.py]"]
  node_defense_profiles["고정 방어 프로필<br/>[durable.py]"]
end

subgraph group_data["데이터와 평가"]
  node_persistence["DB API 연동<br/>[persistence.py]"]
  node_database[("실험 데이터 저장<br/>[database.py]")]
  node_performance["성능 평가<br/>[performance.py]"]
  node_quality["요약 품질 채점<br/>[summary_quality.py]"]
  node_results["실험 결과 판정<br/>[results.py]"]
  node_canary["Canary 판정<br/>[canary.py]"]
end

subgraph group_hosting["호스팅 어댑터"]
  node_worker["BAZE Worker<br/>[baze.mjs]"]
  node_proxy["백엔드 프록시<br/>[backend-proxy.mjs]"]
  node_connector_contract["커넥터 계약"]
end

node_user(("실험 사용자"))
node_baze{{"BAZE 모델 서비스"}}

node_user -->|"입력·실행"| node_dashboard
node_dashboard -->|"API 호출"| node_api
node_dashboard -->|"불러옴"| node_historical_data
node_dashboard -->|"결과 표시"| node_attack_results
node_api -->|"첨부 관리"| node_attachment_flow
node_attachment_flow -->|"텍스트 추출"| node_extractor
node_api -->|"요약 실행"| node_gateway
node_gateway -->|"검사 호출"| node_input_filter
node_gateway -->|"분리 적용"| node_separation
node_gateway -->|"모델 요청"| node_baze
node_api -->|"DB 작업"| node_persistence
node_persistence -->|"저장소 사용"| node_database
node_database -->|"평가 저장"| node_performance
node_database -->|"결과 저장"| node_results
node_database -->|"채점 데이터"| node_quality
node_results -->|"판정 사용"| node_canary
node_performance -->|"자동 채점"| node_quality
node_defense_profiles -->|"방어 계획"| node_gateway
node_worker -->|"모델 요청"| node_baze
node_worker -.->|"DB API 연결"| node_proxy

click node_dashboard "https://github.com/capstonefincode/fincode_web_prototype/blob/main/public/app.js"
click node_attack_results "https://github.com/capstonefincode/fincode_web_prototype/blob/main/public/attack-results.js"
click node_historical_data "https://github.com/capstonefincode/fincode_web_prototype/blob/main/public/data.js"
click node_api "https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/app.py"
click node_attachment_flow "https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/attachments.py"
click node_extractor "https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/attachment_extract.py"
click node_gateway "https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/defenses/gateway.py"
click node_input_filter "https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/defenses/input_filter.py"
click node_separation "https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/defenses/separation.py"
click node_defense_profiles "https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/defenses/durable.py"
click node_persistence "https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/persistence.py"
click node_database "https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/database.py"
click node_performance "https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/performance.py"
click node_quality "https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/summary_quality.py"
click node_results "https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/results.py"
click node_canary "https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/canary.py"
click node_worker "https://github.com/capstonefincode/fincode_web_prototype/blob/main/server/baze.mjs"
click node_proxy "https://github.com/capstonefincode/fincode_web_prototype/blob/main/server/backend-proxy.mjs"
click node_connector_contract "https://github.com/capstonefincode/fincode_web_prototype/blob/main/lib/connector-contract.mts"

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_dashboard,node_attack_results,node_historical_data toneBlue
class node_api,node_attachment_flow,node_extractor,node_gateway toneAmber
class node_input_filter,node_separation,node_defense_profiles toneMint
class node_persistence,node_database,node_performance,node_quality,node_results,node_canary toneRose
class node_worker,node_proxy,node_connector_contract,node_user,node_baze toneIndigo
```

## Components

### 웹 실험실

- [실험 대시보드](https://github.com/capstonefincode/fincode_web_prototype/blob/main/public/app.js): `public/app.js`
- [공격 결과 보기](https://github.com/capstonefincode/fincode_web_prototype/blob/main/public/attack-results.js): `public/attack-results.js`
- [기존 실험 데이터](https://github.com/capstonefincode/fincode_web_prototype/blob/main/public/data.js): `public/data.js`

### API와 실행

- [FastAPI 서비스](https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/app.py): `backend/app.py`
- [첨부 업로드·추출](https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/attachments.py): `backend/attachments.py`
- [파일 텍스트 추출](https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/attachment_extract.py): `backend/attachment_extract.py`
- [요약 게이트웨이](https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/defenses/gateway.py): `backend/defenses/gateway.py`

### 방어 처리

- [입력 탐지 필터](https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/defenses/input_filter.py): `backend/defenses/input_filter.py`
- [프롬프트 분리](https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/defenses/separation.py): `backend/defenses/separation.py`
- [고정 방어 프로필](https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/defenses/durable.py): `backend/defenses/durable.py`

### 데이터와 평가

- [DB API 연동](https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/persistence.py): `backend/persistence.py`
- [실험 데이터 저장](https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/database.py): `backend/database.py`
- [성능 평가](https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/performance.py): `backend/performance.py`
- [요약 품질 채점](https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/summary_quality.py): `backend/summary_quality.py`
- [실험 결과 판정](https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/results.py): `backend/results.py`
- [Canary 판정](https://github.com/capstonefincode/fincode_web_prototype/blob/main/backend/canary.py): `backend/canary.py`

### 호스팅 어댑터

- [BAZE Worker](https://github.com/capstonefincode/fincode_web_prototype/blob/main/server/baze.mjs): `server/baze.mjs`
- [백엔드 프록시](https://github.com/capstonefincode/fincode_web_prototype/blob/main/server/backend-proxy.mjs): `server/backend-proxy.mjs`
- [커넥터 계약](https://github.com/capstonefincode/fincode_web_prototype/blob/main/lib/connector-contract.mts): `lib/connector-contract.mts`

### Other components

- **실험 사용자**
- **BAZE 모델 서비스**

## Connections

- 실험 사용자 → 실험 대시보드: 입력·실행 (evidence: `README.md`)
- 실험 대시보드 → FastAPI 서비스: API 호출 (evidence: `README.md`)
- 실험 대시보드 → 기존 실험 데이터: 불러옴 (evidence: `public/app.js`)
- 실험 대시보드 → 공격 결과 보기: 결과 표시 (evidence: `public/app.js`)
- FastAPI 서비스 → 첨부 업로드·추출: 첨부 관리 (evidence: `backend/app.py`)
- 첨부 업로드·추출 → 파일 텍스트 추출: 텍스트 추출 (evidence: `backend/attachments.py`)
- FastAPI 서비스 → 요약 게이트웨이: 요약 실행 (evidence: `backend/app.py`)
- 요약 게이트웨이 → 입력 탐지 필터: 검사 호출 (evidence: `backend/defenses/gateway.py`)
- 요약 게이트웨이 → 프롬프트 분리: 분리 적용 (evidence: `backend/defenses/gateway.py`)
- 요약 게이트웨이 → BAZE 모델 서비스: 모델 요청 (evidence: `README.md`)
- FastAPI 서비스 → DB API 연동: DB 작업 (evidence: `backend/app.py`)
- DB API 연동 → 실험 데이터 저장: 저장소 사용 (evidence: `backend/persistence.py`)
- 실험 데이터 저장 → 성능 평가: 평가 저장 (evidence: `backend/database.py`)
- 실험 데이터 저장 → 실험 결과 판정: 결과 저장 (evidence: `backend/database.py`)
- 실험 데이터 저장 → 요약 품질 채점: 채점 데이터 (evidence: `backend/database.py`)
- 실험 결과 판정 → Canary 판정: 판정 사용 (evidence: `backend/results.py`)
- 성능 평가 → 요약 품질 채점: 자동 채점 (evidence: `backend/performance.py`)
- 고정 방어 프로필 → 요약 게이트웨이: 방어 계획 (evidence: `backend/defenses/durable.py`)
- BAZE Worker → BAZE 모델 서비스: 모델 요청 (evidence: `README.md`)
- BAZE Worker → 백엔드 프록시: DB API 연결 (evidence: `README.md`)
