# 100-hours-a-week/ktb4-2nd-ai architecture

> Architecture diagram of the GitHub repository 100-hours-a-week/ktb4-2nd-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/100-hours-a-week/ktb4-2nd-ai
- Repository: https://github.com/100-hours-a-week/ktb4-2nd-ai

## Overview

여담 AI는 여행 사진을 장소별로 분류·정리하는 작업 API와 사진 검색·질의 API를 제공한다. 정리 흐름은 요청 접수와 큐잉, 워커 위임, 이미지 처리, 장소 추론·군집화·필터링, 결과 콜백으로 이어진다. 별도 검색 흐름은 요청을 검증한 뒤 검색 파이프라인에 넘긴다. 구성은 API, 작업 실행, 사진 파이프라인·자원, 검색, 공통 기반으로 나눴다. 검색과 일부 파이프라인 구현은 인덱스와 README로 확인했으며, 세부 연결은 확인된 관계만 표시했다.

Main entry points: [`app/pipeline/run.py`](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/run.py) (파이프라인 조정), [`app/main.py`](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/main.py) (API 앱), [`app/api/services/task_service.py`](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/api/services/task_service.py) (작업 상태 관리), [`app/pipeline/context.py`](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/context.py) (실행 컨텍스트)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API 및 작업 관리"]
  node_api_app["API 앱<br/>[main.py]"]
  node_process_api["정리 API<br/>[process.py]"]
  node_query_api["검색 API<br/>[query.py]"]
  node_task_service["작업 상태 관리<br/>[task_service.py]"]
  node_task_store[("작업 저장소<br/>[task_store.py]")]
  node_worker_client["워커 클라이언트<br/>[worker_client.py]"]
  node_internal_api["내부 콜백 API<br/>[internal.py]"]
  node_query_service["검색 서비스<br/>[query_service.py]"]
end

subgraph group_worker["워커 실행"]
  node_worker_jobs["작업 접수 라우터<br/>[jobs.py]"]
  node_worker_runner["작업 실행기<br/>[runner.py]"]
  node_callback["결과 콜백<br/>[callback.py]"]
end

subgraph group_pipeline["사진 파이프라인"]
  node_bootstrap["파이프라인 조립<br/>[bootstrap.py]"]
  node_pipeline_run["파이프라인 조정<br/>[run.py]"]
  node_download["이미지 다운로드<br/>[download.py]"]
  node_clock["시계 보정<br/>[clock.py]"]
  node_locating["장소 추론<br/>[locating.py]"]
  node_clustering["장소 군집화<br/>[clustering.py]"]
  node_filtering["품질 필터링<br/>[filtering.py]"]
  node_finalizing["결과 마무리<br/>[finalizing.py]"]
  node_pipeline_context["실행 컨텍스트<br/>[context.py]"]
  node_image_source["이미지 소스<br/>[images.py]"]
  node_embedding["임베딩 엔진<br/>[base.py]"]
  node_qdrant[("Qdrant 저장소<br/>[qdrant.py]")]
end

subgraph group_search["검색 및 질의"]
  node_search_pipeline["검색 파이프라인<br/>[pipeline.py]"]
  node_search_context["검색 의존성<br/>[context.py]"]
  node_vlm["VLM 클라이언트<br/>[vlm.py]"]
end

subgraph group_shared["공통 기반"]
  node_schemas["요청·결과 계약<br/>[process.py]"]
  node_settings["설정<br/>[config.py]"]
  node_logging["구조화 로깅<br/>[logging.py]"]
end

node_backend(("백엔드 호출자"))

node_backend -->|"HTTP 요청"| node_api_app
node_api_app -->|"라우팅"| node_process_api
node_api_app -->|"라우팅"| node_query_api
node_process_api -->|"호출"| node_task_service
node_query_api -->|"호출"| node_query_service
node_api_app -->|"구성"| node_task_service
node_task_service -->|"상태 읽기·쓰기"| node_task_store
node_task_service -->|"작업 위임"| node_worker_client
node_worker_client -.->|"작업 요청"| node_worker_jobs
node_worker_jobs -->|"실행 요청"| node_worker_runner
node_worker_runner -->|"파이프라인 사용"| node_bootstrap
node_worker_runner -->|"결과 전송"| node_callback
node_callback -.->|"콜백 전송"| node_internal_api
node_internal_api -.->|"상태 갱신"| node_task_service
node_bootstrap -->|"컨텍스트 구성"| node_pipeline_context
node_bootstrap -->|"실행 연결"| node_pipeline_run
node_pipeline_run -->|"단계 호출"| node_download
node_pipeline_run -->|"단계 호출"| node_clock
node_pipeline_run -->|"단계 호출"| node_locating
node_pipeline_run -->|"단계 호출"| node_clustering
node_pipeline_run -->|"단계 호출"| node_filtering
node_pipeline_run -->|"단계 호출"| node_finalizing
node_pipeline_context -->|"의존성 제공"| node_image_source
node_pipeline_context -->|"의존성 제공"| node_embedding
node_pipeline_context -->|"의존성 제공"| node_qdrant
node_query_service -->|"검색 실행"| node_search_pipeline
node_query_service -->|"의존성 전달"| node_search_context
node_search_pipeline -->|"의존성 사용"| node_search_context
node_search_context -->|"VLM 제공"| node_vlm
node_settings -->|"설정 제공"| node_api_app
node_schemas -->|"요청·응답 계약"| node_process_api
node_logging -->|"로그 설정"| node_api_app

click node_api_app "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/main.py"
click node_process_api "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/api/routers/process.py"
click node_query_api "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/api/routers/query.py"
click node_task_service "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/api/services/task_service.py"
click node_task_store "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/api/services/task_store.py"
click node_worker_client "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/api/services/worker_client.py"
click node_internal_api "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/api/routers/internal.py"
click node_query_service "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/api/services/query_service.py"
click node_worker_jobs "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/worker/routers/jobs.py"
click node_worker_runner "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/worker/runner.py"
click node_callback "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/worker/callback.py"
click node_bootstrap "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/bootstrap.py"
click node_pipeline_run "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/run.py"
click node_download "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/steps/download.py"
click node_clock "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/steps/clock.py"
click node_locating "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/steps/locating.py"
click node_clustering "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/steps/clustering.py"
click node_filtering "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/steps/filtering.py"
click node_finalizing "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/steps/finalizing.py"
click node_pipeline_context "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/context.py"
click node_image_source "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/infra/images.py"
click node_embedding "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/engines/base.py"
click node_qdrant "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/infra/qdrant.py"
click node_search_pipeline "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/search/pipeline.py"
click node_search_context "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/search/context.py"
click node_vlm "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/infra/vlm.py"
click node_schemas "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/schemas/process.py"
click node_settings "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/core/config.py"
click node_logging "https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/core/logging.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_api_app,node_process_api,node_query_api,node_task_service,node_task_store,node_worker_client,node_internal_api,node_query_service toneBlue
class node_worker_jobs,node_worker_runner,node_callback toneAmber
class node_bootstrap,node_pipeline_run,node_download,node_clock,node_locating,node_clustering,node_filtering,node_finalizing,node_pipeline_context,node_image_source,node_embedding,node_qdrant toneMint
class node_search_pipeline,node_search_context,node_vlm toneRose
class node_schemas,node_settings,node_logging,node_backend toneIndigo
```

## Components

### API 및 작업 관리

- [API 앱](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/main.py): `app/main.py`
- [정리 API](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/api/routers/process.py): `app/api/routers/process.py`
- [검색 API](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/api/routers/query.py): `app/api/routers/query.py`
- [작업 상태 관리](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/api/services/task_service.py): `app/api/services/task_service.py`
- [작업 저장소](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/api/services/task_store.py): `app/api/services/task_store.py`
- [워커 클라이언트](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/api/services/worker_client.py): `app/api/services/worker_client.py`
- [내부 콜백 API](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/api/routers/internal.py): `app/api/routers/internal.py`
- [검색 서비스](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/api/services/query_service.py): `app/api/services/query_service.py`

### 워커 실행

- [작업 접수 라우터](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/worker/routers/jobs.py): `app/worker/routers/jobs.py`
- [작업 실행기](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/worker/runner.py): `app/worker/runner.py`
- [결과 콜백](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/worker/callback.py): `app/worker/callback.py`

### 사진 파이프라인

- [파이프라인 조립](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/bootstrap.py): `app/pipeline/bootstrap.py`
- [파이프라인 조정](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/run.py): `app/pipeline/run.py`
- [이미지 다운로드](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/steps/download.py): `app/pipeline/steps/download.py`
- [시계 보정](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/steps/clock.py): `app/pipeline/steps/clock.py`
- [장소 추론](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/steps/locating.py): `app/pipeline/steps/locating.py`
- [장소 군집화](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/steps/clustering.py): `app/pipeline/steps/clustering.py`
- [품질 필터링](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/steps/filtering.py): `app/pipeline/steps/filtering.py`
- [결과 마무리](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/steps/finalizing.py): `app/pipeline/steps/finalizing.py`
- [실행 컨텍스트](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/pipeline/context.py): `app/pipeline/context.py`
- [이미지 소스](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/infra/images.py): `app/infra/images.py`
- [임베딩 엔진](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/engines/base.py): `app/engines/base.py`
- [Qdrant 저장소](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/infra/qdrant.py): `app/infra/qdrant.py`

### 검색 및 질의

- [검색 파이프라인](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/search/pipeline.py): `app/search/pipeline.py`
- [검색 의존성](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/search/context.py): `app/search/context.py`
- [VLM 클라이언트](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/infra/vlm.py): `app/infra/vlm.py`

### 공통 기반

- [요청·결과 계약](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/schemas/process.py): `app/schemas/process.py`
- [설정](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/core/config.py): `app/core/config.py`
- [구조화 로깅](https://github.com/100-hours-a-week/ktb4-2nd-ai/blob/main/app/core/logging.py): `app/core/logging.py`

### Other components

- **백엔드 호출자**

## Connections

- 백엔드 호출자 → API 앱: HTTP 요청 (evidence: `app/main.py`)
- API 앱 → 정리 API: 라우팅 (evidence: `app/main.py`)
- API 앱 → 검색 API: 라우팅 (evidence: `app/main.py`)
- 정리 API → 작업 상태 관리: 호출
- 검색 API → 검색 서비스: 호출 (evidence: `app/api/routers/query.py`)
- API 앱 → 작업 상태 관리: 구성 (evidence: `app/main.py`)
- 작업 상태 관리 → 작업 저장소: 상태 읽기·쓰기 (evidence: `app/api/services/task_service.py`)
- 작업 상태 관리 → 워커 클라이언트: 작업 위임 (evidence: `app/api/services/task_service.py`)
- 워커 클라이언트 → 작업 접수 라우터: 작업 요청
- 작업 접수 라우터 → 작업 실행기: 실행 요청 (evidence: `app/worker/routers/jobs.py`)
- 작업 실행기 → 파이프라인 조립: 파이프라인 사용 (evidence: `app/worker/runner.py`)
- 작업 실행기 → 결과 콜백: 결과 전송 (evidence: `app/worker/runner.py`)
- 결과 콜백 → 내부 콜백 API: 콜백 전송
- 내부 콜백 API → 작업 상태 관리: 상태 갱신
- 파이프라인 조립 → 실행 컨텍스트: 컨텍스트 구성 (evidence: `app/pipeline/bootstrap.py`)
- 파이프라인 조립 → 파이프라인 조정: 실행 연결 (evidence: `app/pipeline/bootstrap.py`)
- 파이프라인 조정 → 이미지 다운로드: 단계 호출 (evidence: `app/pipeline/run.py`)
- 파이프라인 조정 → 시계 보정: 단계 호출 (evidence: `app/pipeline/run.py`)
- 파이프라인 조정 → 장소 추론: 단계 호출 (evidence: `app/pipeline/run.py`)
- 파이프라인 조정 → 장소 군집화: 단계 호출 (evidence: `app/pipeline/run.py`)
- 파이프라인 조정 → 품질 필터링: 단계 호출 (evidence: `app/pipeline/run.py`)
- 파이프라인 조정 → 결과 마무리: 단계 호출 (evidence: `app/pipeline/run.py`)
- 실행 컨텍스트 → 이미지 소스: 의존성 제공 (evidence: `app/pipeline/context.py`)
- 실행 컨텍스트 → 임베딩 엔진: 의존성 제공 (evidence: `app/pipeline/context.py`)
- 실행 컨텍스트 → Qdrant 저장소: 의존성 제공 (evidence: `app/pipeline/context.py`)
- 검색 서비스 → 검색 파이프라인: 검색 실행 (evidence: `app/api/services/query_service.py`)
- 검색 서비스 → 검색 의존성: 의존성 전달 (evidence: `app/api/services/query_service.py`)
- 검색 파이프라인 → 검색 의존성: 의존성 사용 (evidence: `app/search/pipeline.py`)
- 검색 의존성 → VLM 클라이언트: VLM 제공 (evidence: `app/search/context.py`)
- 설정 → API 앱: 설정 제공 (evidence: `app/main.py`)
- 요청·결과 계약 → 정리 API: 요청·응답 계약 (evidence: `app/api/routers/process.py`)
- 구조화 로깅 → API 앱: 로그 설정 (evidence: `app/main.py`)
