Inspiration
Most people assume that investing well means choosing between making money and staying true to their values. The S&P 500 is a reliable benchmark, but it's a broad basket, and tucked inside it are companies that many investors would rather not fund: fossil fuel producers, weapons manufacturers, or companies with poor labor practices, depending on who you ask.
We wanted to fix that. Alignfolio lets you describe your values in plain English and converts them into concrete rules that shape your portfolio. Exclude entire industries, prioritize others, or weight your holdings by ethical criteria, all without needing to know anything about quantitative finance. The NLP layer does the translation; the math does the rest.
To power this translation, we deployed Mistral 7B Instruct (q4_K_M), a fully open-source large language model running entirely on-device. When a user states a preference, "I don't want to support fossil fuels" or "I care about fair labor," Mistral interprets the intent and maps it to concrete financial parameters. No third-party API, no data leaving the machine. The result is a system where human values and portfolio construction speak the same language.
What it does
Alignfolio is an Ethos-Driven Portfolio Optimizer. It takes a user's "moral objective" and passes it through a local LLM to extract high-affinity sectors and exclusionary filters. The system then calculates a customized portfolio that maintains the stability of the S&P 500 while maximizing for the user's specific values. Users can view their alignment score, track real-world impact metrics (like $CO_2$ avoided), and see a real-time backtest of how their ethical strategy would have performed historically against the traditional market.
How we built it
We built Alignfolio using a high-performance modern stack: The intelligence: We used Mistral 7B running locally to handle sentiment analysis and thematic mapping. The Backend: A FastAPI server coordinates the LLM inference and the portfolio optimization logic. The frontend: Built with React and Tailwind CSS v4, utilizing a "bento grid" design system to make complex financial data digestible. The Motion: We integrated Framer Motion for a "glassmorphism" UI that feels alive, featuring animated count-ups and smooth tab transitions. The Math: We implemented a weighting algorithm that rebalances S&P 500 constituents based on affinity scores derived from the LLM’s sector analysis, ensuring the budget is fully utilized while minimizing "tracking error" against the benchmark.
Challenges we ran into
One of the primary hurdles was data sanitization between the LLM and the Financial Engine. LLMs are non-deterministic, meaning they sometimes return data in formats that a rigid financial calculator can't read. We spent significant time building a "defensive" frontend and backend middleware to catch "hallucinated" tickers or string-formatted weights before they reached our React components, preventing the dreaded "black screen" UI crashes.
Additionally, optimizing the local inference speed was a challenge. Running a 7B parameter model alongside a heavy React frontend requires careful memory management to ensure the "Ethos Engine" feels responsive rather than sluggish.
Accomplishments that we're proud of
We are incredibly proud of achieving a fully local AI pipeline. In an era of data privacy concerns, building a tool that handles sensitive financial intent without sending a single byte to an external LLM provider is a major win. We also successfully created a "professional grade" dashboard aesthetic that makes sophisticated financial optimization accessible to the everyday investor.
What we learned
We learned that UX is the bridge between AI and utility. You can have the best model in the world, but if the user doesn't see a "count-up" animation or a clear "impact" score, the math feels invisible. Technically, we deepened our understanding of React state management for asynchronous API calls and the nuances of CORS and middleware configuration in FastAPI to ensure seamless local communication between ports.
What's next for Alignfolio
The next step is multi-asset support. We want to expand beyond the S&P 500 to include international equities and green bonds. We also plan to implement "Direct Indexing" capabilities, allowing users to connect their actual brokerage accounts to Alignfolio to execute these ethical trades with a single click. Finally, we want to fine-tune our Mistral model on a proprietary dataset of ESG reports to make the "Ethos Engine" even more precise in its moral mapping.
Built With
- css
- fastapi
- html
- javascript
- mistral
- ollama
- python
- react
- recharts
- tailwind
Log in or sign up for Devpost to join the conversation.