## App Flow Charts ### App ```plantuml @startuml skinparam legendBackgroundColor lightgreen skinparam defaultFontColor blue skinparam legendAlignment left skinparam defaultFontName "Arial Black" skinparam legendFontSize 12 skinparam activity { BackgroundColor lightblue BorderColor black FontColor darkblue FontSize 16 } legend top ———————————————————————————————— =app.py ———————————————————————————————— Initializes the BrighterTrades object, configures the Flask server, defines the endpoints then launches the app. end legend start :Create BrighterTrades object; :Configure app; :Define endpoints; :Run app; stop @enduml ``` ### /index ```plantuml @startuml skinparam legendBackgroundColor lightgreen skinparam defaultFontColor blue skinparam legendAlignment left skinparam defaultFontName "Arial Black" skinparam legendFontSize 12 skinparam activity { BackgroundColor lightblue BorderColor black FontColor darkblue FontSize 16 } legend top ———————————————————————————————— =/index ———————————————————————————————— Handles the main landing page, logs in the user, loads dynamic data, and renders the landing page. end legend start :Log in user; :Load dynamic data; :Render Landing Page; stop @enduml ``` ### /ws ```plantuml @startuml skinparam legendBackgroundColor lightgreen skinparam defaultFontColor blue skinparam legendAlignment left skinparam defaultFontName "Arial Black" skinparam legendFontSize 12 skinparam activity { BackgroundColor lightblue BorderColor black FontColor darkblue FontSize 16 } legend top ———————————————————————————————— =/ws ———————————————————————————————— Handles WebSocket connections, listens for messages, processes JSON data, and displays messages. end legend start repeat :Listen for message; if (Contains JSON?) then (yes) :Process received JSON; else (no) :Display message; endif repeat while () @enduml ``` ### /settings ```plantuml @startuml skinparam legendBackgroundColor lightgreen skinparam defaultFontColor blue skinparam legendAlignment left skinparam defaultFontName "Arial Black" skinparam legendFontSize 12 skinparam activity { BackgroundColor lightblue BorderColor black FontColor darkblue FontSize 16 } legend top ———————————————————————————————— =/settings ———————————————————————————————— Handles settings changes. If user is logged in, processes commands and redirects to index. end legend start if (Logged in?) then (no) :redirect -> "/index"; stop else (yes) :get_setting(); :process_command(); :redirect -> "/index"; endif stop @enduml ``` ### /history ```plantuml @startuml skinparam legendBackgroundColor lightgreen skinparam defaultFontColor blue skinparam legendAlignment left skinparam defaultFontName "Arial Black" skinparam legendFontSize 12 skinparam activity { BackgroundColor lightblue BorderColor black FontColor darkblue FontSize 16 } legend top ———————————————————————— =/history​ ———————————————————————— Fetches candle history for a specific trading pair and timeframe. Returns empty data if user is not logged in. end legend start if (Logged in?) then (no) :Return empty data; stop else (yes) :Get current chart view details; :Request price history for the chart view; :Return data; endif stop @enduml ``` ### /signup ```plantuml @startuml skinparam legendBackgroundColor lightgreen skinparam defaultFontColor blue skinparam legendAlignment left skinparam defaultFontName "Arial Black" skinparam legendFontSize 12 skinparam activity { BackgroundColor lightblue BorderColor black FontColor darkblue FontSize 16 } legend top ———————————————————————————————— =/signup ———————————————————————————————— Returns the rendered signup page.​ end legend start :Return rendered signup page​; stop @enduml ``` ### /signout ```plantuml @startuml skinparam legendBackgroundColor lightgreen skinparam defaultFontColor blue skinparam legendAlignment left skinparam defaultFontName "Arial Black" skinparam legendFontSize 12 skinparam activity { BackgroundColor lightblue BorderColor black FontColor darkblue FontSize 16 } legend top ———————————————————————————————— =/signout ———————————————————————————————— Logs out the user, deletes the client session variable, and redirects to index. end legend start :Logout user; :Delete client session var; :redirect -> "/index"; stop @enduml ``` ### /login ```plantuml @startuml skinparam legendBackgroundColor lightgreen skinparam defaultFontColor blue skinparam legendAlignment left skinparam defaultFontName "Arial Black" skinparam legendFontSize 12 skinparam activity { BackgroundColor lightblue BorderColor black FontColor darkblue FontSize 16 } legend top ———————————————————————————————— =/login ———————————————————————————————— Handles user login by receiving credentials, logging in the user, and redirecting to index. end legend start :Get credentials; :Log in user; if (success) then (yes) :Set the client session var; else (no) endif :Redirect -> /index; stop @enduml ``` ### /signup_submit ```plantuml @startuml skinparam legendBackgroundColor lightgreen skinparam defaultFontColor blue skinparam legendAlignment left skinparam defaultFontName "Arial Black" skinparam legendFontSize 12 skinparam activity { BackgroundColor lightblue BorderColor black FontColor darkblue FontSize 16 } legend top ———————————————————————————————— =/signup_submit ———————————————————————————————— Handles user signup by receiving form data,​ validating email, creating new user, and redirecting to homepage. end legend start :Receive form data; :Extract email, username, and password​; :Validate email format; if (Valid email format?) then (yes) :Validate username and password; if (Valid username and password?) then (yes) :Create new user; if (Success) then (yes) :Set session user; :Redirect to homepage; else (no) :Flash error message; endif else (no) :Flash error message; endif else (no) :Flash error message; endif stop @enduml ``` ### /indictor_init ```plantuml @startuml skinparam legendBackgroundColor lightgreen skinparam defaultFontColor blue skinparam legendAlignment left skinparam defaultFontName "Arial Black" skinparam legendFontSize 12 skinparam activity { BackgroundColor lightblue BorderColor black FontColor darkblue FontSize 16 } legend top ———————————————————————————————— =/indicator_init ———————————————————————————————— Initializes the indicators for a given symbol and timeframe, retrieves user and chart view​ details, and returns data response.​ end legend start if (Check if username is provided) then (yes) :Retrieve username from request data; else (no) :Return error response; stop endif if (Check if user is logged in) then (yes) :Retrieve chart view for the user; else (no) :Return error response; stop endif :Retrieve indicator data for the user; :Return data response; stop @enduml ```