# xamie01/swat architecture

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

- Interactive diagram: https://gitdiagram.com/xamie01/swat
- Repository: https://github.com/xamie01/swat

## Overview

WAKE is a multi-chain, non-custodial copy-trading product. A user manages a followed trader (“master”) through the dashboard and API; WAKE ingests that master’s activity, evaluates per-master signals and safety, then sizes and executes mirrors under the user’s balance and risk settings. Scoring and clustering support wallet intelligence and discovery, while alerts report trade and ingestion status. The README documents the service-level pipeline; sampled source confirms selected auth, API-client, ingestion-health, and database details, so unsampled internal links are omitted.

Main entry points: [`apps/indexer/src/index.ts`](https://github.com/xamie01/swat/blob/main/apps/indexer/src/index.ts) (Multi-chain indexer), [`apps/trade-executor/src/index.ts`](https://github.com/xamie01/swat/blob/main/apps/trade-executor/src/index.ts) (Trade executor), [`packages/db/src`](https://github.com/xamie01/swat/tree/main/packages/db/src) (PostgreSQL data), [`apps/api/src/index.ts`](https://github.com/xamie01/swat/blob/main/apps/api/src/index.ts) (REST API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User access"]
  node_web["Dashboard"]
  node_webapi["Browser API client<br/>[api.ts]"]
  node_api["REST API<br/>[index.ts]"]
end

subgraph group_ingest["Wallet intelligence"]
  node_indexer["Multi-chain indexer<br/>[index.ts]"]
  node_scorer["Wallet scoring<br/>[index.ts]"]
  node_discovery["Wallet discovery<br/>[runner.ts]"]
end

subgraph group_control["Signals and control"]
  node_signals["Signal engine<br/>[index.ts]"]
  node_alerts["Alert service<br/>[index.ts]"]
end

subgraph group_execution["Trade execution"]
  node_executor["Trade executor<br/>[index.ts]"]
  node_solana{{"Solana venues"}}
  node_polymarket{{"Polymarket CLOB"}}
  node_robinhood{{"Robinhood Chain"}}
end

subgraph group_state["Persistence and operations"]
  node_db[("PostgreSQL data")]
  node_health["Ingestion health"]
end

node_user(("WAKE user"))
node_telegram{{"Telegram"}}

node_user -->|"manages wallets"| node_web
node_web -->|"requests data"| node_webapi
node_webapi -->|"calls API"| node_api
node_api -->|"authenticates users"| node_db
node_api -->|"triggers discovery"| node_discovery
node_indexer -->|"stores transactions"| node_db
node_indexer -->|"publishes swap events"| node_signals
node_indexer -->|"supplies wallet data"| node_scorer
node_scorer -->|"stores scores"| node_db
node_signals -->|"dispatches trades"| node_executor
node_signals -->|"dispatches alerts"| node_alerts
node_executor -->|"executes swaps"| node_solana
node_executor -->|"places orders"| node_polymarket
node_executor -->|"executes swaps"| node_robinhood
node_alerts -->|"sends notifications"| node_telegram
node_indexer -->|"records batch health"| node_health
node_health -->|"writes health records"| node_db

click node_web "https://github.com/xamie01/swat/tree/main/apps/web/app"
click node_webapi "https://github.com/xamie01/swat/blob/main/apps/web/lib/api.ts"
click node_api "https://github.com/xamie01/swat/blob/main/apps/api/src/index.ts"
click node_indexer "https://github.com/xamie01/swat/blob/main/apps/indexer/src/index.ts"
click node_scorer "https://github.com/xamie01/swat/blob/main/apps/scorer/src/index.ts"
click node_discovery "https://github.com/xamie01/swat/blob/main/apps/discovery/src/runner.ts"
click node_signals "https://github.com/xamie01/swat/blob/main/apps/signal-engine/src/index.ts"
click node_alerts "https://github.com/xamie01/swat/blob/main/apps/alert-service/src/index.ts"
click node_executor "https://github.com/xamie01/swat/blob/main/apps/trade-executor/src/index.ts"
click node_db "https://github.com/xamie01/swat/tree/main/packages/db/src"
click node_health "https://github.com/xamie01/swat/blob/main/packages/db/src/ingestion-health.ts"

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_web,node_webapi,node_api,node_user toneBlue
class node_indexer,node_scorer,node_discovery toneAmber
class node_signals,node_alerts toneMint
class node_executor,node_solana,node_polymarket,node_robinhood toneRose
class node_db,node_health,node_telegram toneIndigo
```

## Components

### User access

- [Dashboard](https://github.com/xamie01/swat/tree/main/apps/web/app): `apps/web/app`
- [Browser API client](https://github.com/xamie01/swat/blob/main/apps/web/lib/api.ts): `apps/web/lib/api.ts`
- [REST API](https://github.com/xamie01/swat/blob/main/apps/api/src/index.ts): `apps/api/src/index.ts`

### Wallet intelligence

- [Multi-chain indexer](https://github.com/xamie01/swat/blob/main/apps/indexer/src/index.ts): `apps/indexer/src/index.ts`
- [Wallet scoring](https://github.com/xamie01/swat/blob/main/apps/scorer/src/index.ts): `apps/scorer/src/index.ts`
- [Wallet discovery](https://github.com/xamie01/swat/blob/main/apps/discovery/src/runner.ts): `apps/discovery/src/runner.ts`

### Signals and control

- [Signal engine](https://github.com/xamie01/swat/blob/main/apps/signal-engine/src/index.ts): `apps/signal-engine/src/index.ts`
- [Alert service](https://github.com/xamie01/swat/blob/main/apps/alert-service/src/index.ts): `apps/alert-service/src/index.ts`

### Trade execution

- [Trade executor](https://github.com/xamie01/swat/blob/main/apps/trade-executor/src/index.ts): `apps/trade-executor/src/index.ts`
- **Solana venues**
- **Polymarket CLOB**
- **Robinhood Chain**

### Persistence and operations

- [PostgreSQL data](https://github.com/xamie01/swat/tree/main/packages/db/src): `packages/db/src`
- [Ingestion health](https://github.com/xamie01/swat/blob/main/packages/db/src/ingestion-health.ts): `packages/db/src/ingestion-health.ts`

### Other components

- **WAKE user**
- **Telegram**

## Connections

- WAKE user → Dashboard: manages wallets (evidence: `README.md`)
- Dashboard → Browser API client: requests data (evidence: `apps/web/lib/api.ts`)
- Browser API client → REST API: calls API (evidence: `apps/web/lib/api.ts`)
- REST API → PostgreSQL data: authenticates users
- REST API → Wallet discovery: triggers discovery (evidence: `README.md`)
- Multi-chain indexer → PostgreSQL data: stores transactions (evidence: `README.md`)
- Multi-chain indexer → Signal engine: publishes swap events (evidence: `README.md`)
- Multi-chain indexer → Wallet scoring: supplies wallet data (evidence: `README.md`)
- Wallet scoring → PostgreSQL data: stores scores (evidence: `README.md`)
- Signal engine → Trade executor: dispatches trades (evidence: `README.md`)
- Signal engine → Alert service: dispatches alerts (evidence: `README.md`)
- Trade executor → Solana venues: executes swaps (evidence: `README.md`)
- Trade executor → Polymarket CLOB: places orders (evidence: `README.md`)
- Trade executor → Robinhood Chain: executes swaps (evidence: `README.md`)
- Alert service → Telegram: sends notifications (evidence: `README.md`)
- Multi-chain indexer → Ingestion health: records batch health
- Ingestion health → PostgreSQL data: writes health records (evidence: `packages/db/src/ingestion-health.ts`)
