# rafapolo/renda architecture

> Architecture diagram of the GitHub repository rafapolo/renda, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rafapolo/renda
- Repository: https://github.com/rafapolo/renda

## Overview

##### Project type and purpose
- From the README and file tree, Renda is a command‐line, compiled Crystal application (distributed as a binary) that connects to cryptocurrency exchanges (Bittrex, Cryptopia, etc.) to fetch market data, detect arbitrage or pump opportunities, and optionally place orders or simulate them.
- It is not a web or front-end project but a data-processing / trading‐bot CLI tool with a modular domain-driven architecture.

##### File structure
- Top level
- shard.yml / shard.lock – Crystal’s dependency and build configuration
- README.md, deploy.sh – documentation and deploy script
- luno.cr, renda.cr – likely entry points: `renda.cr` as the main program, `luno.cr` as a broker plugin
- app/
- config.cr – configuration loading
- broker.cr – generic broker interface
- market.cr, tick.cr, summary.cr – data models and aggregators for market/tick data
- wallet.cr, order.cr – domain models for managing wallets and orders
- strategy.cr, arbitrage.cr – trading logic modules
- helper.cr – utility functions
- doc/
- Markdown docs and sample screenshots
- extra/ – logs, experimental code, ancillary files

##### README for additional insights
- Describes core commands and CLI flags (`--simulate`, `--arbitrage`, `--pump detectors`, etc.)
- Emphasizes sub‐millisecond execution and compiled performance

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        CLI["CLI Parser & Dispatcher"]:::presentation
        Config["Configuration Loader"]:::presentation
    end

    %% Application/Core
    subgraph "Application/Core"
        Core["Core Engine (Orchestration)"]:::core
    end

    %% Domain Modules
    subgraph "Domain Modules"
        TF["TickFetcher"]:::domain
        MM["Market Model"]:::domain
        MS["Market Summary"]:::domain
        StratI["Strategy Interface"]:::domain
        Arb["Arbitrage Detector"]:::domain
        Order["OrderExecutor"]:::domain
        Wallet["WalletManager"]:::domain
    end

    %% Infrastructure / External
    subgraph "Infrastructure & External"
        BrokerIF["Broker Connector Interface"]:::infra
        LunoPlugin["Broker Plugin (Luno)"]:::infra
        Exchanges["Exchange APIs"]:::external
        Simulation["Simulation Mode Stub"]:::infra
        Log["Logging"]:::infra
    end

    %% Documentation
    subgraph "Documentation"
        DocArb["Arbitrage Details"]:::doc
        DocFlow["Flow Example Script"]:::doc
    end

    %% Connections
    CLI -->|"parse args"| Config
    Config -->|"load settings"| Core
    Core -->|"get_ticks()"| TF
    TF -->|"raw data"| MS
    MS -->|"summary data"| StratI
    StratI -->|"detect_arbitrage()"| Arb
    Arb -->|"signal"| Order
    Order -->|"place_order()"| BrokerIF
    Core -->|"simulate mode?"| Simulation
    Simulation -.->|replaces| BrokerIF
    BrokerIF -->|"HTTP/JSON"| Exchanges
    Exchanges -->|"response"| Wallet
    Wallet -->|"update state"| Core

    %% Logging cross-cutting
    Core -->|log events| Log
    TF -->|log ticks| Log
    MS -->|log summary| Log
    Arb -->|log signals| Log
    Order -->|log orders| Log

    %% Documentation links
    Arb --> DocArb
    Core --> DocFlow

    %% Click Events
    click CLI "https://github.com/rafapolo/renda/blob/master/renda.cr"
    click Config "https://github.com/rafapolo/renda/blob/master/app/config.cr"
    click Core "https://github.com/rafapolo/renda/blob/master/app/helper.cr"
    click TF "https://github.com/rafapolo/renda/blob/master/app/tick.cr"
    click MM "https://github.com/rafapolo/renda/blob/master/app/market.cr"
    click MS "https://github.com/rafapolo/renda/blob/master/app/summary.cr"
    click StratI "https://github.com/rafapolo/renda/blob/master/app/strategy.cr"
    click Arb "https://github.com/rafapolo/renda/blob/master/app/arbitrage.cr"
    click Order "https://github.com/rafapolo/renda/blob/master/app/order.cr"
    click Wallet "https://github.com/rafapolo/renda/blob/master/app/wallet.cr"
    click BrokerIF "https://github.com/rafapolo/renda/blob/master/app/broker.cr"
    click LunoPlugin "https://github.com/rafapolo/renda/blob/master/luno.cr"
    click Log "https://github.com/rafapolo/renda/blob/master/extra/bot.log"
    click DocArb "https://github.com/rafapolo/renda/blob/master/doc/arbitrage.md"
    click DocFlow "https://github.com/rafapolo/renda/blob/master/doc/flow.cr"

    %% Styles
    classDef presentation fill:#a2fba5,stroke:#333,stroke-width:1px;
    classDef core fill:#9ec1cf,stroke:#333,stroke-width:1px;
    classDef domain fill:#ffc078,stroke:#333,stroke-width:1px;
    classDef infra fill:#d291bc,stroke:#333,stroke-width:1px;
    classDef external fill:#c9d1d9,stroke:#333,stroke-width:1px;
    classDef doc fill:#fef033,stroke:#333,stroke-width:1px;
```
