# demwick/hukuk-agent architecture

> Architecture diagram of the GitHub repository demwick/hukuk-agent, 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/demwick/hukuk-agent
- Repository: https://github.com/demwick/hukuk-agent

## Overview

hukuk-agent is a Turkish-law document-drafting assistant for Claude Code, implemented as a local MCP server plus a hub/branch skill. The documented workflow selects a legal branch and document type, anonymizes personal data, researches legislation, optionally calculates compensation and court fees, retrieves a template, restores personal data, and returns a draft for lawyer review. The graph includes the documented skill workflow and the sampled MCP tool, calculation, template, and database layers. Some skill and PII-restore wiring is documented but not shown in sampled implementation, so those links cite the README.

Main entry points: [`mcp-server/index.ts`](https://github.com/demwick/hukuk-agent/blob/main/mcp-server/index.ts) (MCP server), [`mcp-server/lib/paths.ts`](https://github.com/demwick/hukuk-agent/blob/main/mcp-server/lib/paths.ts) (Data path resolver), [`mcp-server/tools/sablon-getir.ts`](https://github.com/demwick/hukuk-agent/blob/main/mcp-server/tools/sablon-getir.ts) (Template retrieval), [`mcp-server/tools/is-hukuku/tazminat-hesapla.ts`](https://github.com/demwick/hukuk-agent/blob/main/mcp-server/tools/is-hukuku/tazminat-hesapla.ts) (Compensation tool)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Assistant workflow"]
  node_hub["Hub skill<br/>[SKILL.md]"]
  node_labor_skill["Labor-law skill<br/>[is-hukuku.md]"]
  node_draft["Drafted document"]
end

subgraph group_mcp["MCP tools"]
  node_server["MCP server<br/>[index.ts]"]
  node_search_tool["Legislation search<br/>[mevzuat-ara.ts]"]
  node_save_tool["Legislation save<br/>[mevzuat-kaydet.ts]"]
  node_template_tool["Template retrieval<br/>[sablon-getir.ts]"]
  node_comp_tool["Compensation tool"]
  node_fee_tool["Court-fee tool<br/>[harc-hesapla.ts]"]
end

subgraph group_legal["Legal services"]
  node_comp_math["Compensation rules<br/>[hesaplama.ts]"]
  node_deductions["Tax deductions<br/>[kesinti.ts]"]
  node_rates["Court-fee rates<br/>[harc-oranlari.json]"]
  node_templates["Labor templates"]
end

subgraph group_privacy["PII protection"]
  node_anon_tool["PII anonymizer"]
  node_restore_tool["PII restorer<br/>[pii-geri-yukle.ts]"]
  node_patterns["PII patterns<br/>[pii-patterns.ts]"]
end

subgraph group_data["Local data"]
  node_db_api["Database access<br/>[db.ts]"]
  node_legislation_db[("Legislation database")]
  node_data_paths["Data path resolver<br/>[paths.ts]"]
  node_comp_caps["Compensation caps<br/>[tavan.json]"]
  node_deduction_rates["Deduction rates"]
end

node_lawyer(("Lawyer"))
node_claude(("Claude Code"))

node_lawyer -->|"requests draft"| node_claude
node_claude -->|"invokes skill"| node_hub
node_hub -->|"selects branch"| node_labor_skill
node_labor_skill -->|"guides workflow"| node_claude
node_claude -->|"calls tools"| node_server
node_server -->|"dispatches"| node_search_tool
node_server -->|"dispatches"| node_save_tool
node_server -->|"dispatches"| node_template_tool
node_server -->|"dispatches"| node_comp_tool
node_server -->|"dispatches"| node_fee_tool
node_server -->|"dispatches"| node_anon_tool
node_server -->|"dispatches"| node_restore_tool
node_anon_tool -->|"detects PII"| node_patterns
node_search_tool -->|"searches records"| node_db_api
node_save_tool -->|"inserts records"| node_db_api
node_db_api -->|"reads and writes"| node_legislation_db
node_comp_tool -->|"calculates awards"| node_comp_math
node_comp_tool -->|"calculates net"| node_deductions
node_fee_tool -->|"loads rates"| node_rates
node_template_tool -->|"reads template"| node_templates
node_comp_math -->|"loads caps"| node_comp_caps
node_deductions -->|"loads rates"| node_deduction_rates
node_server -->|"resolves data"| node_data_paths
node_comp_math -->|"resolves data"| node_data_paths
node_deductions -->|"resolves data"| node_data_paths
node_fee_tool -->|"resolves data"| node_data_paths
node_template_tool -->|"resolves data"| node_data_paths
node_claude -->|"anonymizes input"| node_anon_tool
node_claude -->|"researches law"| node_search_tool
node_claude -->|"calculates damages"| node_comp_tool
node_claude -->|"calculates fees"| node_fee_tool
node_claude -->|"gets template"| node_template_tool
node_claude -->|"restores PII"| node_restore_tool
node_claude -->|"returns draft"| node_draft
node_draft -->|"requires review"| node_lawyer

click node_hub "https://github.com/demwick/hukuk-agent/blob/main/skill/SKILL.md"
click node_labor_skill "https://github.com/demwick/hukuk-agent/blob/main/skill/is-hukuku.md"
click node_server "https://github.com/demwick/hukuk-agent/blob/main/mcp-server/index.ts"
click node_search_tool "https://github.com/demwick/hukuk-agent/blob/main/mcp-server/tools/mevzuat-ara.ts"
click node_save_tool "https://github.com/demwick/hukuk-agent/blob/main/mcp-server/tools/mevzuat-kaydet.ts"
click node_template_tool "https://github.com/demwick/hukuk-agent/blob/main/mcp-server/tools/sablon-getir.ts"
click node_comp_tool "https://github.com/demwick/hukuk-agent/blob/main/mcp-server/tools/is-hukuku/tazminat-hesapla.ts"
click node_fee_tool "https://github.com/demwick/hukuk-agent/blob/main/mcp-server/tools/is-hukuku/harc-hesapla.ts"
click node_anon_tool "https://github.com/demwick/hukuk-agent/blob/main/mcp-server/tools/pii-anonimlestir.ts"
click node_restore_tool "https://github.com/demwick/hukuk-agent/blob/main/mcp-server/tools/pii-geri-yukle.ts"
click node_patterns "https://github.com/demwick/hukuk-agent/blob/main/mcp-server/lib/pii-patterns.ts"
click node_comp_math "https://github.com/demwick/hukuk-agent/blob/main/mcp-server/lib/is-hukuku/hesaplama.ts"
click node_deductions "https://github.com/demwick/hukuk-agent/blob/main/mcp-server/lib/is-hukuku/kesinti.ts"
click node_rates "https://github.com/demwick/hukuk-agent/blob/main/data/harc-oranlari.json"
click node_templates "https://github.com/demwick/hukuk-agent/tree/main/data/sablonlar/is-hukuku"
click node_db_api "https://github.com/demwick/hukuk-agent/blob/main/mcp-server/lib/db.ts"
click node_data_paths "https://github.com/demwick/hukuk-agent/blob/main/mcp-server/lib/paths.ts"
click node_comp_caps "https://github.com/demwick/hukuk-agent/blob/main/data/tavan.json"
click node_deduction_rates "https://github.com/demwick/hukuk-agent/blob/main/data/kesinti-oranlari.json"

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_hub,node_labor_skill,node_draft toneBlue
class node_server,node_search_tool,node_save_tool,node_template_tool,node_comp_tool,node_fee_tool toneAmber
class node_comp_math,node_deductions,node_rates,node_templates toneMint
class node_anon_tool,node_restore_tool,node_patterns toneRose
class node_db_api,node_legislation_db,node_data_paths,node_comp_caps,node_deduction_rates,node_lawyer,node_claude toneIndigo
```

## Components

### Assistant workflow

- [Hub skill](https://github.com/demwick/hukuk-agent/blob/main/skill/SKILL.md): `skill/SKILL.md`
- [Labor-law skill](https://github.com/demwick/hukuk-agent/blob/main/skill/is-hukuku.md): `skill/is-hukuku.md`
- **Drafted document**

### MCP tools

- [MCP server](https://github.com/demwick/hukuk-agent/blob/main/mcp-server/index.ts): `mcp-server/index.ts`
- [Legislation search](https://github.com/demwick/hukuk-agent/blob/main/mcp-server/tools/mevzuat-ara.ts): `mcp-server/tools/mevzuat-ara.ts`
- [Legislation save](https://github.com/demwick/hukuk-agent/blob/main/mcp-server/tools/mevzuat-kaydet.ts): `mcp-server/tools/mevzuat-kaydet.ts`
- [Template retrieval](https://github.com/demwick/hukuk-agent/blob/main/mcp-server/tools/sablon-getir.ts): `mcp-server/tools/sablon-getir.ts`
- [Compensation tool](https://github.com/demwick/hukuk-agent/blob/main/mcp-server/tools/is-hukuku/tazminat-hesapla.ts): `mcp-server/tools/is-hukuku/tazminat-hesapla.ts`
- [Court-fee tool](https://github.com/demwick/hukuk-agent/blob/main/mcp-server/tools/is-hukuku/harc-hesapla.ts): `mcp-server/tools/is-hukuku/harc-hesapla.ts`

### Legal services

- [Compensation rules](https://github.com/demwick/hukuk-agent/blob/main/mcp-server/lib/is-hukuku/hesaplama.ts): `mcp-server/lib/is-hukuku/hesaplama.ts`
- [Tax deductions](https://github.com/demwick/hukuk-agent/blob/main/mcp-server/lib/is-hukuku/kesinti.ts): `mcp-server/lib/is-hukuku/kesinti.ts`
- [Court-fee rates](https://github.com/demwick/hukuk-agent/blob/main/data/harc-oranlari.json): `data/harc-oranlari.json`
- [Labor templates](https://github.com/demwick/hukuk-agent/tree/main/data/sablonlar/is-hukuku): `data/sablonlar/is-hukuku`

### PII protection

- [PII anonymizer](https://github.com/demwick/hukuk-agent/blob/main/mcp-server/tools/pii-anonimlestir.ts): `mcp-server/tools/pii-anonimlestir.ts`
- [PII restorer](https://github.com/demwick/hukuk-agent/blob/main/mcp-server/tools/pii-geri-yukle.ts): `mcp-server/tools/pii-geri-yukle.ts`
- [PII patterns](https://github.com/demwick/hukuk-agent/blob/main/mcp-server/lib/pii-patterns.ts): `mcp-server/lib/pii-patterns.ts`

### Local data

- [Database access](https://github.com/demwick/hukuk-agent/blob/main/mcp-server/lib/db.ts): `mcp-server/lib/db.ts`
- **Legislation database**
- [Data path resolver](https://github.com/demwick/hukuk-agent/blob/main/mcp-server/lib/paths.ts): `mcp-server/lib/paths.ts`
- [Compensation caps](https://github.com/demwick/hukuk-agent/blob/main/data/tavan.json): `data/tavan.json`
- [Deduction rates](https://github.com/demwick/hukuk-agent/blob/main/data/kesinti-oranlari.json): `data/kesinti-oranlari.json`

### Other components

- **Lawyer**
- **Claude Code**

## Connections

- Lawyer → Claude Code: requests draft (evidence: `README.md`)
- Claude Code → Hub skill: invokes skill (evidence: `README.md`)
- Hub skill → Labor-law skill: selects branch (evidence: `README.md`)
- Labor-law skill → Claude Code: guides workflow (evidence: `README.md`)
- Claude Code → MCP server: calls tools (evidence: `README.md`)
- MCP server → Legislation search: dispatches (evidence: `mcp-server/index.ts`)
- MCP server → Legislation save: dispatches (evidence: `mcp-server/index.ts`)
- MCP server → Template retrieval: dispatches (evidence: `mcp-server/index.ts`)
- MCP server → Compensation tool: dispatches (evidence: `mcp-server/index.ts`)
- MCP server → Court-fee tool: dispatches (evidence: `mcp-server/index.ts`)
- MCP server → PII anonymizer: dispatches (evidence: `mcp-server/index.ts`)
- MCP server → PII restorer: dispatches (evidence: `mcp-server/index.ts`)
- PII anonymizer → PII patterns: detects PII (evidence: `mcp-server/tools/pii-anonimlestir.ts`)
- Legislation search → Database access: searches records (evidence: `mcp-server/tools/mevzuat-ara.ts`)
- Legislation save → Database access: inserts records (evidence: `mcp-server/tools/mevzuat-kaydet.ts`)
- Database access → Legislation database: reads and writes (evidence: `mcp-server/lib/db.ts`)
- Compensation tool → Compensation rules: calculates awards (evidence: `mcp-server/tools/is-hukuku/tazminat-hesapla.ts`)
- Compensation tool → Tax deductions: calculates net (evidence: `mcp-server/tools/is-hukuku/tazminat-hesapla.ts`)
- Court-fee tool → Court-fee rates: loads rates (evidence: `mcp-server/tools/is-hukuku/harc-hesapla.ts`)
- Template retrieval → Labor templates: reads template (evidence: `mcp-server/tools/sablon-getir.ts`)
- Compensation rules → Compensation caps: loads caps (evidence: `mcp-server/lib/is-hukuku/hesaplama.ts`)
- Tax deductions → Deduction rates: loads rates (evidence: `mcp-server/lib/is-hukuku/kesinti.ts`)
- MCP server → Data path resolver: resolves data (evidence: `mcp-server/index.ts`)
- Compensation rules → Data path resolver: resolves data (evidence: `mcp-server/lib/is-hukuku/hesaplama.ts`)
- Tax deductions → Data path resolver: resolves data (evidence: `mcp-server/lib/is-hukuku/kesinti.ts`)
- Court-fee tool → Data path resolver: resolves data (evidence: `mcp-server/tools/is-hukuku/harc-hesapla.ts`)
- Template retrieval → Data path resolver: resolves data (evidence: `mcp-server/tools/sablon-getir.ts`)
- Claude Code → PII anonymizer: anonymizes input (evidence: `README.md`)
- Claude Code → Legislation search: researches law (evidence: `README.md`)
- Claude Code → Compensation tool: calculates damages (evidence: `README.md`)
- Claude Code → Court-fee tool: calculates fees (evidence: `README.md`)
- Claude Code → Template retrieval: gets template (evidence: `README.md`)
- Claude Code → PII restorer: restores PII (evidence: `README.md`)
- Claude Code → Drafted document: returns draft (evidence: `README.md`)
- Drafted document → Lawyer: requires review (evidence: `README.md`)
