# aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver architecture

> Architecture diagram of the GitHub repository aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver, 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/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver
- Repository: https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver

## Overview

This is a stdio-only MCP server for searching Yargıtay precedent decisions. The principal workflow dispatches a search request, checks memory and PostgreSQL cache tiers, scrapes the court site on a miss, and returns structured results. Separate MCP tools expose health, cache statistics, popular queries, analytics, and cache clearing. The graph combines sampled call paths with README-documented capabilities; unsampled tool-handler details are represented at the server entry point rather than inferred.

Main entry points: [`src/services/unified-cache.ts`](https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/services/unified-cache.ts) (Unified cache), [`src/index.ts`](https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/index.ts) (MCP server), [`src/services/browserless.ts`](https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/services/browserless.ts) (Court scraper), [`src/services/database.ts`](https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/services/database.ts) (Database service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["MCP interface"]
  node_server["MCP server<br/>[index.ts]"]
  node_search_handler["Search handler<br/>[index.ts]"]
  node_other_tools["Operational tools<br/>[index.ts]"]
end

subgraph group_search["Search and cache"]
  node_cache["Unified cache<br/>[unified-cache.ts]"]
  node_memory["Memory cache<br/>[cache.ts]"]
end

subgraph group_scrape["Scraping"]
  node_scraper["Court scraper<br/>[browserless.ts]"]
  node_processor["Content processor"]
end

subgraph group_persistence["Persistence and configuration"]
  node_repository["Search repository<br/>[repository.ts]"]
  node_db_service["Database service<br/>[database.ts]"]
  node_config["Runtime config<br/>[config.ts]"]
  node_schema["Database schema<br/>[schema.sql]"]
end

node_client(("MCP client"))
node_postgres[("PostgreSQL")]
node_browserless["Browserless"]
node_court_site["Yargıtay site"]

node_client -->|"stdio requests"| node_server
node_server -->|"dispatches search"| node_search_handler
node_server -->|"dispatches tools"| node_other_tools
node_search_handler -->|"checks cache"| node_cache
node_search_handler -->|"scrapes on miss"| node_scraper
node_search_handler -->|"invalidates refresh"| node_cache
node_cache -->|"reads and writes"| node_memory
node_cache -->|"reads and writes"| node_repository
node_repository -->|"queries"| node_db_service
node_db_service -->|"executes SQL"| node_postgres
node_scraper -->|"connects via Puppeteer"| node_browserless
node_scraper -->|"searches and reads"| node_court_site
node_scraper -->|"processes content"| node_processor
node_server -->|"initializes database"| node_db_service
node_server -->|"validates settings"| node_config
node_scraper -->|"reads settings"| node_config
node_cache -->|"reads TTL settings"| node_config
node_other_tools -->|"reports cache stats"| node_cache
node_other_tools -->|"checks health"| node_db_service
node_other_tools -.->|"reads query analytics"| node_repository
node_other_tools -.->|"clears cache"| node_cache
node_schema -->|"defines tables"| node_postgres

click node_server "https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/index.ts"
click node_search_handler "https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/index.ts"
click node_other_tools "https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/index.ts"
click node_cache "https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/services/unified-cache.ts"
click node_memory "https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/services/cache.ts"
click node_repository "https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/services/repository.ts"
click node_db_service "https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/services/database.ts"
click node_scraper "https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/services/browserless.ts"
click node_processor "https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/services/content-processor.ts"
click node_config "https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/config/config.ts"
click node_schema "https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/database/schema.sql"

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_server,node_search_handler,node_other_tools,node_client,node_browserless toneBlue
class node_cache,node_memory,node_postgres toneAmber
class node_scraper,node_processor toneMint
class node_repository,node_db_service,node_config,node_schema toneRose
class node_court_site toneIndigo
```

## Components

### MCP interface

- [MCP server](https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/index.ts): `src/index.ts`
- [Search handler](https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/index.ts): `src/index.ts`
- [Operational tools](https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/index.ts): `src/index.ts`

### Search and cache

- [Unified cache](https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/services/unified-cache.ts): `src/services/unified-cache.ts`
- [Memory cache](https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/services/cache.ts): `src/services/cache.ts`

### Scraping

- [Court scraper](https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/services/browserless.ts): `src/services/browserless.ts`
- [Content processor](https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/services/content-processor.ts): `src/services/content-processor.ts`

### Persistence and configuration

- [Search repository](https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/services/repository.ts): `src/services/repository.ts`
- [Database service](https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/services/database.ts): `src/services/database.ts`
- [Runtime config](https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/config/config.ts): `src/config/config.ts`
- [Database schema](https://github.com/aliozkanozdurmus/veniai-hukuk-emsalkarar-mcpserver/blob/main/src/database/schema.sql): `src/database/schema.sql`

### Other components

- **MCP client**
- **PostgreSQL**
- **Browserless**
- **Yargıtay site**

## Connections

- MCP client → MCP server: stdio requests (evidence: `README.md`)
- MCP server → Search handler: dispatches search (evidence: `src/index.ts`)
- MCP server → Operational tools: dispatches tools (evidence: `src/index.ts`)
- Search handler → Unified cache: checks cache (evidence: `src/index.ts`)
- Search handler → Court scraper: scrapes on miss (evidence: `src/index.ts`)
- Search handler → Unified cache: invalidates refresh (evidence: `src/index.ts`)
- Unified cache → Memory cache: reads and writes (evidence: `src/services/unified-cache.ts`)
- Unified cache → Search repository: reads and writes (evidence: `src/services/unified-cache.ts`)
- Search repository → Database service: queries (evidence: `src/services/repository.ts`)
- Database service → PostgreSQL: executes SQL (evidence: `src/services/database.ts`)
- Court scraper → Browserless: connects via Puppeteer (evidence: `src/services/browserless.ts`)
- Court scraper → Yargıtay site: searches and reads (evidence: `src/services/browserless.ts`)
- Court scraper → Content processor: processes content (evidence: `src/services/browserless.ts`)
- MCP server → Database service: initializes database (evidence: `src/index.ts`)
- MCP server → Runtime config: validates settings (evidence: `src/index.ts`)
- Court scraper → Runtime config: reads settings (evidence: `src/services/browserless.ts`)
- Unified cache → Runtime config: reads TTL settings (evidence: `src/services/unified-cache.ts`)
- Operational tools → Unified cache: reports cache stats (evidence: `src/index.ts`)
- Operational tools → Database service: checks health (evidence: `src/index.ts`)
- Operational tools → Search repository: reads query analytics (evidence: `README.md`)
- Operational tools → Unified cache: clears cache (evidence: `README.md`)
- Database schema → PostgreSQL: defines tables (evidence: `README.md`)
