> ## Documentation Index
> Fetch the complete documentation index at: https://developer.moneyone.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Flow Architecture

> PFM platform data flow, processing phases, and analytics response structures

### Data Flow Diagram

```mermaid theme={null}
flowchart TD
    Start([PFM Journey Starts]) --> RaiseConsent[Raise Consent]
    RaiseConsent --> ConsentCallback[Consent Callback]
    ConsentCallback --> ConsentCheck{Consent Approved?}

    ConsentCheck -->|No| ConsentRejected[Consent Rejected<br/>No Data Received]
    ConsentRejected --> EndRejected([Journey Ends])

    ConsentCheck -->|Yes| StorePartialData[Store Partial Data<br/>Link Reference, etc.]
    StorePartialData --> WaitCallback[Wait for Data Callback]

    WaitCallback --> DataCallback{Data Callback<br/>Status}

    DataCallback -->|Success| GenerateAnalytics[Generate Analytics<br/>from FI Data]
    GenerateAnalytics --> ShareAnalytics[Analytics Shared]
    ShareAnalytics --> EndSuccess([PFM Journey Ends])

    DataCallback -->|Failed| DataFailed[Data Callback Failed<br/>FIP Issues]
    DataFailed --> UserSeesFailed[Status as Failed]
    UserSeesFailed --> EndFailed([PFM Journey Ends])
```

### Two Phases of Fetching Data

<AccordionGroup>
  <Accordion title="User Consent Request">
    * A consent is raised with OneMoney when the user wants to initiate financial data sharing through PFM application
    * The user can approve or reject the consent
    * A consent callback is received, with the consent status (APPROVED or REJECTED)
    * If the consent in APPROVED, partial data of the user (basic details like link reference number etc) are stored
  </Accordion>

  <Accordion title="Data Fetching and Analytics Generation">
    * Data Callback is received for approved consents, which contains the raw FI data
    * Analytics is generated on the FI data received
    * On successful generation, the analytics is shared with the user
  </Accordion>
</AccordionGroup>

### Analytics Response Structure

For detailed field explanations and complete data structure references, see our [Analytics Data Dictionary](/pfm/mutual-funds-data-dictionary) which covers all analytics response fields in depth.

<AccordionGroup>
  <Accordion title="ETF Analytics">
    ```json theme={null}
    {
      "status": "SUCCESS",
      "data": {
        "etfAnalysis": {
          "overallAnalysis": {
            "totalPortfolioValue": 250000,
            "totalInvestedAmount": 200000,
            "absolutePercentageReturn": 25.0,
            "profitAmount": 50000,
            "xirr": 12.5,
            "portfolioConsolidatedAnalysis": [],
            "accountDetails": [
              {
                "name": "John Doe",
                "dob": "1990-01-15",
                "mobile": "9876543210",
                "nominee": "Jane Doe",
                "dematId": "12345678901234567890",
                "landline": "",
                "address": "123 Main Street, City, State, 123456",
                "email": "john.doe@example.com",
                "pan": "ABCDE1234F",
                "linkReferenceNumber": "LRN123456789",
                "dataFetchTimeStamp": "2024-02-15T10:30:00Z"
              }
            ],
            "folioDetails": [
              {
                "folioNo": "ETF12345678",
                "linkedAccRef": "ACC123456",
                "totalFolioValue": 125000,
                "totalInvestedAmount": 100000,
                "dematId": "12345678901234567890"
              }
            ]
          },
          "errorFlags": [],
          "fundWiseAnalysis": [
            {
              "isin": "INF204KB17I5",
              "fundName": "Nippon India ETF Nifty 50",
              "accountDetails": [
                {
                  "folioNo": "ETF12345678",
                  "linkedAccRef": "ACC123456"
                }
              ],
              "totalPortfolioValue": 125000,
              "nav": 250.50,
              "units": 500,
              "lastNavDate": "2024-02-15"
            }
          ],
          "marketCapBasedAnalysis": {
            "LARGE_CAP": {
              "percentageContribution": 60.0,
              "portfolioValue": 150000
            },
            "MID_CAP": {
              "percentageContribution": 20.0,
              "portfolioValue": 50000
            },
            "SMALL_CAP": {
              "percentageContribution": 15.0,
              "portfolioValue": 37500
            }
          }
        }
      }
    }
    ```
  </Accordion>

  <Accordion title="Mutual Funds Analytics">
    ```json theme={null}
    {
      "status": "SUCCESS",
      "data": {
        "mutualFundsAnalysis": {
          "overallAnalysis": {
            "totalPortfolioValue": 500000,
            "totalInvestedAmount": 400000,
            "absolutePercentageReturn": 25.0,
            "profitAmount": 100000,
            "xirr": 15.2,
            "accountDetails": [
              {
                "name": "John Doe",
                "dob": "1990-01-15",
                "mobile": "9876543210",
                "folioNo": "MF12345678",
                "pan": "ABCDE1234F",
                "kycCompliance": "COMPLIANT",
                "ckycCompliance": "COMPLIANT"
              }
            ]
          },
          "errorFlags": [],
          "mutualFundWiseAnalysis": [
            {
              "isin": "INF090I01239",
              "amcName": "HDFC Asset Management Company",
              "fundName": "HDFC Equity Fund - Direct Plan - Growth",
              "totalInvestedAmount": 200000,
              "totalPortfolioValue": 250000,
              "nav": 125.50,
              "units": 1992.03,
              "profitAmount": 50000,
              "absolutePercentageReturn": 25.0,
              "expenseRatio": 1.05,
              "cagr": 18.5,
              "xirr": 17.2,
              "marketCapitalizationType": "LARGE_CAP",
              "schemeCategory": "EQUITY"
            }
          ]
        }
      }
    }
    ```
  </Accordion>

  <Accordion title="Equities Analytics">
    ```json theme={null}
    {
      "status": "SUCCESS",
      "data": {
        "equitiesAnalysis": {
          "overallAnalysis": {
            "totalInvestedAmount": 600000,
            "totalPortfolioValue": 750000,
            "profitAmount": 150000,
            "absolutePercentageReturn": 25.0,
            "accountDetails": [
              {
                "name": "John Doe",
                "dob": "1990-01-15",
                "mobile": "9876543210",
                "dematId": "12345678901234567890",
                "pan": "ABCDE1234F",
                "email": "john.doe@example.com"
              }
            ]
          },
          "errorFlags": [],
          "stockWiseAnalysis": [
            {
              "currentlyInvested": true,
              "totalPortfolioValue": 250000,
              "units": 100,
              "currentStockPrice": 2500,
              "totalInvestedAmount": 200000,
              "companyName": "Reliance Industries Limited",
              "sector": "Oil & Gas",
              "isin": "INE002A01018"
            }
          ],
          "marketCapBasedAnalysis": {
            "LARGE_CAP": {
              "percentageContribution": 70.0,
              "profitAmount": 105000,
              "portfolioValue": 525000
            },
            "MID_CAP": {
              "percentageContribution": 20.0,
              "profitAmount": 30000,
              "portfolioValue": 135000
            }
          }
        }
      }
    }
    ```
  </Accordion>

  <Accordion title="Deposit Analytics">
    ```json theme={null}
    {
      "status": "api contract to be added"
    }
    ```
  </Accordion>

  <Accordion title="Term Deposits Analytics">
    ```json theme={null}
    {
      "status": "SUCCESS",
      "data": {
        "profiles": [
          {
            "link_reference_no": "LRN123456789",
            "dob": "1990-01-15",
            "pan": "ABCDE1234F",
            "name": "John Doe",
            "email": "john.doe@example.com",
            "mobile": "9876543210",
            "address": "123 Main Street, City, State, 123456",
            "nominee": "Jane Doe",
            "current_value": "250000",
            "principal_amount": "200000",
            "interest_on_maturity": "50000",
            "interest_rate": "7.5",
            "tenure": "60",
            "opening_date": "2024-01-15",
            "closing_date": "2029-01-15",
            "bank_name": "HDFC Bank",
            "data_fetch_date": "2024-02-15T10:30:00Z",
            "is_partial_data": false
          },
          {
            "link_reference_no": "LRN987654321",
            "dob": "1990-01-15",
            "pan": "ABCDE1234F",
            "name": "John Doe",
            "email": "john.doe@example.com",
            "mobile": "9876543210",
            "address": "123 Main Street, City, State, 123456",
            "nominee": "Jane Doe",
            "current_value": "150000",
            "principal_amount": "100000",
            "interest_on_maturity": "50000",
            "interest_rate": "8.0",
            "tenure": "36",
            "opening_date": "2023-06-01",
            "closing_date": "2026-06-01",
            "bank_name": "SBI",
            "data_fetch_date": "2024-02-15T10:30:00Z",
            "is_partial_data": false
          }
        ],
        "overall_analytics": {
          "link_reference_no_list": [
            "LRN123456789",
            "LRN987654321"
          ],
          "reference_end_date": "2024-02-15",
          "aggregated_term_deposits_amount": [
            {
              "data": {
                "total_term_deposits_amount": 400000
              }
            }
          ],
          "grouped_term_deposits_balance": [
            {
              "data": {
                "term_deposit_balances": [
                  {
                    "bank_name": "HDFC Bank",
                    "total_amount": 250000,
                    "count": 1
                  },
                  {
                    "bank_name": "SBI",
                    "total_amount": 150000,
                    "count": 1
                  }
                ]
              },
              "config": {
                "period": 30,
                "sortby": "amount_desc",
                "grouping": "bank_wise"
              }
            }
          ]
        }
      }
    }
    ```
  </Accordion>

  <Accordion title="Recurring Deposits Analytics">
    ```json theme={null}
    {
      "status": "SUCCESS",
      "data": {
        "profiles": [
          {
            "link_reference_no": "LRN456789123",
            "dob": "1990-01-15",
            "pan": "ABCDE1234F",
            "name": "John Doe",
            "email": "john.doe@example.com",
            "mobile": "9876543210",
            "address": "123 Main Street, City, State, 123456",
            "nominee": "Jane Doe",
            "ckyc_compliance": "COMPLIANT",
            "current_value": "65000",
            "principal_amount": "60000",
            "interest_rate": "6.8",
            "interest_on_maturity": "12000",
            "tenure": "24",
            "opening_date": "2023-02-01",
            "maturity_date": "2025-02-01",
            "bank_name": "ICICI Bank",
            "branch": "MG Road Branch",
            "ifsc": "ICIC0001234",
            "maturity_amount": "72000",
            "recurring_amount": "2500",
            "recurring_deposit_day": "1",
            "data_fetch_date": "2024-02-15T10:30:00Z",
            "is_partial_data": false
          },
          {
            "link_reference_no": "LRN789123456",
            "dob": "1990-01-15",
            "pan": "ABCDE1234F",
            "name": "John Doe",
            "email": "john.doe@example.com",
            "mobile": "9876543210",
            "address": "123 Main Street, City, State, 123456",
            "nominee": "Jane Doe",
            "ckyc_compliance": "COMPLIANT",
            "current_value": "45000",
            "principal_amount": "36000",
            "interest_rate": "7.2",
            "interest_on_maturity": "10800",
            "tenure": "18",
            "opening_date": "2023-08-01",
            "maturity_date": "2025-02-01",
            "bank_name": "Axis Bank",
            "branch": "Commercial Street Branch",
            "ifsc": "UTIB0001567",
            "maturity_amount": "46800",
            "recurring_amount": "2000",
            "recurring_deposit_day": "5",
            "data_fetch_date": "2024-02-15T10:30:00Z",
            "is_partial_data": false
          }
        ],
        "overall_analytics": {
          "link_reference_no_list": [
            "LRN456789123",
            "LRN789123456"
          ],
          "reference_end_date": "2024-02-15",
          "aggregated_recurring_deposits_amount": [
            {
              "data": {
                "total_recurring_deposits_amount": 110000
              }
            }
          ],
          "grouped_recurring_deposits_balance": [
            {
              "data": {
                "recurring_deposit_balances": [
                  {
                    "bank_name": "ICICI Bank",
                    "total_amount": 65000,
                    "count": 1
                  },
                  {
                    "bank_name": "Axis Bank",
                    "total_amount": 45000,
                    "count": 1
                  }
                ]
              },
              "config": {
                "period": 30,
                "sortby": "amount_desc",
                "grouping": "bank_wise"
              }
            }
          ]
        }
      }
    }
    ```
  </Accordion>
</AccordionGroup>
