# alsk1992/cloddsbot architecture

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

- Interactive diagram: https://gitdiagram.com/alsk1992/cloddsbot
- Repository: https://github.com/alsk1992/cloddsbot

## Overview

Clodds is an AI-powered trading terminal for prediction markets, crypto and futures, operated through messaging channels or its WebChat. The principal workflow is a user request entering the gateway, being handled by the agent and its skills, then using market data and opportunity analysis to inform risk checks and execution; portfolio services track resulting positions. The README also describes broad exchange coverage, automation, token security, and Bittensor mining. Connections reflect README statements and available source references; unsampled implementation details are not asserted.

Main entry points: [`src/agents/index.ts`](https://github.com/alsk1992/cloddsbot/blob/main/src/agents/index.ts) (AI agents), [`src/gateway/index.ts`](https://github.com/alsk1992/cloddsbot/blob/main/src/gateway/index.ts) (HTTP gateway), [`src/execution/index.ts`](https://github.com/alsk1992/cloddsbot/blob/main/src/execution/index.ts) (Trade execution), [`src/channels/index.ts`](https://github.com/alsk1992/cloddsbot/blob/main/src/channels/index.ts) (Messaging channels)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interaction"]
  node_channels["Messaging channels<br/>[index.ts]"]
  node_webchat["WebChat<br/>[app.js]"]
end

subgraph group_intelligence["Agent and analysis"]
  node_agents["AI agents<br/>[index.ts]"]
  node_skills["Skills system<br/>[executor.ts]"]
  node_feeds["Market feeds<br/>[index.ts]"]
  node_opportunity["Opportunity analysis<br/>[index.ts]"]
end

subgraph group_trading["Trading services"]
  node_risk["Risk engine<br/>[engine.ts]"]
  node_execution["Trade execution<br/>[index.ts]"]
  node_positions["Position management"]
  node_portfolio["Portfolio tracking<br/>[index.ts]"]
end

subgraph group_platform["Runtime platform"]
  node_gateway["HTTP gateway<br/>[index.ts]"]
  node_database[("SQLite persistence<br/>[index.ts]")]
  node_automation["Scheduled automation<br/>[index.ts]"]
end

subgraph group_specialized["Specialized capabilities"]
  node_security["Token security<br/>[index.ts]"]
  node_bittensor["Bittensor mining<br/>[service.ts]"]
  node_mcp["MCP server<br/>[server.ts]"]
  node_backtesting["Strategy backtesting<br/>[backtest.ts]"]
end

node_user(("Trader"))

node_user -->|"messages"| node_channels
node_user -->|"chats"| node_webchat
node_channels -.->|"uses gateway"| node_gateway
node_webchat -.->|"uses gateway"| node_gateway
node_gateway -.->|"routes requests"| node_agents
node_agents -.->|"uses skills"| node_skills
node_agents -.->|"gets market data"| node_feeds
node_feeds -->|"supplies markets"| node_opportunity
node_gateway -->|"calls execution"| node_execution
node_gateway -->|"routes backtests"| node_backtesting
node_execution -.->|"checks risk"| node_risk
node_execution -->|"uses manager"| node_positions
node_risk -->|"reads positions"| node_positions
node_portfolio -->|"persists data"| node_database
node_agents -.->|"schedules tasks"| node_automation
node_agents -.->|"uses protection"| node_security
node_agents -.->|"supports mining"| node_bittensor
node_mcp -->|"exposes tools"| node_skills

click node_channels "https://github.com/alsk1992/cloddsbot/blob/main/src/channels/index.ts"
click node_webchat "https://github.com/alsk1992/cloddsbot/blob/main/public/webchat/js/app.js"
click node_gateway "https://github.com/alsk1992/cloddsbot/blob/main/src/gateway/index.ts"
click node_agents "https://github.com/alsk1992/cloddsbot/blob/main/src/agents/index.ts"
click node_skills "https://github.com/alsk1992/cloddsbot/blob/main/src/skills/executor.ts"
click node_feeds "https://github.com/alsk1992/cloddsbot/blob/main/src/feeds/index.ts"
click node_opportunity "https://github.com/alsk1992/cloddsbot/blob/main/src/opportunity/index.ts"
click node_risk "https://github.com/alsk1992/cloddsbot/blob/main/src/risk/engine.ts"
click node_execution "https://github.com/alsk1992/cloddsbot/blob/main/src/execution/index.ts"
click node_positions "https://github.com/alsk1992/cloddsbot/blob/main/src/execution/position-manager.ts"
click node_portfolio "https://github.com/alsk1992/cloddsbot/blob/main/src/portfolio/index.ts"
click node_database "https://github.com/alsk1992/cloddsbot/blob/main/src/db/index.ts"
click node_automation "https://github.com/alsk1992/cloddsbot/blob/main/src/cron/index.ts"
click node_security "https://github.com/alsk1992/cloddsbot/blob/main/src/security/index.ts"
click node_bittensor "https://github.com/alsk1992/cloddsbot/blob/main/src/bittensor/service.ts"
click node_mcp "https://github.com/alsk1992/cloddsbot/blob/main/src/mcp/server.ts"
click node_backtesting "https://github.com/alsk1992/cloddsbot/blob/main/src/trading/backtest.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_channels,node_webchat toneBlue
class node_agents,node_skills,node_feeds,node_opportunity toneAmber
class node_risk,node_execution,node_positions,node_portfolio toneMint
class node_gateway,node_database,node_automation toneRose
class node_security,node_bittensor,node_mcp,node_backtesting,node_user toneIndigo
```

## Components

### User interaction

- [Messaging channels](https://github.com/alsk1992/cloddsbot/blob/main/src/channels/index.ts): `src/channels/index.ts`
- [WebChat](https://github.com/alsk1992/cloddsbot/blob/main/public/webchat/js/app.js): `public/webchat/js/app.js`

### Agent and analysis

- [AI agents](https://github.com/alsk1992/cloddsbot/blob/main/src/agents/index.ts): `src/agents/index.ts`
- [Skills system](https://github.com/alsk1992/cloddsbot/blob/main/src/skills/executor.ts): `src/skills/executor.ts`
- [Market feeds](https://github.com/alsk1992/cloddsbot/blob/main/src/feeds/index.ts): `src/feeds/index.ts`
- [Opportunity analysis](https://github.com/alsk1992/cloddsbot/blob/main/src/opportunity/index.ts): `src/opportunity/index.ts`

### Trading services

- [Risk engine](https://github.com/alsk1992/cloddsbot/blob/main/src/risk/engine.ts): `src/risk/engine.ts`
- [Trade execution](https://github.com/alsk1992/cloddsbot/blob/main/src/execution/index.ts): `src/execution/index.ts`
- [Position management](https://github.com/alsk1992/cloddsbot/blob/main/src/execution/position-manager.ts): `src/execution/position-manager.ts`
- [Portfolio tracking](https://github.com/alsk1992/cloddsbot/blob/main/src/portfolio/index.ts): `src/portfolio/index.ts`

### Runtime platform

- [HTTP gateway](https://github.com/alsk1992/cloddsbot/blob/main/src/gateway/index.ts): `src/gateway/index.ts`
- [SQLite persistence](https://github.com/alsk1992/cloddsbot/blob/main/src/db/index.ts): `src/db/index.ts`
- [Scheduled automation](https://github.com/alsk1992/cloddsbot/blob/main/src/cron/index.ts): `src/cron/index.ts`

### Specialized capabilities

- [Token security](https://github.com/alsk1992/cloddsbot/blob/main/src/security/index.ts): `src/security/index.ts`
- [Bittensor mining](https://github.com/alsk1992/cloddsbot/blob/main/src/bittensor/service.ts): `src/bittensor/service.ts`
- [MCP server](https://github.com/alsk1992/cloddsbot/blob/main/src/mcp/server.ts): `src/mcp/server.ts`
- [Strategy backtesting](https://github.com/alsk1992/cloddsbot/blob/main/src/trading/backtest.ts): `src/trading/backtest.ts`

### Other components

- **Trader**

## Connections

- Trader → Messaging channels: messages (evidence: `README.md`)
- Trader → WebChat: chats (evidence: `README.md`)
- Messaging channels → HTTP gateway: uses gateway (evidence: `README.md`)
- WebChat → HTTP gateway: uses gateway (evidence: `README.md`)
- HTTP gateway → AI agents: routes requests (evidence: `README.md`)
- AI agents → Skills system: uses skills (evidence: `README.md`)
- AI agents → Market feeds: gets market data (evidence: `README.md`)
- Market feeds → Opportunity analysis: supplies markets (evidence: `src/opportunity/index.ts`)
- HTTP gateway → Trade execution: calls execution
- HTTP gateway → Strategy backtesting: routes backtests
- Trade execution → Risk engine: checks risk
- Trade execution → Position management: uses manager (evidence: `src/execution/index.ts`)
- Risk engine → Position management: reads positions (evidence: `src/risk/engine.ts`)
- Portfolio tracking → SQLite persistence: persists data (evidence: `src/portfolio/index.ts`)
- AI agents → Scheduled automation: schedules tasks (evidence: `README.md`)
- AI agents → Token security: uses protection (evidence: `README.md`)
- AI agents → Bittensor mining: supports mining (evidence: `README.md`)
- MCP server → Skills system: exposes tools (evidence: `src/mcp/server.ts`)
