# kanekoshoyu/exchange-collection architecture

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

- Interactive diagram: https://gitdiagram.com/kanekoshoyu/exchange-collection
- Repository: https://github.com/kanekoshoyu/exchange-collection

## Overview

##### Project type and purpose
- exchange-collection is an open-source tooling framework whose purpose is to aggregate machine-readable OpenAPI/AsyncAPI documents for many crypto exchanges and drive a CI/CD pipeline that generates multi-language REST/WS client libraries automatically.
- The primary deliverables are:
- a collection of YAML specs under asset/
- a Rust-based codegen engine in codegen/
- an index.html OpenAPI/AsyncAPI viewer
- a CI workflow in .github/workflows that ties everything together and publishes generated code to a sub-repo.

##### File structure
- Top level:
- asset/ – all exchange_*_openapi.yaml and *_asyncapi.yaml specs
- codegen/ – Rust CLI (main.rs, lib.rs) plus meta modules for codegen input/output
- index.html – static documentation site
- .github/workflows/generate-rust-code.yml – CI pipeline
- Cargo.toml / Cargo.lock – Rust crate for codegen
- Patterns:
- input assets → codegen engine → output client code pushed to exchange-collection-rust
- static viewer reads directly from asset/
- pipeline orchestrated via GitHub Actions
- Supporting files:
- .openapi-generator-ignore, .gitignore, LICENSE, README.md

##### README for additional insights
- It outlines “gather → codegen → deploy” steps
- It lists codegen command examples for OpenAPI and AsyncAPI (Rust, Python)
- It emphasizes CI integration and multi-language support

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Components
    AssetStore[(Asset Store)]:::core
    subgraph "Codegen Engine"
        direction TB
        CGMain["main.rs"]:::core
        CGLib["lib.rs"]:::core
        MetaCLI["cli.rs"]:::core
        MetaInput["input.rs"]:::core
        MetaOutput["output.rs"]:::core
    end
    CodegenEngine[("Codegen Engine")]:::core

    %% CI/CD & External Services
    CI["CI/CD Orchestrator"]:::ci
    ExternalTools[(External Tools & Services)]:::external
    OpenAPI_CLI["@openapitools/openapi-generator-cli"]:::external
    AsyncAPI_CLI["@asyncapi/cli"]:::external
    Registry["crates.io / pip registry"]:::external

    %% Deliverables
    subgraph "Generated Client Repositories"
        direction TB
        RustClients["exchange-collection-rust"]:::deliverable
        FutureClients["future language outputs"]:::deliverable
    end
    DocumentationViewer[Documentation Viewer]:::deliverable

    %% Relationships
    AssetStore -->|"YAML inputs"| CodegenEngine
    CodegenEngine -->|"push generated code"| RustClients
    CodegenEngine -->|"push generated code"| FutureClients
    CI -->|"triggers"| CodegenEngine
    CI -->|"publishes"| Registry
    AssetStore -->|"live spec browsing"| DocumentationViewer
    ExternalTools --> CodegenEngine
    OpenAPI_CLI --> CodegenEngine
    AsyncAPI_CLI --> CodegenEngine

    %% Click Events
    click AssetStore "https://github.com/kanekoshoyu/exchange-collection/tree/main/asset/"
    click CGMain "https://github.com/kanekoshoyu/exchange-collection/blob/main/codegen/src/main.rs"
    click CGLib "https://github.com/kanekoshoyu/exchange-collection/blob/main/codegen/src/lib.rs"
    click MetaCLI "https://github.com/kanekoshoyu/exchange-collection/blob/main/codegen/src/meta/cli.rs"
    click MetaInput "https://github.com/kanekoshoyu/exchange-collection/blob/main/codegen/src/meta/input.rs"
    click MetaOutput "https://github.com/kanekoshoyu/exchange-collection/blob/main/codegen/src/meta/output.rs"
    click CI "https://github.com/kanekoshoyu/exchange-collection/blob/main/.github/workflows/generate-rust-code.yml"
    click DocumentationViewer "https://github.com/kanekoshoyu/exchange-collection/blob/main/index.html"
    click CodegenEngine "https://github.com/kanekoshoyu/exchange-collection/tree/main/codegen/src/"
    click RustClients "https://github.com/kanekoshoyu/exchange-collection/blob/main/codegen/Cargo.toml"
    click RustClients "https://github.com/kanekoshoyu/exchange-collection/blob/main/codegen/Cargo.lock"
    click Registry "https://github.com/kanekoshoyu/exchange-collection/blob/main/Cargo.toml"
    click Registry "https://github.com/kanekoshoyu/exchange-collection/blob/main/Cargo.lock"

    %% Styles
    classDef core fill:#bbdefb,stroke:#1e88e5,stroke-width:1px
    classDef ci fill:#c8e6c9,stroke:#43a047,stroke-width:1px
    classDef deliverable fill:#ffe0b2,stroke:#fb8c00,stroke-width:1px
    classDef external fill:#d1c4e9,stroke:#7e57c2,stroke-width:1px
```
