# amfor/strategy_tester architecture

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

- Interactive diagram: https://gitdiagram.com/amfor/strategy_tester
- Repository: https://github.com/amfor/strategy_tester

## Overview

##### Main System Components

A. User Interface Layer (Streamlit Frontend)
- Main application entry (strategy_tester.py)
- Two main sections:
- Strategic Trading Section
- Dollar Cost Averaging (DCA) Section

B. Application Logic Layer
- Trading Logic Module
- Plotting Functions
- Styling Components

C. Data Layer
- Data Fetching Service (Yahoo Finance Integration)
- Configuration Management

##### Component Relationships and Interactions

**[User Interface Layer]**

**[Application Logic Layer]**

**[Data Layer]**

##### Detailed Component Breakdown

For each layer, include these specific components:

UI Layer:

Logic Layer:
- Trading Logic (trade_logic.py)
- Visualization (plot_funcs.py)
- Styling (styling.py)
- How these components interact with both UI and Data layers

Data Layer:
- Connection to external Yahoo Finance API
- Configuration management (config.py)

##### Data Flow Visualization

- User input → UI Layer
- UI Layer → Logic Layer (strategy execution)
- Logic Layer → Data Layer (data requests)
- Data Layer → External Service (YFinance)
- Results flowing back up through the layers

##### Additional Elements

Annotations for:
- Docker container boundary
- Streamlit server
- Configuration files
- Data flow directions

##### The integration with external services

- Component relationships
- Data flow directions
- System boundaries
- Key configuration points

- Component types
- Special symbols

This design should reflect the application's nature as a web-based trading strategy testing tool while showing its modular architecture and data processing flow.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef logic fill:#2ecc71,stroke:#27ae60,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef container fill:none,stroke:#e74c3c,stroke-width:2px
    
    %% Main Container
    subgraph Docker["Docker Container"]
        %% UI Layer
        subgraph UI["User Interface Layer"]
            StreamlitApp["Main Streamlit App"]
            StrategicUI["Strategic Trading Section"]
            DCAUI["DCA Section"]
            StreamlitConfig["Streamlit Config"]
        end

        %% Logic Layer
        subgraph Logic["Application Logic Layer"]
            TradingLogic["Trading Logic"]
            PlotFuncs["Plotting Functions"]
            Styling["Styling Components"]
        end

        %% Data Layer
        subgraph Data["Data Layer"]
            DataFetcher["Data Fetcher"]
            Config["Configuration Management"]
        end
    end

    %% External Services
    YFinance["Yahoo Finance API"]:::external

    %% Relationships
    StreamlitApp --> StrategicUI
    StreamlitApp --> DCAUI
    StrategicUI --> TradingLogic
    DCAUI --> TradingLogic
    TradingLogic --> PlotFuncs
    TradingLogic --> DataFetcher
    PlotFuncs --> Styling
    DataFetcher --> YFinance
    Config --> DataFetcher
    StreamlitConfig --> StreamlitApp

    %% Click Events
    click StreamlitApp "https://github.com/amfor/strategy_tester/blob/master/src/strategy_tester.py"
    click StrategicUI "https://github.com/amfor/strategy_tester/blob/master/src/sections/strategic_trading.py"
    click DCAUI "https://github.com/amfor/strategy_tester/blob/master/src/sections/dca.py"
    click TradingLogic "https://github.com/amfor/strategy_tester/blob/master/src/logic/trade_logic.py"
    click PlotFuncs "https://github.com/amfor/strategy_tester/blob/master/src/logic/plot_funcs.py"
    click Styling "https://github.com/amfor/strategy_tester/blob/master/src/logic/styling.py"
    click DataFetcher "https://github.com/amfor/strategy_tester/blob/master/src/data/fetch_data.py"
    click Config "https://github.com/amfor/strategy_tester/blob/master/src/data/config.py"
    click StreamlitConfig "https://github.com/amfor/strategy_tester/blob/master/.streamlit/config.toml"

    %% Style Applications
    class StreamlitApp,StrategicUI,DCAUI,StreamlitConfig ui
    class TradingLogic,PlotFuncs,Styling logic
    class DataFetcher,Config data
    class Docker container
```
