> For the complete documentation index, see [llms.txt](https://docs.yemreak.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yemreak.com/contents/9a141a85.md).

# Hub: Merkezi Router

Niye böyle bir şey kuruyorum? Çünkü çok sıkıntılı. Kimin neyle haberleştiğini göremiyorum. macOS-helper'da çalışırken debug yapmamız gerekiyor. Her seferinde custom, farklı yapılara bakmam gerekiyor. Bütün sistemlerin birbirine etkileşim halinde olmasını istiyorum. Bana haz veriyor. Mesela macOS'i backend'de kullanabiliyoruz ama hotkey yapıları çok sıkıntılı oluyor. Tekerleği yeniden icat etmek yerine Hammerspoon'un hotkeyini kullanıyorum. macOS uygulamam var, Telegram uygulamam var, Whisper uygulaması var. Bir sürü farklı application'lar var. Hepsi birbirleriyle etkileşim halinde olsun. Ben onların communication'ını dizayn edeyim. Orchestrate edeyim. Ne oluyor, ne bitiyor göreyim. Agent de görsün. Agent'lar çalışsın. Böyle bir medeniyet olsun. Katman katman. Böyle bir arzım var. Bu yüzden bu sistemlerle uğraşıyorum.

## Architecture Flow

```sh
FINAL ARCHITECTURE

  ┌──────────────────────────────────────────────────────────┐
  │ CLIENTS (Send requests to Hub)                           │
  ├──────────────────────────────────────────────────────────┤
  │ clients/telegram/yemreak/     → Voice, text, commands    │
  │ clients/hammerspoon/          → macOS automation         │
  │ clients/cli/                  → gitc, stt, fetch         │
  │ clients/vscode/               → Extensions               │
  └──────────────────────────────────────────────────────────┘
                          ↓ HTTP :8772 (JSON-RPC)
  ┌──────────────────────────────────────────────────────────┐
  │ HUB (Central Router)                                     │
  ├──────────────────────────────────────────────────────────┤
  │ hub/server.ts                 → Request router           │
  │ hub/ports/registry.ts         → Port discovery           │
  └──────────────────────────────────────────────────────────┘
                          ↓ registry.call()
  ┌──────────────────────────────────────────────────────────┐
  │ LAYERS (Receive from Hub, proxy to external services)   │
  ├──────────────────────────────────────────────────────────┤
  │ layers/api/           → Raw API clients                  │
  │ ├─ whisper.ts         → :8770 WebSocket                  │
  │ ├─ macos.ts           → :8766 HTTP                       │
  │ ├─ chrome.ts          → Chrome DevTools WebSocket        │
  │ └─ yemreak.ts         → Telegram bot API                 │
  │                                                          │
  │ layers/protocol/      → JSON-RPC wrappers                │
  │ ├─ whisper.ts                                            │
  │ ├─ macos.ts                                              │
  │ ├─ chrome.ts                                             │
  │ └─ yemreak.ts                                            │
  │                                                          │
  │ layers/hub/           → Hub adapters (PortAdapter)       │
  │ ├─ whisper.ts                                            │
  │ ├─ macos.ts                                              │
  │ ├─ chrome.ts                                             │
  │ └─ yemreak.ts                                            │
  └──────────────────────────────────────────────────────────┘
                          ↓ import
  ┌──────────────────────────────────────────────────────────┐
  │ FLOWS (Orchestration)                                    │
  ├──────────────────────────────────────────────────────────┤
  │ flows/transcribe.ts           → whisper + DB save        │
  │ flows/media-extract.ts        → download + compress      │
  └──────────────────────────────────────────────────────────┘
                          ↓ import
  ┌──────────────────────────────────────────────────────────┐
  │ CORE (Pure business logic)                               │
  ├──────────────────────────────────────────────────────────┤
  │ core/trading/price.ts     → Price calculations           │
  │ core/llm/compress.ts          → Text processing          │
  │ core/analytics/infer-tags.ts  → Tag inference            │
  └──────────────────────────────────────────────────────────┘
                          ↓ import
  ┌──────────────────────────────────────────────────────────┐
  │ INFRA (Database, cache, credentials)                     │
  ├──────────────────────────────────────────────────────────┤
  │ infra/database/               → Supabase clients         │
  │ infra/cache.ts                → Redis wrapper            │
  │ infra/credentials.ts          → Env management           │
  └──────────────────────────────────────────────────────────┘

  PROJECT STRUCTURE

  src/
  ├─ clients/
  │  ├─ telegram/
  │  │  ├─ yemreak/
  │  │  │  ├─ handlers/
  │  │  │  │  ├─ message.text.ts
  │  │  │  │  ├─ message.voice.ts
  │  │  │  │  └─ command.agent.ts
  │  │  │  ├─ client.ts          # Hub client instance
  │  │  │  ├─ bot.ts             # PM2 entry
  │  │  │  └─ config.ts
  │  │  └─ (ytrader separate if needed)
  │  │
  │  ├─ hammerspoon/
  │  │  ├─ modules/
  │  │  │  ├─ dictation.lua
  │  │  │  └─ activity-tracker.lua
  │  │  ├─ client.lua            # jsonrpc.lua
  │  │  └─ init.lua
  │  │
  │  ├─ cli/
  │  │  ├─ commands/
  │  │  │  ├─ gitc.ts
  │  │  │  ├─ stt.ts
  │  │  │  └─ fetch.ts
  │  │  └─ client.ts
  │  │
  │  └─ vscode/
  │     ├─ bridge/
  │     ├─ commands/
  │     └─ theme/
  │
  ├─ hub/
  │  ├─ server.ts                # HTTP :8772
  │  ├─ types.ts                 # JSON-RPC types
  │  ├─ ports/
  │  │  └─ registry.ts
  │  └─ tests/
  │     ├─ health.sh
  │     └─ whisper.sh
  │
  ├─ layers/
  │  ├─ api/
  │  │  ├─ whisper.ts            # :8770 WebSocket
  │  │  ├─ macos.ts              # :8766 HTTP
  │  │  ├─ chrome.ts             # Chrome CDP
  │  │  ├─ vscode.ts             # Extension API
  │  │  └─ yemreak.ts            # Telegram API
  │  │
  │  ├─ protocol/
  │  │  ├─ whisper.ts
  │  │  ├─ macos.ts
  │  │  ├─ chrome.ts
  │  │  ├─ vscode.ts
  │  │  └─ yemreak.ts
  │  │
  │  └─ hub/
  │     ├─ whisper.ts
  │     ├─ macos.ts
  │     ├─ chrome.ts
  │     ├─ vscode.ts
  │     └─ yemreak.ts
  │
  ├─ flows/
  │  ├─ transcribe.ts
  │  ├─ media-extract.ts
  │  └─ text-transform.ts
  │
  ├─ core/
  │  ├─ trading/
  │  │  └─ price.ts             # Price calculations
  │  ├─ llm/
  │  │  ├─ compress.ts
  │  │  └─ translate.ts
  │  └─ analytics/
  │     └─ infer-tags.ts
  │
  └─ infra/
     ├─ database/
     │  ├─ personal/
     │  └─ private/
     ├─ cache.ts
     └─ credentials.ts

  FLOW EXAMPLES

  1. Telegram voice → transcribe:
  User → Telegram voice
  clients/telegram/yemreak/handlers/message.voice.ts
  → hub.call("whisper.transcribe", {audio_path})
  → hub/server.ts
    → registry.call("whisper.transcribe")
      → layers/hub/whisper.ts
        → layers/protocol/whisper.ts
          → layers/api/whisper.ts
            → WebSocket :8770
  → result
  → hub.call("yemreak.sendMessage", {text})
  → layers/hub/yemreak.ts
    → Telegram API

TSCONFIG PATHS

  {
    "@clients/*": ["src/clients/*"],
    "@hub/*": ["src/hub/*"],
    "@layers/*": ["src/layers/*"],
    "@flows/*": ["src/flows/*"],
    "@core/*": ["src/core/*"],
    "@infra/*": ["src/infra/*"]
  }
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yemreak.com/contents/9a141a85.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
