# franciscoaraujo/investwise-manager architecture

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

- Interactive diagram: https://gitdiagram.com/franciscoaraujo/investwise-manager
- Repository: https://github.com/franciscoaraujo/investwise-manager

## Overview

##### Main Components
- User Interface (UI) Layer – This includes all the React components found in the “src/components” directory as well as pages (under “src/pages”) that are responsible for rendering different screens (like “fundos”, “cotistas”, “direitos”, “operacoes”) and layout components (e.g., Layout.tsx, Sidebar.tsx, ThemeToggle.tsx).
- Domain/Business Logic – The “src/domain” folder (with its subdirectories like “fundos”) contains the domain types and logic for handling core business concepts. This layer represents your application’s data models, types, and any domain-specific rules.
- Application Layer – The “src/application” directory, including hooks such as “useFundos.ts”, encapsulates logic for orchestrating UI interactions and domain operations. This acts as a mediator between presentation and underlying services.
- Infrastructure/API Layer – Within “src/infrastructure/api” you have modules such as “config.ts” and “fundos-service.ts”, which handle API requests and external data interactions.
- Utility Modules – The “src/lib” directory (e.g., utils.ts) holds shared helper functions used throughout the project.
- Styling & Configuration – Tools like Tailwind (configured via tailwind.config.ts), shadcn-ui components, and Vite (configured through vite.config.ts) indicate that the project uses best-in-class practices for styling and build optimization.

##### Relationships and Data Flow
- User Input is received via the UI (React components/pages) and then passed to the corresponding Application layer (e.g., custom hooks or context providers in “src/contexts”).
- The Application layer orchestrates interactions with the Domain layer (which holds the business rules) and the Infrastructure layer to fetch or update data.
- API calls flow between the front-end (handled by the “src/infrastructure/api” components) and external services or back-end endpoints.
- Shared utilities and context providers (e.g., Themes via “ThemeContext.tsx”) support cross-component behaviors and styling logic.

##### Architectural Patterns & Design Principles
- Separation of Concerns – Clear decoupling between UI components, domain/business logic, and API/infrastructure code.
- Component-Based Architecture – With React, components are modularized extensively (see “src/components/ui” for many reusable UI pieces).
- Hooks and Context – Custom hooks (e.g., “useToast”, “useFundos”, “use-mobile”) and context files help maintain state and functionality across components.
- Single-Page Application (SPA) design – The “src/pages” structure indicates routing and different views for the user.

##### Final Touches
- Don't over-simplify: capturing the multitude of components (e.g., the comprehensive list of UI components in “src/components/ui”) provides an accurate overview.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        A["Layout.tsx (React Component)"]:::presentation
        B["Sidebar.tsx (React Component)"]:::presentation
        C["ThemeToggle.tsx (React Component)"]:::presentation
        D["UI Components (shadcn-ui)"]:::presentation
        E["Fundos Page"]:::presentation
        F["Cotistas Page"]:::presentation
        G["Direitos Page"]:::presentation
        H["Operacoes Page"]:::presentation
    end

    subgraph "Business & Application Layer"
        I["Domain Models & Business Logic"]:::business
        J["Custom Hook (useFundos)"]:::business
    end

    subgraph "Infrastructure/API Layer"
        K["API Config (config.ts)"]:::api
        L["Fundos Service (fundos-service.ts)"]:::api
    end

    subgraph "Utilities & Config"
        M["Utility Functions (utils)"]:::utility
        N["Tailwind Config"]:::utility
        O["Vite Config"]:::utility
        P["TSConfig App"]:::utility
        Q["TSConfig"]:::utility
        R["PostCSS Config"]:::utility
    end

    %% Data Flow from Presentation to Application Layer
    A -->|"trigger_UI"| J
    B -->|"trigger_UI"| J
    C -->|"trigger_UI"| J
    D -->|"trigger_UI"| J
    E -->|"trigger_UI"| J
    F -->|"trigger_UI"| J
    G -->|"trigger_UI"| J
    H -->|"trigger_UI"| J

    %% Application Layer interactions
    J -->|"apply_business_logic"| I
    J -->|"api_call"| K
    J -->|"api_call"| L

    %% API responses
    K -->|"response"| J
    L -->|"response"| J

    %% Application updates back to Presentation
    J -->|"update_UI"| E
    J -->|"update_UI"| F
    J -->|"update_UI"| G
    J -->|"update_UI"| H

    %% Click Events for Presentation Layer
    click A "https://github.com/franciscoaraujo/investwise-manager/blob/master/src/components/Layout.tsx"
    click B "https://github.com/franciscoaraujo/investwise-manager/blob/master/src/components/Sidebar.tsx"
    click C "https://github.com/franciscoaraujo/investwise-manager/blob/master/src/components/ThemeToggle.tsx"
    click D "https://github.com/franciscoaraujo/investwise-manager/tree/master/src/components/ui"
    click E "https://github.com/franciscoaraujo/investwise-manager/blob/master/src/pages/fundos/Index.tsx"
    click F "https://github.com/franciscoaraujo/investwise-manager/blob/master/src/pages/cotistas/Index.tsx"
    click G "https://github.com/franciscoaraujo/investwise-manager/blob/master/src/pages/direitos/Index.tsx"
    click H "https://github.com/franciscoaraujo/investwise-manager/blob/master/src/pages/operacoes/Index.tsx"

    %% Click Events for Domain/Business Logic
    click I "https://github.com/franciscoaraujo/investwise-manager/blob/master/src/domain/fundos/types.ts"

    %% Click Event for Application Layer
    click J "https://github.com/franciscoaraujo/investwise-manager/blob/master/src/application/hooks/useFundos.ts"

    %% Click Events for Infrastructure/API Layer
    click K "https://github.com/franciscoaraujo/investwise-manager/blob/master/src/infrastructure/api/config.ts"
    click L "https://github.com/franciscoaraujo/investwise-manager/blob/master/src/infrastructure/api/fundos-service.ts"

    %% Click Event for Utility Modules
    click M "https://github.com/franciscoaraujo/investwise-manager/blob/master/src/lib/utils.ts"

    %% Click Events for Styling & Configuration
    click N "https://github.com/franciscoaraujo/investwise-manager/blob/master/tailwind.config.ts"
    click O "https://github.com/franciscoaraujo/investwise-manager/blob/master/vite.config.ts"
    click P "https://github.com/franciscoaraujo/investwise-manager/blob/master/tsconfig.app.json"
    click Q "https://github.com/franciscoaraujo/investwise-manager/blob/master/tsconfig.json"
    click R "https://github.com/franciscoaraujo/investwise-manager/blob/master/postcss.config.js"

    %% Style Definitions
    classDef presentation fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef business fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef api fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef utility fill:#fff3cd,stroke:#856404,stroke-width:2px;
```
