# bi-mars/trading-goal-visualizer architecture

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

- Interactive diagram: https://gitdiagram.com/bi-mars/trading-goal-visualizer
- Repository: https://github.com/bi-mars/trading-goal-visualizer

## Overview

##### Main Components
- Next.js Application Core – Represent the /app directory, which houses the main pages (e.g., page.tsx), layout (layout.tsx), and global styles (globals.css). This is the entry point for rendering the UI.
- UI Components – Highlight the reusable UI elements:
- Custom trading components located in app/components (e.g., ProgressBar.tsx, StepCalculator.tsx, TradeEntry.tsx, Vault.tsx).
- A broader UI library under the components/ui folder (containing accordion, alert, calendar, card, chart, etc.) that likely leverages shadcn/ui components.
- Utility and Business Logic Layer – Show how shared business logic is encapsulated:
- Utility functions in app/utils/calculations.ts.
- Helper functions in lib/utils.ts.
- Hooks – Indicate the custom hooks (found in hooks/) that manage mobile responsiveness and toast notifications. These hooks bridge UI interactions with internal state/logic.
- Configuration & Styling – Note global configurations and CSS:
- Tailwind CSS configured in tailwind.config.ts.
- Global stylesheet references in both app/globals.css and styles/globals.css.
- Build and Dependency Management – Include nodes like package.json, next.config.mjs, and tsconfig.json which drive the build, dependency, and TypeScript configurations.

##### Relationships and Interactions
- That the Next.js app (the presentation layer) communicates with the UI components to render interactive elements.
- How the custom components in the app directory depend on and leverage the reusable components in the components/ui folder.
- Hooks as bridging elements that connect UI events (e.g., user interactions or responsive design handling) with the rest of the application logic.
- Optionally, if there are any external integrations or future domains (e.g., potential API calls, even if not explicit in the file tree), note them as separate modules.

##### Architectural Patterns and Design Principles
- The project follows a modular, component-based architecture typical of Next.js applications. Each UI element is encapsulated, making debugging and extension straightforward.
- Separation of concerns is achieved by isolating presentation (app/components and components/ui) from business logic (utilities and hooks) and configurations.
- Responsive and interactive design guided by Tailwind CSS and shadcn/ui standards.

- Drill down into the app directory for a mid-level view (pages, layout, and main feature-specific components).
- Zoom into the UI components and their dependencies on the utility functions and hooks.
- Every section of the project (as outlined in the file tree) is represented at the appropriate level of detail.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Browser (User)"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer"
        B["Next.js Application Core (app: page.tsx, layout.tsx, globals.css)"]:::presentation
        C["Custom Trading UI Components (app/components)"]:::presentation
        D["Reusable UI Components (components/ui)"]:::presentation
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        E["Calculations Utility (app/utils/calculations.ts)"]:::logic
        F["Helper Utility (lib/utils.ts)"]:::logic
        G["use-mobile Hook (hooks/use-mobile.tsx)"]:::logic
        H["use-toast Hook (hooks/use-toast.ts)"]:::logic
    end

    %% Configuration & Styling Layer
    subgraph "Configuration & Styling"
        I["Tailwind Config (tailwind.config.ts)"]:::config
        J["Global Styles (styles/globals.css)"]:::config
        K["Next.js Config (next.config.mjs)"]:::config
        L["TypeScript Config (tsconfig.json)"]:::config
        M["Package Manager (package.json)"]:::config
    end

    %% Data flow / interactions
    A -->|"access"| B
    B -->|"renders"| C
    B -->|"renders"| D
    C -->|"utilizes"| E
    C -->|"utilizes"| F
    C -->|"triggers"| G
    C -->|"triggers"| H
    D -->|"triggers"| G
    D -->|"triggers"| H
    G -->|"bridges to"| E
    G -->|"bridges to"| F
    H -->|"bridges to"| E
    H -->|"bridges to"| F

    %% Click Events
    click B "https://github.com/bi-mars/trading-goal-visualizer/tree/main/app"
    click C "https://github.com/bi-mars/trading-goal-visualizer/tree/main/app/components"
    click D "https://github.com/bi-mars/trading-goal-visualizer/tree/main/components/ui"
    click E "https://github.com/bi-mars/trading-goal-visualizer/blob/main/app/utils/calculations.ts"
    click F "https://github.com/bi-mars/trading-goal-visualizer/blob/main/lib/utils.ts"
    click G "https://github.com/bi-mars/trading-goal-visualizer/blob/main/hooks/use-mobile.tsx"
    click H "https://github.com/bi-mars/trading-goal-visualizer/blob/main/hooks/use-toast.ts"
    click I "https://github.com/bi-mars/trading-goal-visualizer/blob/main/tailwind.config.ts"
    click J "https://github.com/bi-mars/trading-goal-visualizer/blob/main/styles/globals.css"
    click K "https://github.com/bi-mars/trading-goal-visualizer/blob/main/next.config.mjs"
    click L "https://github.com/bi-mars/trading-goal-visualizer/blob/main/tsconfig.json"
    click M "https://github.com/bi-mars/trading-goal-visualizer/blob/main/package.json"

    %% Styles
    classDef presentation fill:#B3D9FF,stroke:#000,stroke-width:2px;
    classDef logic fill:#CCFFCC,stroke:#000,stroke-width:2px;
    classDef config fill:#FFCC99,stroke:#000,stroke-width:2px;
    classDef external fill:#F7E79E,stroke:#000,stroke-width:2px;
```
