Fund Purifier: Invest in halal versions of popular US funds
Introduction
Investing in the stock market as a Muslim is hard, because it’s not always obvious what’s halal and what isn’t. It gets even trickier when it comes to investing in funds, because there’s no way to exclude non-halal stocks from a fund with hundreds of stocks.
Until now.
Why
We built the Fund Purifier to automatically filter any US-listed mutual fund or ETF for you.
Just choose a fund, and we automatically filter it for compliant stocks.
On top of that, we also support:
🔍 Tracking fund changes so your filtered fund reflects additions/removals in the original fund
🗑️ Automatic removal when a stock turns haram (and re-added if it turns halal)
⚖️ Smart rebalancing so any funds invested/withdrawn help you come closer to the target weights
… and more!
It’s also 100% Free! You can use it today by signing up at https://fundpurifier.com.
Oh, and one more thing. It’s completely open-source 💥
Important Just looking to use the Fund Purifier? Use the hosted version at app.fundpurifier.com
Development
Install dependencies
git clone https://github.com/fundpurifier/app.git
npm install
Register for 3rd Party Services
The Fund Purifier relies on some 3rd party services. You’ll need to sign up for these in order to run the app locally:
- Alpaca Developer App for executing trades (powers the “Sign in with Alpaca” functionality)
- Clerk for authentication
- Resend for email notifications
You’ll need to sign up to these services and populate your local .env
file with the following keys:
ALPACA_CLIENT_ID=
ALPACA_CLIENT_SECRET=
CLERK_SECRET_KEY=
RESEND_KEY=
Production
To run the Fund Purifier in production, you’ll need to register for additional 3rd party services:
- Musaffa B2B for retrieving Shariah compliance data via API
- Finnhub B2B for retrieving fund holdings, ISIN data, logos, exchange symbols and realtime quotes
- Financial Modeling Prep for bulk retrieval of realtime quotes
- EOD Historical Data for bulk retrieval of historical end-of-day quotes
Once done, populate your local .env
file with the following keys:
ALPACA_CLIENT_ID=
ALPACA_CLIENT_SECRET=
FINNHUB_FREE_KEY=
FINNHUB_API_KEY=
MUSAFFA_CLIENT_ID=
MUSAFFA_SECRET_KEY=
EOD_HISTORICAL_DATA_API_KEY=
FINANCIAL_MODELING_PREP_KEY=
Note: These are paid services. The total cost is around $20k/year.
IMPORTANT: You do not need to sign up to these services to run the Fund Purifier locally. We provide mocked responses in development instead.
Tech Stack
The Fund Purifier is built using the latest tech. Here’s a run-down of what our stack looks like:
- NextJS 14, with
app
directory - React (Frontend / Server Components)
- SQLite
- Typescript
- BullMQ
- Redis
Overview
Let’s cover the main parts of the project src/
directory:
app/
: all the routes used in the client applicationcomponents/
: reusable components used throughout the applicationhooks/
: mainly used for global state managementlib/
: includes interfaces for 3rd party libraries and servicesmodels/
: includes zod schemas for verifying data from 3rd partiesservices/
: any sufficiently complex code taken outside controllersworkers/
: any long-running code that runs in the background
Authors
License
AGPL 3.0 License