# MDRIFT - Mutual Fund Composition & Drift Analyzer

Serverless mutual fund portfolio analysis app. Tracks holdings drift across 21 Indian mutual funds (5 categories) over multiple time periods. Runs entirely in-browser - no backend needed.

## Links
- App: https://mf-fetch.tigzig.com
- GitHub (v1 — open source): https://github.com/amararun/shared-mf-portfolio-full-app-react

Note: The current live MDRIFT app is a newer proprietary version. The GitHub repo above is the v1 open-source version. The v1 codebase demonstrates the core architecture (in-browser SQLite, fund comparison, drift analysis) and can be used as a starting point for similar projects.

## Tags
mutual-funds, mdrift, duckdb, react, serverless

## Architecture

Fully serverless - Vercel serves static files only. All data processing happens in the browser.

```
Browser
├── React 18 + TypeScript + Vite + TailwindCSS
├── SQLite via sql.js (WebAssembly) - ~1.6MB DB downloaded once
├── Plotly.js (interactive charts)
└── Zustand (state management)
```

- Database: SQLite loaded in-browser via sql.js (WebAssembly)
- Raw data files: AMC Excel files hosted on GitHub Releases (amararun/datasets)
- No backend API calls - all queries run client-side

## Features

- Period-over-period holdings comparison: new entries, exits, increases, decreases
- Interactive holdings analyzer with charts and full data table
- AUM breakdown by fund and aggregate
- ISIN validation and corporate action tracking
- Debt instrument grouping by issuer
- Direct stock links to NSE and Yahoo Finance

## Data

- `public/data/mf_portfolio.db` - SQLite database served to browser (holdings + fund metadata)
- `public/data/validation_log.csv` - Conversion validation results
- Raw Excel files from AMC disclosures hosted on GitHub Releases, linked via `src/config/fundFileConfig.ts`

## Data Pipeline Scripts

Scripts in `scripts/` handle: Excel-to-SQLite conversion, ISIN mapping, validation, extension fixing. AMC downloader scripts in `scripts/downloaders/` automate downloading SEBI-mandated monthly portfolio disclosures from AMC websites.

## Setup

```bash
git clone https://github.com/amararun/shared-mf-portfolio-full-app-react.git
cd shared-mf-portfolio-full-app-react
npm install
npm run dev
```

No environment variables or backend setup required.
