```plantuml
@startuml

participant BrighterTrades
participant ExchangeInterface
participant DataCache
participant Configuration
participant Signals
participant Candles
participant Indicators
participant Trades
participant Strategies
participant Backtester

BrighterTrades -> ExchangeInterface: create instance
BrighterTrades -> DataCache: create instance
BrighterTrades -> Configuration: create instance
BrighterTrades -> Signals: create instance
BrighterTrades -> Candles: create instance
BrighterTrades -> Indicators: create instance
BrighterTrades -> Trades: create instance
BrighterTrades -> Strategies: create instance
BrighterTrades -> Backtester: create instance

BrighterTrades -> ExchangeInterface: connect_user_to_exchange(user_name, exchange_name, keys)
ExchangeInterface -> ExchangeInterface: query exchange_data
alt exc_data.empty is False
    ExchangeInterface -> BrighterTrades: True
else exc_data.empty is True
    ExchangeInterface -> ExchangeInterface: connect_exchange(exchange_name, user_name, api_keys)
    alt result is True
        ExchangeInterface -> Configuration: users.active_exchange(exchange, user_name, cmd)
        Configuration -> BrighterTrades: True
    else result is False
        ExchangeInterface -> BrighterTrades: False
    end
end

BrighterTrades -> Configuration: update_data('signals', signals.get_signals('dict'))
BrighterTrades -> Configuration: update_data('strategies', strategies.get_strategies('dict'))

BrighterTrades -> Candles: set_cache(user_name)
BrighterTrades -> BrighterTrades: received_cdata(cdata)
Candles -> BrighterTrades: set_new_candle(cdata)
Signals -> BrighterTrades: process_all_signals(indicators)
Trades -> BrighterTrades: update(float(cdata['close']))
Strategies -> BrighterTrades: update(signals)

BrighterTrades -> BrighterTrades: get_js_init_data(user_name)
BrighterTrades -> BrighterTrades: get_rendered_data(user_name)

BrighterTrades -> Signals: new_signal(data)
BrighterTrades -> Configuration: update_data('signals', signals.get_signals('dict'))

BrighterTrades -> Strategies: new_strategy(data)
BrighterTrades -> Configuration: update_data('strategies', strategies.get_strategies('dict'))

BrighterTrades -> Strategies: delete_strategy(strategy_name)
BrighterTrades -> Configuration: remove('strategies', strategy_name)

BrighterTrades -> Signals: delete_signal(signal_name)
BrighterTrades -> Configuration: remove('signals', signal_name)

BrighterTrades -> Signals: get_signals()
BrighterTrades -> Strategies: get_strategies()

BrighterTrades -> ExchangeInterface: connect_exchange(api_keys, exchange, user_name)
ExchangeInterface -> Configuration: users.update_api_keys(api_keys, exchange, user_name)

BrighterTrades -> Trades: close_trade(trade_id)
BrighterTrades -> Configuration: remove('trades', trade_id)

BrighterTrades -> Trades: new_trade(target, symbol, price, side, order_type, qty)
Trades -> BrighterTrades: new_trade(target, symbol, price, side, order_type, qty)
BrighterTrades -> Configuration: update_data('trades', trades.get_trades('dict'))

BrighterTrades -> Trades: get_trade_by_id(trade_id)
Trades -> BrighterTrades: get_trade_by_id(result)
 
BrighterTrades -> Trades: get_trades()

BrighterTrades -> Configuration: users.set_chart_view(values, specific_property, user_name, default_market)
@enduml
```
```plantuml
@startuml

actor User
participant "BrighterTrades" as BT
participant "ExchangeInterface" as EI
participant "DataCache" as DC
participant "Configuration" as Conf
participant "Signals" as Sig
participant "Candles" as Can
participant "Indicators" as Ind
participant "Trades" as T
participant "Strategies" as St
participant "Backtester" as Btst

User -> BT: connect_user_to_exchange(user_name, exchange_name, keys)
BT -> EI: connect_exchange(exchange_name, user_name, api_keys)
EI -> DC: query(exchange_data)
DC --> BT: exc_data
BT -> BT: Return if exc_data is not empty
BT -> EI: connect_exchange(exchange_name, user_name, api_keys)
BT -> Conf: active_exchange(exchange, user_name, cmd='set')
BT --> User: True / False

User -> BT: get_js_init_data(user_name)
BT -> Conf: get_chart_view(user_name)
BT -> Ind: get_indicator_list(user_name)
BT --> User: js_data

User -> BT: get_rendered_data(user_name)
BT -> Conf: get_chart_view(user_name)
BT --> User: rendered_data

@enduml
```
```plantuml
@startuml
class User {
  - name: string
  - api_keys: string[]
  + connect_user_to_exchange(user_name: string, exchange_name: string, keys: string[]): bool
  + get_js_init_data(user_name: string): string
  + get_rendered_data(user_name: string): string
}

class BrighterTrades {
  - exchanges: ExchangeInterface[]
  - user_map: Map<string, User>
  + connect_user_to_exchange(user_name: string, exchange_name: string, keys: string[]): bool
  + get_js_init_data(user_name: string): string
  + get_rendered_data(user_name: string): string
}

class ExchangeInterface {
  - exchange_name: string
  - user_name: string
  - api_keys: string[]
  + connect_exchange(exchange_name: string, user_name: string, api_keys: string[]): void
  + query(data: string): string
}

class DataCache {
  - cache: Map<string, string>
  + query(data: string): string
}

class Configuration {
  - active_exchange: string
  - user_name: string
  + active_exchange(exchange: string, user_name: string, cmd: string): bool
  + get_chart_view(user_name: string): string
}

class Signals {
  + get_signal_list(user_name: string): string[]
}

class Candles {
  + get_candle_list(user_name: string): string[]
}

class Indicators {
  + get_indicator_list(user_name: string): string[]
}

class Trades {
  + get_trade_list(user_name: string): string[]
}

class Strategies {
  + get_strategy_list(user_name: string): string[]
}

class Backtester {
  + get_backtest_result(user_name: string): string[]
}

User -- BrighterTrades
BrighterTrades "1" *-- "1..*" ExchangeInterface
BrighterTrades -- DataCache
BrighterTrades -- Configuration
BrighterTrades -- Signals
BrighterTrades -- Candles
BrighterTrades -- Indicators
BrighterTrades -- Trades
BrighterTrades -- Strategies
BrighterTrades -- Backtester

@enduml

```
```plantuml
@startuml

class BrighterTrades {
  - exchanges: ExchangeInterface
  - data: DataCache
  - config: Configuration
  - signals: Signals
  - candles: Candles
  - indicators: Indicators
  - trades: Trades
  - strategies: Strategies
  - backtester: Backtester
  + __init__()
  + connect_user_to_exchange(user_name: str, exchange_name: str, keys: dict) -> bool
  + get_js_init_data(user_name: str) -> dict
  + get_rendered_data(user_name: str) -> dict
  + received_cdata(cdata: dict) -> dict | None
  + received_new_signal(data) -> dict | None
  + received_new_strategy(data) -> dict | None
  + delete_strategy(strategy_name)
  + delete_signal(signal_name)
  + get_signals() -> dict
  + get_strategies() -> dict
  + config_exchange(user_name: str, exchange: str, api_keys: dict) -> bool
  + close_trade(trade_id)
  + received_new_trade(data)
  + get_trades() -> dict
  + adjust_setting(user_name: str, setting: str, params: Any)
}

class DataCache {
  + __init__(exchanges)
}

class Strategies {
  + __init__(strategies_list, trades)
  + new_strategy(data)
  + delete_strategy(strategy_name)
  + update(signals)
  + get_strategies(format) -> dict
}

class Backtester {
  + __init__()
}

class Candles {
  + __init__(config_obj, exchanges, database)
  + set_new_candle(cdata)
  + set_cache(user_name)
}

class Configuration {
  + __init__(cache)
  + users
  + app_data
  + signals_list
  + strategies_list
  + trades
  + update_data(key, value)
  + remove(key, item)
  + config_and_states(action)
}

class ExchangeInterface {
  + __init__()
  + exchange_data
  + connect_exchange(exchange_name, user_name, api_keys) -> bool
  + get_exchange(ename, uname)
  + get_available_exchanges() -> list
  + get_connected_exchanges(user_name) -> list
}

class Indicators {
  + __init__(candles, config)
  + toggle_indicator(user_name, params)
  + edit_indicator(user_name, params)
  + new_indicator(user_name, params)
  + update_indicators() -> dict
  + get_indicator_list(user_name)
  + get_enabled_indicators(user_name)
  + indicator_types
  + MV_AVERAGE_ENUM
}

class Signals {
  + __init__(signals_list)
  + new_signal(data)
  + delete_signal(signal_name)
  + process_all_signals(indicators) -> dict
  + get_signals(format) -> dict
}

class Trades {
  + __init__(config_trades)
  + connect_exchanges(exchanges)
  + new_trade(target, symbol, price, side, order_type, qty)
  + close_trade(trade_id)
  + update(price) -> dict
  + get_trade_by_id(trade_id)
  + get_trades(format) -> dict
}

class Backtester {
  + __init__()
}

BrighterTrades --> DataCache
BrighterTrades --> Strategies
BrighterTrades --> Backtester
BrighterTrades --> Candles
BrighterTrades --> Configuration
BrighterTrades --> ExchangeInterface
BrighterTrades --> Indicators
BrighterTrades --> Signals

```
```plantuml
@startuml

actor User

User -> BrighterTrades: login(username, password)
BrighterTrades -> Users: authenticate(username, password)
Users -> Database: get_user_data(username)
Database --> Database: _execute_query(query)
Database --> Users: Return user data
Users --> BrighterTrades: Return user data
BrighterTrades --> User: Return user data
User -> DataCache: get_data(symbol)
DataCache --> DataCache: check_cache(symbol)
alt Symbol data in cache
    DataCache --> User: Return cached data
else Symbol data not in cache
    User -> Database: get_data(symbol)
    Database --> Database: _execute_query(query)
    Database --> User: Return data from database
    User -> DataCache: cache_data(symbol, data)
    DataCache --> DataCache: Store data in cache
    DataCache --> User: Return data from cache
end

@enduml

```
```plantuml
@startuml

left to right direction

actor Users
rectangle BrighterTrades {
  usecase "Access DataCache" as AccessDataCache
  usecase "Access Database" as AccessDatabase
}

Users --> AccessDataCache
Users --> AccessDatabase
AccessDataCache --> DataCache
AccessDatabase --> Database

@enduml
```
```plantuml
@startuml

!define ICONURL https://raw.githubusercontent.com/jaime-olivares/yuml-diagram/master/images

!define DarkYellow #ffd666
!define DarkGreen #75d68c
!define DarkBlue #6cb2ed

skinparam participant {
  BackgroundColor DarkYellow
  BorderColor DarkGreen
  FontColor Black
}

!define CLASSURL [BrighterTrades](https://www.example.com)
!define USERSURL [Users](https://www.example.com)
!define DATACACHEURL [DataCache](https://www.example.com)
!define DATABASEURL [Database](https://www.example.com)

actor Users as "Users" <<(U,#FF7700)>>
boundary "BrighterTrades" as BrighterTrades <<(B,#FF7700)>>
control DataCache as "DataCache" <<(C,#FF7700)>>
database Database as "Database" <<(D,#FF7700)>>

Users --> BrighterTrades : "Access DataCache"
Users --> BrighterTrades : "Access Database"
BrighterTrades --> DataCache : "Access DataCache"
BrighterTrades --> Database : "Access Database"

note right of BrighterTrades : Application Layer
note right of DataCache : Cache Layer
note right of Database : Data Layer

@enduml
 
```
```plantuml
@startuml
start
:Users Interacts with BrighterTrades;
if (Request data) then (yes)
  :BrighterTrades Requests data from DataCache;
  if (Data exists in DataCache) then (yes)
    :DataCache Returns data to BrighterTrades;
    if (Display data) then (yes)
      :BrighterTrades Displays data to Users;
    else (no)
      stop
    endif
  else (no)
    :BrighterTrades Requests data from Database;
    if (Data exists in Database) then (yes)
      :Database Returns data to DataCache;
      :DataCache Returns data to BrighterTrades;
      if (Display data) then (yes)
        :BrighterTrades Displays data to Users;
      else (no)
        stop
      endif
    else (no)
      :Database Notifies DataCache of data unavailability;
      :DataCache Notifies BrighterTrades of data unavailability;
      stop
    endif
  endif
else (no)
  stop
endif
stop
@enduml

```
```plantuml
@startuml
|BrighterTrades|
start
:Users Interacts with BrighterTrades;
if (Request data) then (yes)
  |BrighterTrades|
  :BrighterTrades Requests data from DataCache;
  if (Data exists in DataCache) then (yes)
    |DataCache|
    :DataCache Returns data to BrighterTrades;
    |BrighterTrades|
    if (Display data) then (yes)
      :BrighterTrades Displays data to Users;
    else (no)
      stop
    endif
  else (no)
    |DataCache|
    :BrighterTrades Requests data from Database;
    if (Data exists in Database) then (yes)
      |Database|
      :Database Returns data to DataCache;
      |DataCache|
      :DataCache Returns data to BrighterTrades;
      |BrighterTrades|
      if (Display data) then (yes)
        :BrighterTrades Displays data to Users;
      else (no)
        stop
      endif
    else (no)
      |Database|
      :Database Notifies DataCache of data unavailability;
      |DataCache|
      :DataCache Notifies BrighterTrades of data unavailability;
      stop
    endif
  endif
else (no)
  stop
endif
|BrighterTrades|
stop
@enduml

```
```plantuml
@startuml

participant Brightertrades
participant DataCache
participant Database
participant Strategies
participant Candles
participant Configuration
participant ExchangeInterface
participant Indicators
participant Signals
participant Trades

== Brightertrades Interactions ==

Brightertrades -> DataCache: retrieveData()
DataCache -> Database: fetchData()
Database --> DataCache: data
DataCache --> Brightertrades: data
Brightertrades -> Strategies: selectStrategy()
Brightertrades -> Configuration: getConfig()
Brightertrades -> ExchangeInterface: getAccountInfo()
Brightertrades -> Indicators: calculateIndicators(candleData, config)
Brightertrades -> Signals: generateSignals(indicators)
Brightertrades -> Strategies: evaluateSignals(signals)
Brightertrades -> Trades: executeTrades(evaluatedSignals, accountInfo)

== DataCache Interactions ==

DataCache -> Database: fetchData()
Database --> DataCache: data

== Strategies Interactions ==

Strategies -> Candles: getCandleData()
Candles --> Strategies: candleData

== Brightertrades Internal Interactions ==

Brightertrades -> Strategies: evaluateSignals(signals)

@enduml

```
```plantuml
@startuml

participant "Brightertrades" as BT
participant "DataCache" as DC
participant "Database" as DB
participant "Strategies" as ST
participant "Candles" as CD
participant "Configuration" as CFG
participant "ExchangeInterface" as EI
participant "Indicators" as IND
participant "Signals" as SG
participant "Trades" as TD

== Brightertrades Interactions ==

BT -> DC: retrieveData()
DC -> DB: fetchData()
DB --> DC: data
DC --> BT: data
BT -> ST: selectStrategy()
BT -> CFG: getConfig()
BT -> EI: getAccountInfo()
BT -> IND: calculateIndicators(candleData, config)
BT -> SG: generateSignals(indicators)
BT -> ST: evaluateSignals(signals)
BT -> TD: executeTrades(evaluatedSignals, accountInfo)
TD --> BT: tradeResult

== DataCache Interactions ==

DC -> DB: fetchData()
DB --> DC: data

== Strategies Interactions ==

ST -> CD: getCandleData()
CD --> ST: candleData
ST --> BT: strategyResult

== Brightertrades Internal Interactions ==

BT -> ST: evaluateSignals(signals)
BT --> TD: evaluatedSignals

@enduml
```
### dd
```plantuml
@startuml

!define LightBlueColor #00AEEF
!define LightGreyColor #D3D3D3

!define BrightertradesColor(LightBlueColor)
!define DataCacheColor(LightBlueColor)
!define DatabaseColor(LightBlueColor)
!define StrategiesColor(LightBlueColor)
!define CandlesColor(LightBlueColor)
!define ConfigurationColor(LightBlueColor)
!define ExchangeInterfaceColor(LightBlueColor)
!define IndicatorsColor(LightBlueColor)
!define SignalsColor(LightBlueColor)
!define TradesColor(LightBlueColor)

skinparam monochrome false
skinparam defaultTextAlignment center
skinparam component {
    BackgroundColor LightGreyColor
    BorderColor black
    ArrowColor black
    FontColor black
}

actor User

User --> Brightertrades: Request action

Brightertrades -> DataCache: Retrieve data
DataCache --> Brightertrades: Data
Brightertrades -> Database: Execute SQL
Database --> Brightertrades: Result
Brightertrades -> Strategies: Get strategies
Strategies --> Brightertrades: List of strategies
Brightertrades -> Candles: Get candles
Candles --> Brightertrades: Candles data
Brightertrades -> Configuration: Get configuration
Configuration --> Brightertrades: Configuration data
Brightertrades -> ExchangeInterface: Execute trade
ExchangeInterface --> Brightertrades: Trade result
Brightertrades -> Indicators: Calculate indicators
Indicators --> Brightertrades: Indicator values
Brightertrades -> Signals: Generate signals
Signals --> Brightertrades: List of signals
Brightertrades -> Trades: Execute trades
Trades --> Brightertrades: Trade execution results

@enduml

```
```plantuml
@startuml

!define LightBlueColor #00AEEF
!define LightGreyColor #D3D3D3

!define BrightertradesColor(LightBlueColor)
!define DataCacheColor(LightBlueColor)
!define DatabaseColor(LightBlueColor)
!define StrategiesColor(LightBlueColor)
!define CandlesColor(LightBlueColor)
!define ConfigurationColor(LightBlueColor)
!define ExchangeInterfaceColor(LightBlueColor)
!define IndicatorsColor(LightBlueColor)
!define SignalsColor(LightBlueColor)
!define TradesColor(LightBlueColor)

skinparam monochrome false
skinparam defaultTextAlignment center
skinparam participant {
    BackgroundColor LightGreyColor
    BorderColor black
    FontColor black
}

participant User
participant Brightertrades
participant DataCache
participant Database
participant Strategies
participant Candles
participant Configuration
participant ExchangeInterface
participant Indicators
participant Signals
participant Trades

User -> Brightertrades: Request action

activate Brightertrades

Brightertrades -> DataCache: retrieveData()
activate DataCache
DataCache --> Brightertrades: Data
deactivate DataCache

Brightertrades -> Database: executeSQL()
activate Database
Database --> Brightertrades: Result
deactivate Database

Brightertrades -> Strategies: getStrategies()
activate Strategies
Strategies --> Brightertrades: List of strategies
deactivate Strategies

Brightertrades -> Candles: getCandles()
activate Candles
Candles --> Brightertrades: Candles data
deactivate Candles

Brightertrades -> Configuration: getConfiguration()
activate Configuration
Configuration --> Brightertrades: Configuration data
deactivate Configuration

Brightertrades -> ExchangeInterface: executeTrade()
activate ExchangeInterface
ExchangeInterface --> Brightertrades: Trade result
deactivate ExchangeInterface

Brightertrades -> Indicators: calculateIndicators()
activate Indicators
Indicators --> Brightertrades: Indicator values
deactivate Indicators

Brightertrades -> Signals: generateSignals()
activate Signals
Signals --> Brightertrades: List of signals
deactivate Signals

Brightertrades -> Trades: executeTrades()
activate Trades
Trades --> Brightertrades: Trade execution results
deactivate Trades

deactivate Brightertrades

@enduml

```
```plantuml

```
