# piyushh-11/gs-mutual-fund-calculator architecture

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

- Interactive diagram: https://gitdiagram.com/piyushh-11/gs-mutual-fund-calculator
- Repository: https://github.com/piyushh-11/gs-mutual-fund-calculator

## Overview

##### Main Components
- Frontend: This includes the React application with its various components like CalculatorForm, InvestmentForm, Graph, LoginPage, Navbar, PastInvestment, and ResultSummary. Also include the supporting elements such as assets, services (like the API service using axios), and configuration files (e.g., vite.config.js, tailwind.config.js).
- Backend: Consists of the server (server.js), application logic (investment.js), routes (under the “routes” directory), and deployment/environment configurations (.env files). The backend uses Express.js, and from the README, it integrates with MongoDB, Auth0, and Axios.
- Database & External Services: Although the file tree doesn’t show a dedicated database file/folder for MongoDB, the README mentions it. Also include Auth0 (for authentication) and potentially external data sources for real-time market information.

##### Relationships and Interactions
- How the backend communicates with external services (e.g., MongoDB for data persistence and Auth0 for user authentication), indicating data flow.

##### Important Architectural Patterns
- Separation of concerns between the frontend and backend (typical full-stack architecture).
- Use of RESTful API design in the backend routes.
- Client-side state management and component-based design (React components) in the frontend.
- Mention any design principles such as modularity and reusability driven by separate files and directories (e.g., components and services in the frontend).

##### Technologies and Frameworks to Display
- Frontend: React, JavaScript, Chart.js, Tailwind CSS, Vite as a build tool.
- Backend: Node.js, Express.js, and dependencies for environment settings (dotenv).
- External Services: MongoDB (for database functionalities), Auth0 (for authentication), and Axios (for API requests).

##### Detail and Precision
- Configuration file indications if relevant (such as the .env files to denote environment-specific properties).
- To note any important interfaces (such as API endpoints represented in the “routes” folder and the API service in “frontend/src/services/api.js”) so developers have a complete picture of how data flows through the system from the client to the backend services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global External Entity
    U["User"]:::external

    %% Frontend Subgraph
    subgraph "Frontend"
        direction TB
        F1["CalculatorForm"]:::frontend
        F2["Graph"]:::frontend
        F3["InvestmentForm"]:::frontend
        F4["LoginPage"]:::frontend
        F5["Navbar"]:::frontend
        F6["PastInvestment"]:::frontend
        F7["ResultSummary"]:::frontend
        F_api["API Service (axios)"]:::frontend
        F_assets["Assets"]:::frontend
        F_vite["Vite Config"]:::frontend
        F_tailwind["Tailwind CSS Config"]:::frontend
        F_frontenv["Frontend Environment Config (.env)"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend"
        direction TB
        B_server["Express Server"]:::backend
        B_routes["API Routes"]:::backend
        B_logic["Investment Calculation"]:::backend
        B_env["Backend Environment Config (.env)"]:::backend
    end

    %% External Services Subgraph
    subgraph "External Services"
        direction TB
        DB["MongoDB"]:::external
        Auth["Auth0"]:::external
    end

    %% Data Flow Connections
    U -->|"initiates"| F4
    U -->|"navigates via"| F5

    %% Frontend Component Interactions
    F1 -->|"submits/calculates"| F_api
    F3 -->|"submits investment data"| F_api

    %% API call from Frontend to Backend
    F_api -->|"HTTP request"| B_server
    B_server -->|"routes request"| B_routes
    B_routes -->|"executes logic"| B_logic

    %% Backend interactions with External Services
    B_logic -->|"queries"| DB
    B_logic -->|"authenticates"| Auth

    %% Data response flow back to Frontend through Backend
    B_logic -->|"response data"| B_routes
    B_routes -->|"forwards response"| B_server
    B_server -->|"HTTP response"| F_api
    F_api -->|"updates UI"| F7

    %% Styles
    classDef frontend fill:#CDEBFF,stroke:#333,stroke-width:2px;
    classDef backend fill:#FFE0B2,stroke:#333,stroke-width:2px;
    classDef external fill:#D1F2EB,stroke:#333,stroke-width:2px;

    %% Click Events for Frontend Components
    click F1 "https://github.com/piyushh-11/gs-mutual-fund-calculator/blob/main/frontend/src/components/CalculatorForm.jsx"
    click F2 "https://github.com/piyushh-11/gs-mutual-fund-calculator/blob/main/frontend/src/components/Graph.jsx"
    click F3 "https://github.com/piyushh-11/gs-mutual-fund-calculator/blob/main/frontend/src/components/InvestmentForm.jsx"
    click F4 "https://github.com/piyushh-11/gs-mutual-fund-calculator/blob/main/frontend/src/components/LoginPage.jsx"
    click F5 "https://github.com/piyushh-11/gs-mutual-fund-calculator/blob/main/frontend/src/components/Navbar.jsx"
    click F6 "https://github.com/piyushh-11/gs-mutual-fund-calculator/blob/main/frontend/src/components/PastInvestment.jsx"
    click F7 "https://github.com/piyushh-11/gs-mutual-fund-calculator/blob/main/frontend/src/components/ResultSummary.jsx"
    click F_assets "https://github.com/piyushh-11/gs-mutual-fund-calculator/tree/main/frontend/src/assets"
    click F_api "https://github.com/piyushh-11/gs-mutual-fund-calculator/blob/main/frontend/src/services/api.js"
    click F_vite "https://github.com/piyushh-11/gs-mutual-fund-calculator/blob/main/frontend/vite.config.js"
    click F_tailwind "https://github.com/piyushh-11/gs-mutual-fund-calculator/blob/main/frontend/tailwind.config.js"
    click F_frontenv "https://github.com/piyushh-11/gs-mutual-fund-calculator/blob/main/frontend/.env"
    
    %% Click Events for Backend Components
    click B_server "https://github.com/piyushh-11/gs-mutual-fund-calculator/blob/main/backend/server.js"
    click B_logic "https://github.com/piyushh-11/gs-mutual-fund-calculator/blob/main/backend/investment.js"
    click B_routes "https://github.com/piyushh-11/gs-mutual-fund-calculator/blob/main/backend/routes/investments.js"
    click B_env "https://github.com/piyushh-11/gs-mutual-fund-calculator/blob/main/backend/.env"
```
