# vsaravind01/smart-wealth architecture

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

- Interactive diagram: https://gitdiagram.com/vsaravind01/smart-wealth
- Repository: https://github.com/vsaravind01/smart-wealth

## Overview

##### Main Components
- Frontend: This is the user interface that displays real-time market insights, investment recommendations, and tailored planning. It contains typical assets (HTML, CSS, JavaScript files) and component-based widgets (chat area, mutual fund and stock widgets) as seen in the /frontend directory.
- Backend API: Under the backend/api directory, the API layer handles routes and endpoints (agent, mutual_fund, services, stock) that the frontend calls.
- Core Processing Modules: Several directories under /backend/core, such as:
- finance_agents_network, which implements the reinforcement learning agents (e.g., investor_agent, market_analyzer_agent, etc.)
- market_forecaster, which provides real-time market forecasting services.
- Document Loader: Responsible for data ingestion from different document sources (news, expert documents, NSE, websites, etc.), as observed in the backend/document_loader folder.
- Data & Models: The backend/models directory houses various document representations and utilities for processing data.
- Cluster & Analytics: The backend/clusters directory contains clustering scripts and notebooks (for example, clustering_v1.ipynb) that drive data insights or segmentation.
- Data Persistence & Vector Stores: The project leverages a MongoDB-based store (backend/mongo_store) and has vector store integrations (e.g., azure_cosmos_db, bob_web_db) for efficient retrieval and semantic search.

##### Architectural Patterns and Key Design Principles
- Layered Architecture: Emphasize how the design clearly segments presentation (frontend), application logic (API and core services), and data/storage concerns.
- Modular Design: The division into smaller folders like document loader, models, and clusters suggests a design that promotes separation of concerns.
- Microservice-ish Separation in the backend: Although contained in one repository, each core function (API, agents, data ingestion, storage) has its own directory and role.
- Use of Advanced Retrieval and ML Components: Note that the design integrates advanced retrieval strategies (RAG Fusion, semantic chunking, semantic caching) and reinforcement learning agents for investment strategies.

- Use clear labels: Each component (API Gateway, Document Loader, Financial Agents, Clustering Module, etc.) should be clearly labeled.

##### Final Assembly
- From the API gateway, branch into multiple modules:
- Directly to the finance agents network (reinforcement learning agents).
- To market forecaster services.
- To document loaders (which link into models).
- Interconnections from these modules to the MongoDB/vector store.
- Additionally, illustrate the clustering module as supporting analytics.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    A["Smart-Wealth Frontend"]:::frontend

    %% Backend API Layer
    B["API Gateway (Backend API)"]:::backend

    %% Core Services
    C["Finance Agents Network"]:::service
    D["Market Forecasting Service"]:::service
    E["Document Loader"]:::service
    F["Data & Models"]:::service
    G["Clustering & Analytics Module"]:::service

    %% Data Storage
    H["MongoDB Store"]:::database
    I["Vector Stores"]:::database

    %% Data flow from Frontend to Backend API
    A -->|"HTTP_Request"| B

    %% API Gateway directs to Core Services
    B -->|"Process_Request"| C
    B -->|"Process_Request"| D
    B -->|"Process_Request"| E
    B -->|"Process_Request"| F
    B -->|"Process_Request"| G

    %% Core Services interact with Data Storage
    C -->|"DataRead/Write"| H
    C -->|"DataRead/Write"| I

    D -->|"DataRead/Write"| H
    D -->|"DataRead/Write"| I

    %% Document Loader feeds into Data & Models
    E -->|"IngestData"| F
    F -->|"Store/Retrieve"| H
    F -->|"Store/Retrieve"| I

    %% Clustering analytics provide feedback to Finance Agents
    G -->|"AnalyticsResults"| C

    %% Click Events
    click A "https://github.com/vsaravind01/smart-wealth/tree/master/frontend/"
    click B "https://github.com/vsaravind01/smart-wealth/tree/master/backend/api/"
    click C "https://github.com/vsaravind01/smart-wealth/tree/master/backend/core/finance_agents_network/"
    click D "https://github.com/vsaravind01/smart-wealth/blob/master/backend/core/market_forecaster/services.py"
    click E "https://github.com/vsaravind01/smart-wealth/tree/master/backend/document_loader/"
    click F "https://github.com/vsaravind01/smart-wealth/tree/master/backend/models/"
    click G "https://github.com/vsaravind01/smart-wealth/tree/master/backend/clusters/"
    click H "https://github.com/vsaravind01/smart-wealth/tree/master/backend/mongo_store/"
    click I "https://github.com/vsaravind01/smart-wealth/tree/master/backend/vector_stores/"

    %% Styles
    classDef frontend fill:#B3E5FC,stroke:#0288D1,stroke-width:2px;
    classDef backend fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef service fill:#FFF9C4,stroke:#F9A825,stroke-width:2px;
    classDef database fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
```
