# mbl43/my-wealth architecture

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

- Interactive diagram: https://gitdiagram.com/mbl43/my-wealth
- Repository: https://github.com/mbl43/my-wealth

## Overview

##### Project Type & Overview
- This is a modern front-end web application built with React that focuses on financial investment tracking. It offers various financial calculators (SIP, Loss Recovery, Stock Average) and includes user authentication via Firebase.
- It is a full-stack application in the sense that while the frontend handles the UI and interaction logic, Firebase (both Firestore and Firebase Auth) is the backend component.

##### Primary Components
- UI/Presentation Layer: Components like Herosection, Navbar, Footer, Layout, Darkmode, Modal, and general pages (Home, Notfound) constitute this layer.
- Functionality/Business Logic Layer: The Calculator components (Calc folder with LossRecovery, Sip, StockAvg) for processing user inputs and performing calculations.
- Authentication & Protected Routing: Components like Login, Signup, ProtectedRoute, and integration in the Firebase configuration for secure authentication.
- Data & External Services: Firebase for authentication and, likely, database storage (investment tracking) as well as external libraries like Email.js and Swiper.js.

##### Architectural Interactions
- Frontend UI Components interact with the Firebase backend for both authentication and data storage via REST calls or SDK functions provided in the firebase folder.
- Context API (src/contextAPI.jsx) likely provides global state management for features like dark mode toggling and user state.
- React Router is used for navigating between various pages such as Home, Dashboard, and Notfound. ProtectedRoute ensures that private views are accessible only after authentication.
- A clear separation of concerns is enforced with major directories: "components" holding reusable UI blocks, "pages" for the actual views, and "firebase" for backend configuration.

##### Design Patterns & Technologies
- Component-Based Architecture: Emphasize each UI piece as a self-contained component (for example, Calculator, Dashboard, Modal).
- Single Page Application (SPA): The usage of React Router ensures that navigation occurs without full page reloads.
- Service Integration: Integration with Firebase (authentication and database) serves as the primary backend service.
- UI/UX Consistency: Use of Tailwind CSS and Material UI indicates an emphasis on consistent design and responsiveness.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry Points
    E1("index.html"):::ui
    E2("main.jsx"):::ui
    App("App Component"):::ui

    %% Frontend Layer Subgraph
    subgraph "Frontend Layer"
        direction TB
        Layout("Layout"):::ui
        Navbar("Navbar"):::ui
        Herosection("Herosection"):::ui
        Footer("Footer"):::ui
        Modal("Modal"):::ui
        Darkmode("Darkmode"):::ui
    end

    %% Pages Subgraph
    subgraph "Pages"
        direction TB
        Home("Home Page"):::page
        Notfound("Notfound Page"):::page
        Dashboard("Dashboard"):::page
        Login("Login"):::auth
        Signup("Signup"):::auth
        ProtectedRoute("ProtectedRoute"):::auth
    end

    %% Calculators Subgraph
    subgraph "Calculator Components"
        direction TB
        LossRecovery("LossRecovery Calculator"):::calc
        Sip("Sip Calculator"):::calc
        StockAvg("Stock Average Calculator"):::calc
    end

    %% Global State Management
    ContextAPI("Context API"):::state

    %% Backend/External Services
    Firebase("Firebase"):::external

    %% External Libraries
    EmailJS("Email.js"):::external
    SwiperJS("Swiper.js"):::external

    %% Connections: Entry
    E1 --> App
    E2 --> App
    App --> Layout

    %% Layout -> UI Components
    Layout --> Navbar
    Layout --> Herosection
    Layout --> Footer
    Layout --> Modal
    Layout --> Darkmode

    %% Navbar handles routing to pages
    Navbar --> Home
    Navbar --> Dashboard
    Navbar --> Notfound

    %% Protected routing for authenticated pages
    ProtectedRoute --> Dashboard
    Login --> Firebase
    Signup --> Firebase

    %% Calculators feed into Dashboard
    LossRecovery --> Dashboard
    Sip --> Dashboard
    StockAvg --> Dashboard

    %% Global state management feeds Darkmode and Layout
    ContextAPI --> Darkmode

    %% UI Components interaction with External Libraries
    Herosection --> SwiperJS
    Modal --> EmailJS

    %% Dashboard relies on Firebase for data & auth verification
    Dashboard --> Firebase

    %% Click Events
    click Herosection "https://github.com/mbl43/my-wealth/blob/main/src/components/Herosection/Hero.jsx"
    click Navbar "https://github.com/mbl43/my-wealth/blob/main/src/components/Navbar/Navbar.jsx"
    click Footer "https://github.com/mbl43/my-wealth/blob/main/src/components/Footer/Footer.jsx"
    click Layout "https://github.com/mbl43/my-wealth/blob/main/src/components/Layout/Layout.jsx"
    click Modal "https://github.com/mbl43/my-wealth/blob/main/src/components/Modal/Modal.jsx"
    click Nominee "https://github.com/mbl43/my-wealth/blob/main/src/components/Modal/Nominee.jsx"
    click Darkmode "https://github.com/mbl43/my-wealth/blob/main/src/components/Darkmode/Switch.jsx"
    click Home "https://github.com/mbl43/my-wealth/blob/main/src/pages/Home/Home.jsx"
    click Notfound "https://github.com/mbl43/my-wealth/blob/main/src/pages/Notfound/Notfound.jsx"
    click LossRecovery "https://github.com/mbl43/my-wealth/blob/main/src/components/Calc/LossRecovery.jsx"
    click Sip "https://github.com/mbl43/my-wealth/blob/main/src/components/Calc/Sip.jsx"
    click StockAvg "https://github.com/mbl43/my-wealth/blob/main/src/components/Calc/StockAvg.jsx"
    click Login "https://github.com/mbl43/my-wealth/blob/main/src/components/Login/Login.jsx"
    click Signup "https://github.com/mbl43/my-wealth/blob/main/src/components/Signup/SignUp.jsx"
    click ProtectedRoute "https://github.com/mbl43/my-wealth/blob/main/src/components/ProtectedRoute.jsx"
    click Dashboard "https://github.com/mbl43/my-wealth/blob/main/src/components/Dashboard/Dashboard.jsx"
    click ContextAPI "https://github.com/mbl43/my-wealth/blob/main/src/contextAPI.jsx"
    click Firebase "https://github.com/mbl43/my-wealth/blob/main/src/firebase/firebase.js"

    %% Styles and Classes
    classDef ui fill:#cfe2f3,stroke:#1a1aff,stroke-width:2px;
    classDef page fill:#fef8c2,stroke:#ff9900,stroke-width:2px;
    classDef calc fill:#d9e8d8,stroke:#388e3c,stroke-width:2px;
    classDef auth fill:#f3c6c6,stroke:#ff0000,stroke-width:2px;
    classDef state fill:#f3e6c6,stroke:#e6a700,stroke-width:2px;
    classDef external fill:#e2d6ff,stroke:#800080,stroke-width:2px;
    
    %% Legend
    subgraph "Legend"
      direction TB
      L1("UI Components"):::ui
      L2("Pages"):::page
      L3("Calculators"):::calc
      L4("Authentication"):::auth
      L5("Global State"):::state
      L6("External Services & Libraries"):::external
    end
    %% Hide the legend from impacting layout
    style Legend fill:#ffffff,stroke:#ffffff,stroke-width:0px,visibility:hidden
```
