Files
2nd/10_Wiki/Topics/AI_and_ML/Sequence_Diagram.md
T
koriweb d8a80f6272 chore(wiki): dangling 링크 canonical 정규화 (768파일/1200건)
이름만 다른(표기 변형) [[위키링크]]를 대상 문서의 canonical 제목으로 치환해
끊겼던 1,200개 링크를 연결. 제목/파일명 정규화 일치만 적용하고 별칭 매칭은
과병합 위험으로 제외(애매성 가드). 원본은 _link_reconcile_backup/ 에 백업.
도구: Datacollect/scripts/link_reconcile_apply.mjs

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 12:24:15 +09:00

4.6 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-sequence-diagram Sequence Diagram 10_Wiki/Topics verified self
UML Sequence Diagram
Mermaid Sequence
PlantUML Sequence
none A 0.9 applied
uml
diagramming
documentation
architecture
2026-05-10 pending
language framework
text Mermaid / PlantUML

Sequence Diagram

매 한 줄

"매 시간 축으로 actor 간 message 주고받음 시각화". 매 UML 의 dynamic behavior 다이어그램, 매 distributed system / API 흐름 / agent loop 설명에 매 standard. 매 2026: AI agent 가 code → diagram 자동 생성 (Claude, Mermaid Chart, Eraser AI), 매 text-as-code (Mermaid) 가 GUI tool 보다 dominant.

매 핵심

매 element

  • Lifeline: 매 actor / object 의 vertical line.
  • Message: 매 horizontal arrow (sync solid, async dashed, return dotted).
  • Activation bar: 매 처리 중 vertical bar.
  • Combined fragment: alt / opt / loop / par / critical.
  • Note: 매 inline annotation.

매 vs 다른 다이어그램

  • Flowchart: control flow, no actors. 매 single perspective.
  • Activity diagram: state machine 비슷, branching 강조.
  • Component diagram: static structure.
  • Sequence: 매 dynamic interaction over time — "누가 누구에게 언제".

매 응용

  1. API contract docs (REST/gRPC handshake).
  2. Auth flow (OAuth, OIDC, SAML).
  3. Distributed transaction (saga, 2PC).
  4. AI agent loop (user → LLM → tool → LLM → user).
  5. Bug reproduction trace.
  6. Onboarding 신입 — 매 system overview.

💻 패턴

Mermaid basic

sequenceDiagram
    participant U as User
    participant A as App
    participant DB
    U->>A: GET /profile
    A->>DB: SELECT * FROM users
    DB-->>A: row
    A-->>U: 200 OK (json)

Mermaid with alt/loop

sequenceDiagram
    actor User
    participant API
    participant LLM
    User->>API: question
    loop until done
        API->>LLM: prompt
        LLM-->>API: tool_call
        alt tool == search
            API->>SearchAPI: query
            SearchAPI-->>API: results
        else tool == done
            API-->>User: final answer
        end
    end

PlantUML

@startuml
actor Client
participant "Auth Service" as Auth
participant "Resource API" as API
Client -> Auth: POST /token (creds)
activate Auth
Auth --> Client: JWT
deactivate Auth
Client -> API: GET /data (Bearer JWT)
API -> API: verify JWT
API --> Client: 200 data
@enduml

Generate from code (Claude)

import anthropic
c = anthropic.Anthropic()
diagram = c.messages.create(
    model="claude-opus-4-7",
    max_tokens=2048,
    messages=[{
        "role": "user",
        "content": f"Generate a Mermaid sequenceDiagram from this code:\n```python\n{src}\n```",
    }],
).content[0].text

Embed in MkDocs / GitHub README

```mermaid
sequenceDiagram
    A->>B: ping
    B-->>A: pong
```

Mermaid CLI render

npx -p @mermaid-js/mermaid-cli mmdc -i flow.mmd -o flow.svg -t dark

OAuth 2.0 PKCE 매 example

sequenceDiagram
    participant App
    participant Browser
    participant Auth as AuthServer
    App->>Browser: redirect /authorize?code_challenge
    Browser->>Auth: login
    Auth-->>Browser: redirect ?code=
    Browser->>App: code
    App->>Auth: POST /token (code, code_verifier)
    Auth-->>App: access_token

매 결정 기준

상황 Approach
README / GitHub / Notion Mermaid (native render)
Detailed UML (combined fragments) PlantUML
Whiteboard 빠르게 Excalidraw
Auto-from-code Claude / Eraser AI
Live trace OpenTelemetry → Jaeger trace view

기본값: Mermaid in markdown.

🔗 Graph

🤖 LLM 활용

언제: code/log → diagram 자동화, refactor 후 docs 갱신, agent flow 설명. 언제 X: 매 매우 복잡한 system — 단일 sequence diagram 으로 부족, 매 break down.

안티패턴

  • 너무 많은 lifeline (>7): 매 cognitive overload — split.
  • 모든 detail 포함: 매 high-level abstraction 우선.
  • Static structure 표현: 매 잘못된 diagram type — component diagram 사용.
  • Out of date: code 와 sync 안 됨 → CI 에서 lint.

🧪 검증 / 중복

  • Verified (UML 2.5 spec, Mermaid docs, PlantUML docs).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — Mermaid + AI gen 2026