# hewyinfo/dividend-chart-keeper architecture

> Architecture diagram of the GitHub repository hewyinfo/dividend-chart-keeper, 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/hewyinfo/dividend-chart-keeper
- Repository: https://github.com/hewyinfo/dividend-chart-keeper

## Overview

##### Project Type and Purpose
- The Dividend App is a modern React-based frontend application that focuses on tracking dividend events, visualizing dividend payouts, and monitoring cash utilization over time. The README explicitly describes features like adding events, marking events as received, and displaying interactive charts for financial data.
- The project employs modern technologies such as React with TypeScript, Tailwind CSS, and several charting and form handling libraries (e.g., Recharts and React Hook Form).

##### File Structure Analysis
- The top-level directories and files clearly indicate that this is a single-page frontend application with additional integrations:
- The "src" directory holds the core application code, including components (for UI, dividend features, search, and settings), pages (Index and Auth screens), contexts (e.g., AuthContext), hooks (both generic and domain-specific dividend hooks), services (such as intrinioService and mockDataService), and integrations (specifically with Supabase).
- There are configuration files for tools like Tailwind, TypeScript, and Vite which signal the build and styling processes.
- The presence of a "supabase" directory and files under "src/integrations/supabase" points to integration with an external service for data management or backend services.
- Additionally, UI components are placed in a dedicated "ui" folder suggesting a modular approach to the user interface using component libraries (and hints at usage of shadcn/ui).

##### README Insights
- Furthermore, the README lists the key technologies (React, TypeScript, Tailwind CSS, Recharts, etc.), highlighting that while the frontend is the primary focus, there is integration with external data sources (e.g., Supabase).

a. Main Components:
- User Interface (UI) Layer: This comprises React components for the application including UI elements (from the ui directory), dividend-specific components, modals (like EventModal), search components, and theme toggling.
- Application Logic and Contexts: This includes the global state management (e.g., AuthContext), as well as custom hooks that encapsulate business logic (dividend-specific hooks, mobile detection hooks).
- Data Visualization: Components responsible for rendering charts (BarChartComponent, LineChartComponent, DividendChart) should be represented separately along with their dependencies on charting libraries (Recharts).
- Integration Layer: This segment represents the integration with external services (Supabase for data persistence). Also, note services like intrinioService and mockDataService that supply or simulate data for dividend events.
- Routing & Controllers: The pages (Index.tsx, Auth.tsx, NotFound.tsx) manage the routing and display logic of the application.

b. Component Interactions:
- The UI Layer sends user actions (such as adding a dividend event) via modal forms (EventModal) which are handled by React Hook Form.
- Once data is gathered, custom hooks and services process the data and may use the integration layer to communicate with Supabase or other backends.
- Data flows into visualization components (charts) that render dividend data and cash utilization information.
- Context providers (like AuthContext) ensure global state is maintained and user permissions are enforced (as seen in components like ProtectedRoute).

c. Architectural Patterns and Design Principles:
- Component-Based Architecture: Each UI component is modular, promoting reusability and clarity.
- Separation of Concerns: The project clearly differentiates between UI presentation (components), business logic (hooks and contexts), and data services (integration and service directories).
- Integration Abstraction: The usage of a separate integrations module abstracts away the specifics of Supabase interactions from the core business logic.

d. Technologies and Frameworks:
- React and TypeScript form the core of the application.
- Tailwind CSS for styling, while component libraries and design elements from shadcn/ui are used to improve UI consistency.
- Recharts (or another chosen charting library) is fundamental to the visualization component.
- Third-party libraries like React Hook Form and date-fns support user input and date processing respectively.

- Dividend Components (EventModal, DividendChart, DividendListView, AddCashModal, etc.)
- Chart Components (BarChartComponent, LineChartComponent)
- UI Components (buttons, modals, toggles, etc.)
- Contexts (AuthContext)
- Custom Hooks (dividend hooks, use-mobile, use-stock-search)
- Utility Modules (src/lib)
- Data Services (intrinioService, mockDataService)
- External Integrations (Supabase client integration)

- Clarity—component names, responsibilities, and interactions should be legible and clearly annotated.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interface"
        direction TB
        UI1["General UI Components"]:::ui
        UI2["Dividend-specific UI Components"]:::ui
        UI3["BarChartComponent"]:::chart
        UI4["LineChartComponent"]:::chart
    end

    subgraph "Application Logic & State Management"
        direction TB
        LOG1["AuthContext"]:::logic
        LOG2["Custom Hooks"]:::logic
    end

    subgraph "Service & Integrations"
        direction TB
        SER1["intrinioService"]:::service
        SER2["mockDataService"]:::service
        SER3["Supabase Integration"]:::service
    end

    subgraph "Routing & Pages"
        direction TB
        ROUT1["Pages"]:::routing
        ROUT2["ProtectedRoute"]:::routing
    end

    UI2 -->|"UserInput"| LOG2
    LOG2 -->|"APICall"| SER1
    LOG2 -->|"APICall"| SER2
    SER3 -->|"StateUpdate"| UI2
    ROUT1 -->|"RenderPage"| UI2
    UI2 -->|"Navigate"| ROUT1
    LOG1 -->|"AuthCheck"| ROUT2
    SER1 -->|"DataFlow"| UI3
    SER2 -->|"DataFlow"| UI4

    click UI1 "https://github.com/hewyinfo/dividend-chart-keeper/tree/main/src/components/ui"
    click UI2 "https://github.com/hewyinfo/dividend-chart-keeper/tree/main/src/components/dividend"
    click UI3 "https://github.com/hewyinfo/dividend-chart-keeper/blob/main/src/components/BarChartComponent.tsx"
    click UI4 "https://github.com/hewyinfo/dividend-chart-keeper/blob/main/src/components/LineChartComponent.tsx"
    click LOG1 "https://github.com/hewyinfo/dividend-chart-keeper/blob/main/src/contexts/AuthContext.tsx"
    click LOG2 "https://github.com/hewyinfo/dividend-chart-keeper/tree/main/src/hooks"
    click SER1 "https://github.com/hewyinfo/dividend-chart-keeper/blob/main/src/services/intrinioService.ts"
    click SER2 "https://github.com/hewyinfo/dividend-chart-keeper/blob/main/src/services/mockDataService.ts"
    click SER3 "https://github.com/hewyinfo/dividend-chart-keeper/tree/main/src/integrations/supabase"
    click ROUT1 "https://github.com/hewyinfo/dividend-chart-keeper/tree/main/src/pages"
    click ROUT2 "https://github.com/hewyinfo/dividend-chart-keeper/blob/main/src/components/ProtectedRoute.tsx"

    classDef ui fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef logic fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef service fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef routing fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef chart fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
```
