# sakiphan/yargitay-mcp architecture

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

- Interactive diagram: https://gitdiagram.com/sakiphan/yargitay-mcp
- Repository: https://github.com/sakiphan/yargitay-mcp

## Overview

Yargıtay MCP is a local Go MCP server that lets an AI client search and retrieve decisions from Yargıtay, AYM, Danıştay, and AİHM/HUDOC. The main flow is client request → CLI startup → MCP tools → source-specific search/document access → official court sources; results return through the MCP server. An optional local viewer serves decision pages. The npm launcher obtains and verifies the Go binary before forwarding the client’s stdio. Edges reflect sampled calls or README statements; unsampled internals are represented at directory level.

Main entry points: [`internal/courts/client.go`](https://github.com/sakiphan/yargitay-mcp/blob/main/internal/courts/client.go) (Court Adapter), [`internal/cli/serve.go`](https://github.com/sakiphan/yargitay-mcp/blob/main/internal/cli/serve.go) (Serve Runtime), [`internal/server/server.go`](https://github.com/sakiphan/yargitay-mcp/blob/main/internal/server/server.go) (MCP Tools), [`internal/yargitay/client.go`](https://github.com/sakiphan/yargitay-mcp/blob/main/internal/yargitay/client.go) (Yargıtay Adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Local Runtime"]
  node_go_entry["Go Entry<br/>[main.go]"]
  node_cli["CLI Commands<br/>[app.go]"]
  node_serve["Serve Runtime<br/>[serve.go]"]
  node_mcp_server["MCP Tools<br/>[server.go]"]
  node_viewer["Decision Viewer<br/>[viewer.go]"]
  node_setup["Client Setup<br/>[setup.go]"]
end

subgraph group_courttools["Court Tools"]
  node_court_tooling["Court MCP Tools<br/>[courts.go]"]
  node_yargitay_search["Yargıtay Search<br/>[server.go]"]
  node_court_search["Other Court Search<br/>[search.go]"]
  node_court_documents["Court Documents<br/>[document.go]"]
  node_yargitay_adapter["Yargıtay Adapter<br/>[client.go]"]
end

subgraph group_core["Go Core"]
  node_shared_core["Shared Core"]
  node_court_adapter["Court Adapter<br/>[client.go]"]
end

subgraph group_distribution["npm Launcher"]
  node_npm_cli["npm CLI<br/>[cli.mjs]"]
  node_launcher["Binary Launcher<br/>[launcher.mjs]"]
end

node_mcp_client(("MCP Client"))
node_official_sources(("Official Court Sources"))
node_github_releases(("GitHub Releases"))

node_mcp_client -->|"starts server"| node_go_entry
node_go_entry -->|"dispatches to"| node_cli
node_cli -->|"runs serve"| node_serve
node_cli -->|"applies setup"| node_setup
node_serve -->|"creates tools"| node_mcp_server
node_serve -->|"creates sources"| node_court_adapter
node_mcp_client -->|"sends MCP requests"| node_mcp_server
node_mcp_server -->|"registers tools"| node_yargitay_search
node_mcp_server -->|"adds court tools"| node_court_tooling
node_court_tooling -->|"calls search"| node_court_search
node_court_tooling -->|"calls retrieval"| node_court_documents
node_court_search -->|"uses fetcher"| node_court_adapter
node_court_documents -->|"uses fetcher"| node_court_adapter
node_yargitay_search -->|"calls source"| node_yargitay_adapter
node_yargitay_adapter -->|"uses core"| node_shared_core
node_court_adapter -->|"builds official client"| node_shared_core
node_court_adapter -->|"requests decisions"| node_official_sources
node_yargitay_adapter -->|"fetches decisions"| node_official_sources
node_serve -->|"starts viewer"| node_viewer
node_viewer -->|"retrieves court text"| node_court_documents
node_viewer -->|"retrieves Yargıtay text"| node_yargitay_adapter
node_npm_cli -->|"ensures binary"| node_launcher
node_launcher -->|"downloads binary"| node_github_releases
node_launcher -->|"runs binary"| node_go_entry
node_mcp_client -->|"starts via npx"| node_npm_cli

click node_go_entry "https://github.com/sakiphan/yargitay-mcp/blob/main/cmd/yargitay-mcp/main.go"
click node_cli "https://github.com/sakiphan/yargitay-mcp/blob/main/internal/cli/app.go"
click node_serve "https://github.com/sakiphan/yargitay-mcp/blob/main/internal/cli/serve.go"
click node_mcp_server "https://github.com/sakiphan/yargitay-mcp/blob/main/internal/server/server.go"
click node_court_tooling "https://github.com/sakiphan/yargitay-mcp/blob/main/internal/server/courts.go"
click node_yargitay_search "https://github.com/sakiphan/yargitay-mcp/blob/main/internal/server/server.go"
click node_court_search "https://github.com/sakiphan/yargitay-mcp/blob/main/internal/courts/search.go"
click node_court_documents "https://github.com/sakiphan/yargitay-mcp/blob/main/internal/courts/document.go"
click node_yargitay_adapter "https://github.com/sakiphan/yargitay-mcp/blob/main/internal/yargitay/client.go"
click node_shared_core "https://github.com/sakiphan/yargitay-mcp/tree/main/internal/yargitay"
click node_court_adapter "https://github.com/sakiphan/yargitay-mcp/blob/main/internal/courts/client.go"
click node_viewer "https://github.com/sakiphan/yargitay-mcp/blob/main/internal/server/viewer.go"
click node_setup "https://github.com/sakiphan/yargitay-mcp/blob/main/internal/setup/setup.go"
click node_npm_cli "https://github.com/sakiphan/yargitay-mcp/blob/main/npm/bin/cli.mjs"
click node_launcher "https://github.com/sakiphan/yargitay-mcp/blob/main/npm/lib/launcher.mjs"

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_go_entry,node_cli,node_serve,node_mcp_server,node_viewer,node_setup,node_mcp_client toneBlue
class node_court_tooling,node_yargitay_search,node_court_search,node_court_documents,node_yargitay_adapter toneAmber
class node_shared_core,node_court_adapter toneMint
class node_npm_cli,node_launcher toneRose
class node_official_sources,node_github_releases toneIndigo
```

## Components

### Local Runtime

- [Go Entry](https://github.com/sakiphan/yargitay-mcp/blob/main/cmd/yargitay-mcp/main.go): `cmd/yargitay-mcp/main.go`
- [CLI Commands](https://github.com/sakiphan/yargitay-mcp/blob/main/internal/cli/app.go): `internal/cli/app.go`
- [Serve Runtime](https://github.com/sakiphan/yargitay-mcp/blob/main/internal/cli/serve.go): `internal/cli/serve.go`
- [MCP Tools](https://github.com/sakiphan/yargitay-mcp/blob/main/internal/server/server.go): `internal/server/server.go`
- [Decision Viewer](https://github.com/sakiphan/yargitay-mcp/blob/main/internal/server/viewer.go): `internal/server/viewer.go`
- [Client Setup](https://github.com/sakiphan/yargitay-mcp/blob/main/internal/setup/setup.go): `internal/setup/setup.go`

### Court Tools

- [Court MCP Tools](https://github.com/sakiphan/yargitay-mcp/blob/main/internal/server/courts.go): `internal/server/courts.go`
- [Yargıtay Search](https://github.com/sakiphan/yargitay-mcp/blob/main/internal/server/server.go): `internal/server/server.go`
- [Other Court Search](https://github.com/sakiphan/yargitay-mcp/blob/main/internal/courts/search.go): `internal/courts/search.go`
- [Court Documents](https://github.com/sakiphan/yargitay-mcp/blob/main/internal/courts/document.go): `internal/courts/document.go`
- [Yargıtay Adapter](https://github.com/sakiphan/yargitay-mcp/blob/main/internal/yargitay/client.go): `internal/yargitay/client.go`

### Go Core

- [Shared Core](https://github.com/sakiphan/yargitay-mcp/tree/main/internal/yargitay): `internal/yargitay`
- [Court Adapter](https://github.com/sakiphan/yargitay-mcp/blob/main/internal/courts/client.go): `internal/courts/client.go`

### npm Launcher

- [npm CLI](https://github.com/sakiphan/yargitay-mcp/blob/main/npm/bin/cli.mjs): `npm/bin/cli.mjs`
- [Binary Launcher](https://github.com/sakiphan/yargitay-mcp/blob/main/npm/lib/launcher.mjs): `npm/lib/launcher.mjs`

### Other components

- **MCP Client**
- **Official Court Sources**
- **GitHub Releases**

## Connections

- MCP Client → Go Entry: starts server (evidence: `README.md`)
- Go Entry → CLI Commands: dispatches to (evidence: `cmd/yargitay-mcp/main.go`)
- CLI Commands → Serve Runtime: runs serve (evidence: `internal/cli/app.go`)
- CLI Commands → Client Setup: applies setup (evidence: `internal/cli/app.go`)
- Serve Runtime → MCP Tools: creates tools (evidence: `internal/cli/serve.go`)
- Serve Runtime → Court Adapter: creates sources (evidence: `internal/cli/serve.go`)
- MCP Client → MCP Tools: sends MCP requests (evidence: `README.md`)
- MCP Tools → Yargıtay Search: registers tools (evidence: `internal/server/server.go`)
- MCP Tools → Court MCP Tools: adds court tools
- Court MCP Tools → Other Court Search: calls search (evidence: `internal/server/courts.go`)
- Court MCP Tools → Court Documents: calls retrieval (evidence: `internal/server/courts.go`)
- Other Court Search → Court Adapter: uses fetcher (evidence: `internal/courts/search.go`)
- Court Documents → Court Adapter: uses fetcher (evidence: `internal/courts/document.go`)
- Yargıtay Search → Yargıtay Adapter: calls source (evidence: `internal/server/server.go`)
- Yargıtay Adapter → Shared Core: uses core
- Court Adapter → Shared Core: builds official client (evidence: `internal/courts/client.go`)
- Court Adapter → Official Court Sources: requests decisions (evidence: `README.md`)
- Yargıtay Adapter → Official Court Sources: fetches decisions (evidence: `README.md`)
- Serve Runtime → Decision Viewer: starts viewer (evidence: `internal/cli/serve.go`)
- Decision Viewer → Court Documents: retrieves court text (evidence: `internal/server/viewer.go`)
- Decision Viewer → Yargıtay Adapter: retrieves Yargıtay text (evidence: `internal/server/viewer.go`)
- npm CLI → Binary Launcher: ensures binary (evidence: `npm/bin/cli.mjs`)
- Binary Launcher → GitHub Releases: downloads binary (evidence: `README.md`)
- Binary Launcher → Go Entry: runs binary (evidence: `npm/lib/launcher.mjs`)
- MCP Client → npm CLI: starts via npx (evidence: `README.md`)
