Hub-Based Architecture: MCP, JSON-RPC ile Merkezi Sistem

MCP, JSON-RPC, WebSocket ve HTTP protokolleriyle merkezi hub üzerinden her şeyin birbiriyle iletişim kurduğu bir sistem kuruyorum. ~80% tamamlandı, mimari keşif aşamasında.

r/ClaudeCoder/ClaudeAIr/ExperiencedDevsr/backendr/softwarearchitecture

MCP, JSON-RPC, WebSocket ve HTTP protokolleriyle merkezi hub üzerinden her şeyin birbiriyle iletişim kurduğu bir sistem kuruyorum. Şu an %80 oranında tamamlandı, gerekirse mimariyi ayarlayacağım. Hedef: keşif ve fikirleri modelleme.

Bildiklerim: MCP, JSON-RPC, n8n, VSCode/Claude Code settings.json gibi YAML konfigürasyonları Claude Code hook sistemi

Değerlerim: Initial ∞ OK, Operational → 0

  1. Compile > Runtime (+500 LOC types → 0 runtime error)

  2. Centralized > Distributed (+Hub → 1 terminal)

  3. Auto > Manual (+PM2 → 0 restart action)

  4. Linkage > Search (+ts-morph → 0 find-replace)

  5. Introspection > Docs (+API → 0 outdated)

  6. Single > Multiple (+Router → 0 cognitive)

Hangi teknolojileri veya anahtar kelimeleri bilmem gerekir? Finansal olarak özgürüm, yani ücretsiz olmak zorunda değil ama ROI yüksek olsun lütfen.

Architecture Flow

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/*"]
  }

Last updated

Was this helpful?