# gnosis/prediction-market-agent-tooling architecture

> Architecture diagram of the GitHub repository gnosis/prediction-market-agent-tooling, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gnosis/prediction-market-agent-tooling
- Repository: https://github.com/gnosis/prediction-market-agent-tooling

## Overview

##### Project Type and Core Components
This is a Python-based tooling framework for prediction market applications with three main functionalities:
- Benchmarking prediction market agents
- Deploying agents to cloud infrastructure (GCP)
- Monitoring agent performance and market metrics

##### Main System Components

a) Core Market Platform Layer:
- Market data models and API handlers
- Abstraction through AgentMarket base class

b) Agent Framework Layer:
- AbstractBenchmarkedAgent interface
- DeployableTraderAgent interface
- Safe integration for fund management
- Betting strategies implementation

c) Infrastructure Layer:
- GCP deployment components
- Database and caching systems
- Monitoring system with Streamlit

##### External Systems (Top Layer)
**┌─────────────────────────────────────────┐**
- Prediction Market Platforms             │
- ┌─────────┐  ┌────────┐  ┌───────────┐ │
- Manifold │  │AIOmen  │  │Polymarket │ │
- ┘  └────────┘  └───────────┘ │
- ┘

##### Core Application Layer (Middle)
**┌─────────────────────────────────────────┐**
- Market Abstraction Layer                │
- ┌─────────────┐  ┌──────────────────┐  │
- AgentMarket  │  │Market Data Models│  │
- ┘  └──────────────────┘  │
- ┘

**┌─────────────────────────────────────────┐**
- Agent Framework                         │
- ┌─────────────┐  ┌──────────────────┐  │
- Benchmarking │  │Deployment        │  │
- ┘  └──────────────────┘  │
- ┘

##### Infrastructure Layer (Bottom)
**┌─────────────────────────────────────────┐**
- Infrastructure                          │
- ┌─────┐ ┌────────┐ ┌────────────────┐  │
- GCP  │ │Safe    │ │Monitoring (UI) │  │
- ┘ └────────┘ └────────────────┘  │
- ┘

##### Additional Elements
- Database connections (showing both in-memory and persistent storage)
- API integration points
- Monitoring data flow
- Deployment pipelines
- Testing infrastructure

##### Key Relationships to Highlight
- Market platform APIs → Market Abstraction Layer
- Agent Framework → Market Abstraction Layer
- Infrastructure Layer ↔ Agent Framework
- Safe integration with deployment
- Monitoring system data collection points

##### Technical Details to Note
- Python 3.10+ runtime
- GCP deployment infrastructure
- Web3 integration for blockchain platforms
- Streamlit for monitoring UI
- Poetry for dependency management

Remember to:
- Clear separation of concerns
- Extensibility points
- Notes about critical dependencies and configurations

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef external fill:#b3d1ff,stroke:#333
    classDef core fill:#90EE90,stroke:#333
    classDef infra fill:#FFE5B4,stroke:#333
    classDef api fill:#FFB6C1,stroke:#333
    classDef db cylinder,fill:#F8F8F8,stroke:#333
    
    %% External Platforms
    subgraph Platforms
        Manifold["Manifold Markets"]:::external
        Omen["AIOmen"]:::external
        Polymarket["Polymarket"]:::external
    end

    %% Market Abstraction Layer
    subgraph MarketLayer["Market Abstraction Layer"]
        AgentMarket["Agent Market Base"]
        MarketData["Market Data Models"]
        MarketFees["Market Fees Handler"]
    end

    %% Agent Framework
    subgraph AgentFramework["Agent Framework"]
        BenchmarkSystem["Benchmarking System"]
        AgentImpl["Agent Implementation"]
        BettingStrat["Betting Strategies"]
        TradeInterval["Trade Interval Handler"]
    end

    %% Infrastructure
    subgraph Infrastructure["Infrastructure Layer"]
        GCP["GCP Deployment"]
        Safe["Safe Integration"]
        Monitor["Monitoring Interface"]
        DB["Database"]:::db
        Cache["Caching System"]
        FinMetrics["Financial Metrics"]
        NewsAnalysis["News Analysis"]
    end

    %% Relationships
    Manifold --> AgentMarket
    Omen --> AgentMarket
    Polymarket --> AgentMarket
    
    AgentMarket --> MarketData
    AgentMarket --> MarketFees
    
    AgentImpl --> AgentMarket
    BenchmarkSystem --> AgentImpl
    BettingStrat --> AgentImpl
    TradeInterval --> AgentImpl
    
    AgentImpl --> Safe
    AgentImpl --> GCP
    
    DB --> Monitor
    Cache --> Monitor
    FinMetrics --> Monitor
    NewsAnalysis --> Monitor

    %% Click Events
    click AgentMarket "https://github.com/gnosis/prediction-market-agent-tooling/blob/main/prediction_market_agent_tooling/markets/agent_market.py"
    click Manifold "https://github.com/gnosis/prediction-market-agent-tooling/blob/main/prediction_market_agent_tooling/markets/manifold/manifold.py"
    click Omen "https://github.com/gnosis/prediction-market-agent-tooling/blob/main/prediction_market_agent_tooling/markets/omen/omen.py"
    click Polymarket "https://github.com/gnosis/prediction-market-agent-tooling/blob/main/prediction_market_agent_tooling/markets/polymarket/polymarket.py"
    click MarketData "https://github.com/gnosis/prediction-market-agent-tooling/blob/main/prediction_market_agent_tooling/markets/data_models.py"
    click BenchmarkSystem "https://github.com/gnosis/prediction-market-agent-tooling/blob/main/prediction_market_agent_tooling/benchmark/benchmark.py"
    click AgentImpl "https://github.com/gnosis/prediction-market-agent-tooling/blob/main/prediction_market_agent_tooling/deploy/agent.py"
    click BettingStrat "https://github.com/gnosis/prediction-market-agent-tooling/tree/main/prediction_market_agent_tooling/tools/betting_strategies/"
    click TradeInterval "https://github.com/gnosis/prediction-market-agent-tooling/blob/main/prediction_market_agent_tooling/deploy/trade_interval.py"
    click GCP "https://github.com/gnosis/prediction-market-agent-tooling/blob/main/prediction_market_agent_tooling/deploy/gcp/deploy.py"
    click DB "https://github.com/gnosis/prediction-market-agent-tooling/blob/main/prediction_market_agent_tooling/tools/db/db_manager.py"
    click Cache "https://github.com/gnosis/prediction-market-agent-tooling/tree/main/prediction_market_agent_tooling/tools/caches/"
    click Monitor "https://github.com/gnosis/prediction-market-agent-tooling/blob/main/prediction_market_agent_tooling/monitor/monitor_app.py"
    click Safe "https://github.com/gnosis/prediction-market-agent-tooling/blob/main/prediction_market_agent_tooling/tools/safe.py"
    click FinMetrics "https://github.com/gnosis/prediction-market-agent-tooling/blob/main/prediction_market_agent_tooling/monitor/financial_metrics/financial_metrics.py"
    click MarketFees "https://github.com/gnosis/prediction-market-agent-tooling/blob/main/prediction_market_agent_tooling/markets/market_fees.py"
    click NewsAnalysis "https://github.com/gnosis/prediction-market-agent-tooling/blob/main/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_analysis.py"
```
