# brianmwangi21/anti-charts architecture

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

- Interactive diagram: https://gitdiagram.com/brianmwangi21/anti-charts
- Repository: https://github.com/brianmwangi21/anti-charts

## Overview

##### Project Type and Purpose
- This project is a crypto market analysis and automated trading tool. It interacts with the Binance API to retrieve information on different crypto pairs, performs technical analysis (indicators and strategies), and optionally executes trades on Alpaca.

##### Analyzing the File Structure
- Top-level files and directories:
- .env.example, Dockerfile, Makefile, and go.mod indicate standard Go project settings with environment configurations and build automation.
- main.go sits at the root, suggesting it is the entry point.
- The pkg directory contains subdirectories like analysis and cli, which encapsulate the core functionalities:
○ pkg/analysis: Contains multiple Go files related to analysis (analyze.go, common.go, indicators.go, strategies.go, trades.go). These files are likely responsible for fetching data, processing it, and determining trade strategies.
○ pkg/cli: Contains files related to the command line interface (init.go), indicating that the program may have CLI interactions (e.g., configuration, triggering analysis/trading).

##### Key Components
a. Main Application Entry (main.go)
b. Environment/Configuration Management:
- .env file with API keys and trade settings
c. Analysis Component:
- pkg/analysis: Break down into submodules such as indicators, strategies, and trade decision logic.
d. CLI Component:
- pkg/cli: Handles command-line initialization and interactions.
e. External Services:
- Binance (for crypto pair info and market data)
- Alpaca (for executing trades, based on project settings)
f. Build and Deployment Tools:
- Dockerfile for containerization and Makefile for building and running the project.

##### Architectural Relationships and Interactions
- The Main Application (main.go) wires together all modules:
- It initializes configuration from .env.
- It starts the CLI interface (initialized through pkg/cli) if applicable.
- It dispatches tasks to the analysis engine found in pkg/analysis.
- The Analysis Engine interacts with external APIs:
- It makes network calls to Binance for price/market data.
- Based on analysis outcomes, it can invoke trading actions via Alpaca.
- The Modular structure (using pkg) signals a separation of concerns, where the CLI is decoupled from the analysis logic, but the business logic in analysis can be tested or extended independently.

##### Emphasizing Architectural Patterns
- That the design follows a modular structure, separating concerns between CLI front-end interactions and analysis business logic.
- Design principles like separation of concerns and abstraction in handling API integrations.
- If further extensions are foreseen, mention the possibility of using additional microservices architecture – although the current design is monolithic, its modular structure (inside pkg) lends itself to separation if needed.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Config["Configuration (.env)"]:::config
    Main["Main Application (main.go)"]:::internal
    CLI["CLI Module (init.go)"]:::internal
    Analysis["Analysis Engine (pkg/analysis)"]:::internal
    a1["Analyze Module (analyze.go)"]:::internal
    a2["Common Module (common.go)"]:::internal
    a3["Indicators Module (indicators.go)"]:::internal
    a4["Strategies Module (strategies.go)"]:::internal
    a5["Trades Module (trades.go)"]:::internal
    BuildTools["Build & Deployment Tools"]:::build
    Docker["Dockerfile"]:::build
    Make["Makefile"]:::build
    Binance["Binance API"]:::external
    Alpaca["Alpaca API"]:::external

    Config --> Main
    Main --> CLI
    Main --> Analysis
    Main --> BuildTools

    Analysis --> a1
    Analysis --> a2
    Analysis --> a3
    Analysis --> a4
    Analysis --> a5
    Analysis -->|"fetch"| Binance
    Analysis -->|"trade"| Alpaca

    BuildTools --> Docker
    BuildTools --> Make

    click Config "https://github.com/brianmwangi21/anti-charts/blob/main/.env.example"
    click Main "https://github.com/brianmwangi21/anti-charts/blob/main/main.go"
    click CLI "https://github.com/brianmwangi21/anti-charts/blob/main/pkg/cli/init.go"
    click Analysis "https://github.com/brianmwangi21/anti-charts/tree/main/pkg/analysis"
    click a1 "https://github.com/brianmwangi21/anti-charts/blob/main/pkg/analysis/analyze.go"
    click a2 "https://github.com/brianmwangi21/anti-charts/blob/main/pkg/analysis/common.go"
    click a3 "https://github.com/brianmwangi21/anti-charts/blob/main/pkg/analysis/indicators.go"
    click a4 "https://github.com/brianmwangi21/anti-charts/blob/main/pkg/analysis/strategies.go"
    click a5 "https://github.com/brianmwangi21/anti-charts/blob/main/pkg/analysis/trades.go"
    click Docker "https://github.com/brianmwangi21/anti-charts/tree/main/Dockerfile"
    click Make "https://github.com/brianmwangi21/anti-charts/tree/main/Makefile"

    classDef internal fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef external fill:#FFE4B5,stroke:#000,stroke-width:1px;
    classDef build fill:#D3FFD3,stroke:#000,stroke-width:1px;
    classDef config fill:#FFDAB9,stroke:#000,stroke-width:1px;
```
