# smartsood/invest-iq-finance-demo architecture

> Architecture diagram of the GitHub repository smartsood/invest-iq-finance-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/smartsood/invest-iq-finance-demo
- Repository: https://github.com/smartsood/invest-iq-finance-demo

## Overview

##### Project type and purpose
- This is a single-page React frontend served by Vite, paired with an Express-style Node.js backend (in src/server.js), a data layer (models/), and several external services (Polygon, Google Translate, Google Sign-In).
- The system supports user authentication, portfolio and trend analysis, learning modules, and multilingual text services.

##### File structure
- Top level:
- package.json, vite.config.js, eslint.config.js: build & lint config
- index.html: Vite entry
- models/: domain/entity schemas (levels, module, user)
- public/: static assets
- src/:
– main.jsx, App.jsx: React entry point & root component
– component/: UI components (Auth, Dashboard, Analysis, Learning, ChatBot, etc.)
– context/: React Context providers (Auth, Translation, XP)
– hooks/: custom hooks (useTranslation, useGoogleTranslate)
– middlewares/, routes/, services/: backend logic
– server.js: sets up Express server & middleware
- Architectural patterns:
- Frontend: SPA with React Context and custom hooks
- Backend: MVC-style (routes → controllers/services → models)
- Shared services: caching, external API wrappers (polygonService, translationService)

##### README
- Confirms React + Vite setup, Fast Refresh, ESLint.

##### Main components & interactions
a. Frontend (React/Vite)
- Components: LoginPage, DashboardLayout, Analysis pages, Learning modules, ChatBot
- Contexts for auth, translation, XP
- Communicates via HTTP/REST to backend API
b. Backend (Node.js/Express)
- Routes: /auth (in routes/auth.js) and other protected routes
- Middlewares: cache.js, ProtectedRoute logic
- Controllers/Services: polygonService (market data), translationService (calls Google Translate API)
- Models: user, module, levels (persisted in a database, e.g. MongoDB)
c. Database
- A document-oriented store (likely MongoDB) hosting user/module/levels collections
d. External services
- Google OAuth for Sign-In
- Polygon API for financial data
- Google Translate API for multilingual support

##### Architectural patterns & principles
- Separation of concerns:
- UI (React) vs. API (Express) vs. Data (DB)
- MVC/Layered architecture on backend
- SPA with client-side routing and protected routes
- Context API for cross-cutting concerns (auth, translation, XP)
- Use of middleware for caching & auth checks

- Component subdivisions for clarity, but avoid over-cluttering

## Diagram (Mermaid)

```mermaid
flowchart TB
    User([User]):::external
    Browser([Browser]):::external

    User --> Browser

    subgraph "Frontend (React/Vite SPA)"
      direction TB
      Entry["Vite/React Bootstrap"]:::ui
      click Entry "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/main.jsx"
      Root["App Component"]:::ui
      click Root "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/App.jsx"

      subgraph "Contexts"
         AuthCtx["AuthContext"]:::ui
         click AuthCtx "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/context/AuthContext.jsx"
         TransCtx["TranslationContext"]:::ui
         click TransCtx "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/context/TranslationContext.jsx"
         XpCtx["XpContext"]:::ui
         click XpCtx "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/context/XpContext.jsx"
      end

      subgraph "Public Pages"
         Login["LoginPage"]:::ui
         click Login "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/LoginPage.jsx"
         Signin["SigninPage"]:::ui
         click Signin "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/SigninPage.jsx"
      end

      subgraph "Protected Layout & Pages"
         ProtRoute["ProtectedRoute"]:::ui
         click ProtRoute "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/ProtectedRoute.jsx"
         DashboardLayout["DashboardLayout"]:::ui
         click DashboardLayout "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/DashboardLayout.jsx"
         Dashboard["Dashboard"]:::ui
         click Dashboard "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/Dashboard.jsx"

         subgraph "Analysis"
            AHome["Analysis Home"]:::ui
            click AHome "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/Analysis/Analysis_Home.jsx"
            PortAn["PortfolioAnalyzer"]:::ui
            click PortAn "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/Analysis/PortfolioAnalyzer.jsx"
            TrendAn["TrendAnalyzer"]:::ui
            click TrendAn "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/Analysis/TrendAnalyzer.jsx"
            SelPage["SelectionPage"]:::ui
            click SelPage "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/Analysis/SelectionPage.jsx"
         end

         subgraph "Learning Modules"
            LearnShell["Learning_app"]:::ui
            click LearnShell "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/Learning/Learning_app.jsx"
            MyMods["My_modules"]:::ui
            click MyMods "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/Learning/My_modules.jsx"
            ModOverview["Modules"]:::ui
            click ModOverview "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/Learning/Modules.jsx"
            Practice["Practice"]:::ui
            click Practice "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/Learning/Practice.jsx"
            Levels["levels"]:::ui
            click Levels "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/Learning/levels.jsx"
            AboutMod["About_Modules"]:::ui
            click AboutMod "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/Learning/About_Modules.jsx"
            Finish1["Finish.jsx"]:::ui
            click Finish1 "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/Learning/Finish.jsx"
            Finish2["FinishModule.jsx"]:::ui
            click Finish2 "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/Learning/FInishModule.jsx"
         end

         Chat["ChatBot"]:::ui
         click Chat "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/ChatBot.jsx"
      end

      subgraph "Shared UI"
         About["About"]:::ui
         click About "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/About/About.jsx"
         Contact["Contact"]:::ui
         click Contact "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/Contact/Contact.jsx"
         FAQ["FAQPage"]:::ui
         click FAQ "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/FAQPage.jsx"
         Policies["Policies"]:::ui
         click Policies "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/Policies/Policies.jsx"
         SignBtn["GoogleSignInButton"]:::ui
         click SignBtn "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/GoogleSignInButton.jsx"
         Navbar["navbar"]:::ui
         click Navbar "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/navbar.jsx"
         NavMod["navbarModule"]:::ui
         click NavMod "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/navbarModule.jsx"
         Card["card"]:::ui
         click Card "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/card.jsx"
         Text["Text"]:::ui
         click Text "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/Text.jsx"
         Slide["SlideSensex"]:::ui
         click Slide "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/component/SlideSensex.jsx"
      end

      subgraph "Custom Hooks"
         UseTrans["useTranslation"]:::ui
         click UseTrans "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/hooks/useTranslation.js"
         UseGTrans["useGoogleTranslate"]:::ui
         click UseGTrans "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/hooks/useGoogleTranslate.js"
      end

      Browser --> Entry
      Entry --> Root
      Root --> AuthCtx
      Root --> TransCtx
      Root --> XpCtx
      Root --> Login
      Root --> Signin
      Root --> ProtRoute
      ProtRoute --> DashboardLayout
      DashboardLayout --> Dashboard
      Dashboard --> PortAn
      Dashboard --> TrendAn
    end

    subgraph "Backend (Express API)"
      direction TB
      Server["Express Server"]:::backend
      click Server "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/server.js"

      subgraph "Middlewares"
         Cache["cache.js"]:::backend
         click Cache "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/middlewares/cache.js"
      end

      subgraph "Routes"
         AuthRoutes["auth.js"]:::backend
         click AuthRoutes "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/routes/auth.js"
      end

      subgraph "Services"
         PolyServ["polygonService"]:::backend
         click PolyServ "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/services/polygonService.js"
         TransServ["translationService"]:::backend
         click TransServ "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/services/translationService.js"
      end

      subgraph "Utilities"
         LangCodes["languageCodes"]:::backend
         click LangCodes "https://github.com/smartsood/invest-iq-finance-demo/blob/main/src/utils/languageCodes.js"
      end

      subgraph "Models"
         UserModel["user.js"]:::backend
         click UserModel "https://github.com/smartsood/invest-iq-finance-demo/blob/main/models/user.js"
         ModuleModel["module.js"]:::backend
         click ModuleModel "https://github.com/smartsood/invest-iq-finance-demo/blob/main/models/module.js"
         LevelsModel["levels.js"]:::backend
         click LevelsModel "https://github.com/smartsood/invest-iq-finance-demo/blob/main/models/levels.js"
      end

      Server --> Cache
      Server --> AuthRoutes
      AuthRoutes --> UserModel
      AuthRoutes --> OAuth
      Server --> PolyServ
      Server --> TransServ
      PolyServ --> PolyAPI
      TransServ --> GTrans
      UserModel --> DB
      ModuleModel --> DB
      LevelsModel --> DB
    end

    subgraph "Database"
      DB[(MongoDB)]:::data
    end

    subgraph "External Services"
      OAuth["Google OAuth"]:::external
      PolyAPI["Polygon API"]:::external
      GTrans["Google Translate API"]:::external
    end

    classDef ui fill:#cce5ff,stroke:#004085
    classDef backend fill:#ffe5b4,stroke:#c76300
    classDef data fill:#d4edda,stroke:#155724
    classDef external fill:#f3e5f5,stroke:#6f42c1
```
