# olololoe110399/financial_data_analyst architecture

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

- Interactive diagram: https://gitdiagram.com/olololoe110399/financial_data_analyst
- Repository: https://github.com/olololoe110399/financial_data_analyst

## Overview

##### Main Components
- Frontend (Flutter UI)
- This includes the visual presentation layer located in the lib/ directory (e.g., components for charts, chat inputs, common UI widgets, and pages like finance.dart).
- Multiple platform folders (android, ios, web, linux, macos, windows) indicate that this is a cross-platform Flutter app.
- Finance Module
- Modules specifically under lib/modules/finance (UI panels like left panel, right content/widget, and menu bar).
- AI & File Interaction Layer
- Chat Interface & File Input: Components like lib/components/chat_input.dart, file_preview.dart, and message_item.dart.
- Chat Composable and Finance Service (found in lib/modules/finance/services and lib/modules/finance/composables) that handle processing user queries, file parsing, and communicating with the Anthropic API.
- Chart Rendering Engine
- A group of chart components (lib/components/chart/) that handle different chart types (line, bar, pie, multi-bar, area, etc.) and logic for dynamic rendering.
- Utility & Configuration
- Supporting utilities (lib/utils) for common functions like file handling, context management, and universal utilities.
- Configuration files (like pubspec.yaml, analysis_options.yaml, and platform-specific build files) that are used for managing the project lifecycle.

##### Relationships and Interactions
- User Interaction: Users upload files (CSV, PDF, images) and interact via the chat interface.
- File Parser: Uploaded content is processed by file handling utilities and parsers (likely within finance services).
- AI Assistant: The processed request is sent to the Anthropic API (using the anthopic_sdk_dart package) to interpret user queries.
- Chart Generation: The AI's response is converted into structured chart data, which is then fed to the appropriate chart component.
- UI Rendering: The chart rendering components (fl_chart) dynamically display data based on the structure received, with interactive elements like tooltips and annotations.

##### Architectural Patterns and Design Principles
- Layered Architecture: Separate layers for presentation (Flutter UI), domain logic (finance module and services), and external integrations (AI interaction with Anthropic API).
- Component-Based Design: Clear separation in the lib/components/ folder, where each type of chart or UI element is encapsulated.
- Reactive State Management: Use of flutter_solidart indicates that reactive state and data flow are managed carefully.

##### Including Relevant Technologies, Frameworks, or Libraries
- Flutter & Dart
- Packages:
- fl_chart for chart rendering
- flutter_solidart for state management
- shadcn_ui for UI components
- File management packages (file_picker, mime, uuid)
- anthropic_sdk_dart for AI integrations

##### Specific Elements
- Clear Labels: Name your main components (e.g., “Chat Interface”, “File Parser”, “AI Assistant”, “Chart Renderer”, “Finance Module”).
- Rectangles for UI components,
- Ovals for external services (Anthropic API),
- Annotations: Brief notes on key interactions (e.g., “User uploads CSV → File Parser extracts data → Finance Service calls AI → Chart Data returned → Chart Renderer displays insights”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    U["User"]:::frontend

    %% Presentation Layer
    subgraph "Presentation Layer"
        MainDart["Main Dart (Flutter UI)"]:::frontend
        UIComponents["UI Components"]:::frontend
        subgraph "Finance Module UI"
            Finance_LeftPanel["Finance Left Panel"]:::finance
            Finance_Menubar["Finance MenuBar"]:::finance
            Finance_RightContent["Finance Right Content"]:::finance
            Finance_RightPanel["Finance Right Panel"]:::finance
            Finance_RightWidget["Finance Right Widget"]:::finance
        end
        subgraph "Chat & File Interface"
            ChatInput["Chat Input"]:::aifile
            FilePreview["File Preview"]:::aifile
            MessageItem["Message Item"]:::aifile
        end
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        ChatComposable["Chat Composable"]:::business
        FinanceService["Finance Service"]:::business
        GraphDataTool["Graph Data Tool"]:::business
    end

    %% External AI Service
    AnthropicAPI["Anthropic API"]:::external

    %% Chart Rendering Engine
    subgraph "Chart Rendering Engine"
        AreaChart["Area Chart"]:::chart
        BarChart["Bar Chart"]:::chart
        BaseChart["Base Chart"]:::chart
        ChartRenderer["Chart Renderer"]:::chart
        Footer["Footer"]:::chart
        Header["Header"]:::chart
        LineChart["Line Chart"]:::chart
        MultiBarChart["Multi Bar Chart"]:::chart
        PieChart["Pie Chart"]:::chart
    end

    %% Utilities & Configuration
    subgraph "Utilities & Configuration"
        UtilsColor["Utils - Color"]:::utils
        UtilsContext["Utils - Context"]:::utils
        UtilsFile["Utils - File"]:::utils
        UtilsToast["Utils - Toast"]:::utils
        UtilsUniversal["Utils - Universal"]:::utils
        Pubspec["pubspec.yaml"]:::utils
        AnalysisOptions["analysis_options.yaml"]:::utils
    end

    %% Connections

    %% User Interaction to Presentation
    U -->|"launches"| MainDart
    MainDart -->|"initializes"| UIComponents

    %% UI Components interactions
    UIComponents -->|"displays"| ChatInput
    UIComponents -->|"displays"| FilePreview
    UIComponents -->|"displays"| MessageItem
    UIComponents -->|"integrates"| Finance_LeftPanel
    UIComponents -->|"integrates"| Finance_Menubar
    UIComponents -->|"integrates"| Finance_RightContent
    UIComponents -->|"integrates"| Finance_RightPanel
    UIComponents -->|"integrates"| Finance_RightWidget

    %% From Chat & File Interface to Business Logic
    ChatInput -->|"sends query"| ChatComposable
    ChatInput -->|"triggers"| FinanceService
    FilePreview -->|"uploads file"| FinanceService
    MessageItem -->|"delivers message"| FinanceService

    %% Business Logic internal flow
    ChatComposable -->|"processes"| FinanceService
    FinanceService -->|"analyzes"| GraphDataTool

    %% Business Logic to External AI
    FinanceService -->|"calls"| AnthropicAPI

    %% External AI to Chart Rendering
    AnthropicAPI -->|"returns data"| ChartRenderer

    %% Chart Rendering assembly
    ChartRenderer -->|"composes"| AreaChart
    ChartRenderer -->|"composes"| BarChart
    ChartRenderer -->|"composes"| BaseChart
    ChartRenderer -->|"composes"| Footer
    ChartRenderer -->|"composes"| Header
    ChartRenderer -->|"composes"| LineChart
    ChartRenderer -->|"composes"| MultiBarChart
    ChartRenderer -->|"composes"| PieChart

    %% Business Logic to Finance Module UI update
    FinanceService ---|"updates"| Finance_LeftPanel
    FinanceService ---|"updates"| Finance_Menubar
    FinanceService ---|"updates"| Finance_RightContent
    FinanceService ---|"updates"| Finance_RightPanel
    FinanceService ---|"updates"| Finance_RightWidget

    %% Utilities support (dashed connections)
    UtilsColor --- MainDart
    UtilsContext --- FinanceService
    UtilsFile --- FinanceService
    UtilsToast --- ChartRenderer
    UtilsUniversal --- UIComponents
    Pubspec --- MainDart
    AnalysisOptions --- MainDart

    %% Click Events
    click MainDart "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/main.dart"
    click UIComponents "https://github.com/olololoe110399/financial_data_analyst/tree/main/lib/components/"
    
    click Finance_LeftPanel "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/modules/finance/components/finance_left_panel.dart"
    click Finance_Menubar "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/modules/finance/finance_menubar.dart"
    click Finance_RightContent "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/modules/finance/finance_right_content.dart"
    click Finance_RightPanel "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/modules/finance/finance_right_panel.dart"
    click Finance_RightWidget "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/modules/finance/finance_right_widget.dart"

    click ChatInput "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/components/chat_input.dart"
    click FilePreview "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/components/file_preview.dart"
    click MessageItem "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/components/message_item.dart"
    click ChatComposable "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/modules/finance/composables/chat_composable.dart"
    click FinanceService "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/modules/finance/services/finance_service.dart"
    click GraphDataTool "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/modules/finance/services/graph_data_tool.dart"

    click AreaChart "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/components/chart/area_chart.dart"
    click BarChart "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/components/chart/bar_chart.dart"
    click BaseChart "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/components/chart/base.dart"
    click ChartRenderer "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/components/chart/chart_renderer.dart"
    click Footer "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/components/chart/footer.dart"
    click Header "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/components/chart/header.dart"
    click LineChart "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/components/chart/line_chart.dart"
    click MultiBarChart "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/components/chart/multi_bar_chart.dart"
    click PieChart "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/components/chart/pie_chart.dart"

    click UtilsColor "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/utils/color.dart"
    click UtilsContext "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/utils/context.dart"
    click UtilsFile "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/utils/file.dart"
    click UtilsToast "https://github.com/olololoe110399/financial_data_analyst/blob/main/lib/utils/toast.dart"
    click UtilsUniversal "https://github.com/olololoe110399/financial_data_analyst/tree/main/lib/utils/universal/"
    click Pubspec "https://github.com/olololoe110399/financial_data_analyst/blob/main/pubspec.yaml"
    click AnalysisOptions "https://github.com/olololoe110399/financial_data_analyst/blob/main/analysis_options.yaml"

    %% Styles
    classDef frontend fill:#ccf,stroke:#333,stroke-width:2px;
    classDef finance fill:#cfc,stroke:#333,stroke-width:2px;
    classDef aifile fill:#f9c,stroke:#333,stroke-width:2px;
    classDef business fill:#fc9,stroke:#333,stroke-width:2px;
    classDef chart fill:#ffc,stroke:#333,stroke-width:2px;
    classDef utils fill:#eee,stroke:#333,stroke-width:2px;
    classDef external fill:#f88,stroke:#333,stroke-width:2px;
```
