A neuro-symbolic AI system that helps users achieve their financial goals through personalized, transparent, and privacy-first investment planning.
π Live Demo β’ Features β’ Installation β’ Architecture β’ Team
- Documentation: See Below
- GitHub: Repository
- Demo of Goal Engine:
Goal-Engine.mp4
- XAI:
XAI.mp4
FinTwin is a goal-based financial planning platform that combines Large Language Models (LLMs) with mathematical optimization algorithms to deliver transparent, personalized investment recommendations. Unlike traditional asset-centric approaches, FinTwin organizes all financial decisions around user-defined life goalsβretirement, home purchase, education, wealth growth, and emergency funds.
Traditional Approach:
"Here's a balanced portfolio for your risk profile."
FinTwin's Approach:
"This retirement portfolio needs 73% growth exposure to achieve $1.025M by 2059 with 96% probability. Here's how each investment contributes to your specific goal."
- Goal-Centric Design: Every financial decision is linked to a specific life goal with defined timeline, target amount, and risk tolerance
- Neuro-Symbolic AI: LLMs handle reasoning and context analysis (neural), while deterministic algorithms execute financial calculations (symbolic)
- Complete Transparency: Full audit trail of AI decisions with explainable recommendations and citations
- Privacy-First: Three-layer privacy controls with granular data sharing management
- Four-Stage AI Pipeline: Definition β Strategy β Product Selection β Simulation
- Multi-Goal Optimization: Automatically allocates limited resources across competing goals
- Progress Tracking: Real-time visualization of goal progress and success probability
- Asset Linking: Prevents double-counting by tracking which assets fund which goals
- Conversational AI: Natural language Q&A with streaming responses
- Function Calling: LLM invokes computational tools for portfolio optimization
- RAG Integration: 501 curated document chunks from NZ financial regulations
- Multi-Provider Support: DeepSeek R1, GPT-4o, Gemini 1.5 Flash
- Asset-Liability Tracking: Real-time net worth calculation
- Cash Flow Engine: Monthly surplus analysis (income - expenses - goals)
- Scenario Simulation: Forward-looking projections (1-40 years)
- Liquidity Analysis: Three-tier asset classification (liquid/semi-liquid/locked)
- 1,100+ Products: KiwiSaver funds (339), managed funds (750+), term deposits
- Automated Construction: 3 portfolio options (lowest cost, diversified, balanced)
- Constraint Satisfaction: Product weights, exposure targets, fee limits
- Monte Carlo Simulation: 100 iterations with probabilistic outcome analysis
- Three-Layer Protection: Global toggle, granular allowlist, PII sanitization
- Request-Level Override: Per-conversation privacy control
- GDPR-Compliant: Automated scrubbing of personal identifiers
- Audit Trail: Complete decision logging for regulatory compliance
- Dynamic Form Generation: AI-generated context-aware questionnaires
- Session Isolation: Prevents context leakage between goals
- Intelligent Document Processing: Automated quality filtering for RAG corpus
- Background Tasks: Asynchronous simulation execution with progress tracking
- Comprehensive Testing: 208 backend tests (13 suites), 23 E2E tests, stable CI/CD pipeline
- Automated CI/CD: GitHub Actions pipelines for testing, linting, and build verification
Try FinTwin now: http://13.210.244.120/
Note: This is a demo deployment hosted on AWS. Feel free to create an account and explore the features!
To quickly explore all features without manual data entry:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β React Frontend (Vite) β
β β’ Dynamic form rendering β’ Real-time SSE streaming β
β β’ Session-based context isolation β’ Smart routing & navigation β
ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β REST API + SSE
ββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββ
β Node.js/Express Backend β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Goal Engine Controller (Hybrid AI Core) β β
β β β’ Context enrichment β’ Privacy filtering β β
β β β’ LLM orchestration β’ Algorithm execution β β
β β β’ Decision logging β’ Function calling β β
β ββββββββββ¬βββββββββββββββββββββββββββββββββββ¬βββββββββββββββ β
β β β β
β ββββββββββΌββββββββββ βββββββββββββΌβββββββββββ β
β β LLM Service β β Financial Algorithmsβ β
β β β’ Multi-providerβ β β’ Portfolio optimizerβ β
β β β’ RAG integrationβ β β’ Monte Carlo engineβ β
β β β’ Streaming β β β’ Resource allocatorβ β
β ββββββββββ¬ββββββββββ βββββββββββββ¬βββββββββββ β
βββββββββββββΌββββββββββββββββββββββββββββββββββΌβββββββββββββββββββ
β β
βββββββββ΄βββββββββββ¬ββββββββββββββββββββββ΄βββββββββ
β β β
βΌ βΌ βΌ
βββββββββββ ββββββββββββββββ ββββββββββββββββ
β MongoDB β β DeepSeek R1 β β Vectara β
β10 Modelsβ β (LLM API) β β (RAG Store) β
βββββββββββ ββββββββββββββββ ββββββββββββββββ
| Layer | Technology | Purpose |
|---|---|---|
| Frontend | React 19 + Vite 7 | Dynamic form rendering, session management, SSE streaming |
| API | Express 5 + Mongoose 9 | RESTful endpoints, AI-algorithm orchestration, privacy middleware |
| AI Layer | DeepSeek R1, GPT-4o, Gemini | Natural language reasoning, context analysis, function calling |
| Algorithm Layer | Custom implementations | Portfolio optimization, Monte Carlo simulation, linear programming |
| RAG | Vectara v2 | Semantic search over 501 cleaned document chunks |
| Database | MongoDB 6 | 10 collections with 50+ embedded schemas |
- Runtime: Node.js 20.x
- Framework: Express 5.x
- Database: MongoDB 6.x with Mongoose 9.x
- AI/ML:
- DeepSeek R1 (primary LLM)
- GPT-4o (high-stakes decisions)
- Gemini 1.5 Flash (document processing)
- Vectara v2 (vector database for RAG)
- Key Libraries:
@google/generative-ai- Gemini API clientglpk.js- Linear programming for resource allocationpdf-parse,mammoth- Document processingnode-cron- Scheduled tasks
- Framework: React 19.2
- Build Tool: Vite 7.x
- UI Libraries:
- Tailwind CSS 4.x + DaisyUI 5.x
- Material-UI 7.x
- Recharts 3.x (charts)
- Lucide React (icons)
- Key Libraries:
react-markdown- Markdown renderingreact-router-dom7.x - Routingaxios- HTTP clientkatex- Math formula rendering
- Testing:
- Frontend: Vitest 4.x + Testing Library + Happy-DOM
- Backend: Jest + Supertest
- E2E Testing: Cypress
- Linting: ESLint 9.x
- CI/CD: GitHub Actions (automated testing, linting, build verification)
- Authentication: JWT (jsonwebtoken)
- Environment: dotenv
- Node.js: v20.0.0 or higher
- MongoDB: v6.0 or higher (local or Atlas)
- API Keys:
- DeepSeek API key (for primary LLM)
- Vectara API key (for RAG)
- (Optional) OpenAI API key for GPT-4o
git clone https://github.com/your-org/money-minds.git
cd money-minds# Backend dependencies
cd backend
npm install
# Frontend dependencies
cd ../frontend
npm installCreate backend/.env file:
# Database
MONGODB_URI=mongodb://localhost:27017/fintwin
# Server
PORT=5001
NODE_ENV=development
# JWT Authentication
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
# LLM Provider (options: deepseek, gemini, bedrock)
LLM_PROVIDER=deepseek
# DeepSeek API
DEEPSEEK_API_KEY=your-deepseek-api-key
DEEPSEEK_MODEL=deepseek-reasoner
# Gemini API (optional)
GEMINI_API_KEY=your-gemini-api-key
GEMINI_MODEL=gemini-1.5-flash
# OpenAI API (optional)
OPENAI_API_KEY=your-openai-api-key
# Vectara RAG
VECTARA_API_KEY=your-vectara-api-key
VECTARA_CUSTOMER_ID=your-customer-id
VECTARA_CORPUS_KEY=FinTwin_Docs
# Privacy & Sanitization
PRIVACY_SANITIZATION_MODE=pii_onlyCreate frontend/.env file:
# API Base URL
VITE_API_BASE_URL=http://localhost:5001/api
# Feature Flags (optional)
VITE_ENABLE_DEBUG=falsecd backend
# Import financial products (KiwiSaver funds, managed funds)
npm run seed
# (Optional) Upload documents to Vectara for RAG
npm run update-kbcd backend
npm run devServer will start at http://localhost:5001
cd frontend
npm run devFrontend will start at http://localhost:5173
- Open browser and navigate to
http://localhost:5173 - Register a new account
- Complete the onboarding questionnaire
- Start creating your first financial goal!
- Navigate to Goals Page: Click "Goals" in the sidebar
- Create New Goal: Click "Create Goal" button
- Choose Category: Select from retirement, home purchase, education, wealth growth, or emergency fund
- AI-Guided Planning: Follow the four-stage process:
- Definition: Specify target amount, timeline, and priority
- Strategy: AI recommends risk profile and contribution strategy
- Product Selection: Choose from 3 optimized portfolios
- Simulation: View Monte Carlo projections and success probability
- Navigate to Wealth Center: Click "Wealth" in the sidebar
- Add Assets: Click "Add Asset" and categorize (cash, investments, property, etc.)
- Add Liabilities: Record debts, mortgages, loans
- Track Cash Flow: Add recurring income and expenses
- View Analytics: Monitor net worth trends, liquidity analysis, and allocation charts
- Ask Mode: General financial questions with RAG-powered answers
- Auto Mode: Structured goal planning with form generation
- Agent Mode: Autonomous multi-step reasoning
- Global Settings: Navigate to Settings β Privacy
- Toggle AI Sharing: Enable/disable data sharing with AI
- Granular Control: Select which data types to share (assets, income, debts, etc.)
- Per-Request Override: Use chatbox privacy toggle for one-time exceptions
Before committing changes, run tests locally to ensure code quality:
# Backend tests (Jest)
cd backend
npm test
# Frontend tests (Vitest)
cd frontend
npm test -- --run
# Frontend tests with coverage
npm test -- --run --coverage
# Linting
npm run lint
# Build verification
npm run buildCI/CD Integration: All tests run automatically via GitHub Actions on push/PR to main branches. Check the Actions tab for build status.
money-minds/
βββ backend/
β βββ config/ # Database configuration
β βββ controllers/ # Route handlers (8 controllers)
β βββ middleware/ # Auth, privacy, error handling
β βββ models/ # Mongoose schemas (10 models)
β βββ routes/ # API routes
β βββ services/ # Business logic
β β βββ llmService.js # LLM abstraction layer
β β βββ goalEnginePrompts.js # AI prompts (1,000+ lines)
β β βββ productTools.js # Portfolio optimization
β β βββ vectaraClient.js # RAG integration
β β βββ ...
β βββ scripts/ # Data processing & seeding
β βββ utils/ # Helpers & sanitizers
β βββ server.js # Express app entry point
β
βββ frontend/
β βββ public/ # Static assets
β βββ src/
β β βββ components/ # Reusable components (60+)
β β β βββ goals/ # Goal-related components
β β β β βββ engine/ # AI engine components
β β β βββ wealth/ # Wealth management components
β β β βββ ...
β β βββ pages/ # Route pages (25 pages)
β β β βββ GoalIntakePage.jsx # Main goal planning (1,909 lines)
β β β βββ WealthCenterPage.jsx # Wealth management
β β β βββ Dashboard.jsx # User dashboard
β β β βββ ...
β β βββ services/ # API clients
β β βββ utils/ # Helpers
β β βββ App.jsx # React app entry point
β βββ cypress/ # E2E tests
β
βββ docs/ # Additional documentation
βββ README.md # This file
| File | Purpose | Lines |
|---|---|---|
backend/services/goalEnginePrompts.js |
AI prompts for 4-stage planning | ~1,000 |
backend/services/productTools.js |
Portfolio optimization algorithms | ~800 |
frontend/src/pages/GoalIntakePage.jsx |
Main goal planning interface | 1,909 |
frontend/src/components/goals/engine/Copilot.jsx |
AI chatbox component | 1,045 |
backend/specification.md |
Technical specification & formulas | 535 |
Problem: Traditional advice focuses on asset allocation without linking to specific life goals.
Solution: Full lifecycle goal management with automated resource allocation.
- Asset Linking: Each
FinancialAssetcan be linked to a specific goal vialinked_goal_id - Resource Conflict Prevention: System tracks allocated assets across goals to prevent double-counting
- Multi-Goal Optimization: Linear programming allocates limited resources across competing goals
- Progress Tracking: Real-time visualization of goal progress and success probability
User Value: Users see exactly how each investment contributes to specific life goals, making financial planning more tangible and motivating.
Design Principle: Separate AI reasoning from algorithmic computation for reliability and explainability.
- Natural language understanding of user goals
- Context-aware recommendation generation
- Document retrieval and synthesis (RAG)
- Intent classification (Ask vs. Auto mode)
- Function calling to invoke computational tools
- Portfolio optimization (gradient descent + greedy selection)
- Monte Carlo simulation (100 iterations with Box-Muller sampling)
- Multi-goal resource allocation (linear programming fallback)
- Cash flow calculations (deterministic arithmetic)
Benefit: LLM generates high-level strategy, algorithms execute precise calculations. Users can verify AI recommendations by inspecting the underlying mathematical models.
Innovation: Full audit trail of AI reasoning process through structured decision logs.
Every AI recommendation is persisted with:
- Thought Process: Step-by-step reasoning chain
- Rationale: Natural language explanation for end users
- Evidence References: Citations to regulatory documents (RAG sources)
- Goal Snapshot: Complete context at decision time
- User Actions: How user responded to recommendation (accepted/modified/rejected)
Model: GoalDecisionLog captures each step in the four-stage workflow, enabling retrospective analysis of AI decision quality and user trust patterns.
Challenge: LLM APIs are third-party servicesβhow to enable personalized advice while respecting data privacy?
Layer 1: Global Sharing Control
- User-level toggle:
privacy.shareWithAI(boolean) - If disabled, AI operates with only aggregate/anonymized data
Layer 2: Granular Data Allowlist
- Fine-grained control over data types sent to AI:
financial_assets,income,debts,goals,cashflow - Example: User allows AI to see income but not specific asset holdings
Layer 3: PII Sanitization
- Automated scrubbing before LLM transmission
- Removes:
user_id,email,name,address,session_id - Preserves: Financial values, ratios, and relationships
- Four sanitization modes:
none,pii_only,normalized,strict
Academic Value: First implementation of GDPR-style consent management for LLM-based financial advisory.
Problem: Raw PDF/DOCX extracts contain noise (headers, footers, tables of contents) that degrade RAG quality.
Stage 1: Content Type Detection
- LLM-powered classification into 8 types: paragraph, table, list, figure_caption, TOC, header_footer, metadata_section, other
Stage 2: Semantic Quality Filtering
- LLM evaluates each chunk for:
content_quality(high/medium/low),priority,topic,audience,keywords - Code-level enforcement: Force-filter TOC and headers regardless of LLM judgment
Stage 3: Metadata Enrichment
- Auto-generates searchable attributes: topic taxonomy, document type, structural features
- Input: 6 documents, 293 pages, 678 raw chunks
- Output: 501 high-quality chunks (73.9% retention)
- Quality Distribution: ~78% high quality, 22% medium quality
- Processing Cost: $0.036 USD (Gemini 1.5 Flash)
- Processing Time: 30 minutes
Research Impact: Demonstrates feasibility of fully automated knowledge base curation for domain-specific RAG systems.
Challenge: Traditional financial planning uses static forms that cannot adapt to user context.
AI generates form schemas on-the-fly based on:
- Goal category (retirement/home/education/wealth/emergency)
- Current stage (definition/strategy/product/simulation)
- User's financial context (employment status, existing goals, risk tolerance)
Solution: Session-based isolation
- Each goal planning session has unique
session_id - Frontend maintains separate
goalContextstate per session - Backend stores
previousDecisionsscoped to session - Switching goals clears chatbox history and resets context
Benefits:
- Adaptive Questionnaires: First-time home buyers see KiwiSaver withdrawal questions; investors don't
- Progressive Disclosure: Only show advanced options when relevant
- Context-Aware Validation: "Lump sum cannot exceed your available liquid assets ($84,500)"
- Seamless Resumption: User can leave mid-planning and return later without losing progress
http://localhost:5001/api
All protected endpoints require JWT token in header:
Authorization: Bearer <your-jwt-token>GET /goals # List all user goals
POST /goals # Create new goal
GET /goals/:id # Get goal details
PUT /goals/:id # Update goal
DELETE /goals/:id # Delete goal
POST /goals/:id/activate # Activate goal planPOST /goal-engine/chat # Conversational AI (Ask mode)
POST /goal-engine/auto-substage # Structured planning (Auto mode)
POST /goal-engine/execute-substage # Execute substage with AI
GET /goal-engine/stream-chat # SSE streaming endpointGET /wealth/snapshot # Current wealth snapshot
GET /wealth/assets # List all assets
POST /wealth/assets # Create asset
PUT /wealth/assets/:id # Update asset
DELETE /wealth/assets/:id # Delete asset
GET /wealth/cashflow # Cash flow summary
POST /wealth/cashflow # Add cash flow itemPOST /products/build-portfolios # Build optimized portfolios
POST /products/search # Search product library
GET /products/recommendations # Get product recommendationsFor complete API documentation, see API_REFERENCE.md.
# Backend tests (with coverage)
cd backend
npm test -- --coverage
# Backend tests (watch mode)
npm test -- --watch
# Frontend unit tests
cd frontend
npm run test
# Frontend E2E tests
cd frontend
npx cypress open- Test Suites: 13 suites, 208 tests (all passing) β
Test Suites:
- β Auth Middleware (9 tests) - JWT authentication (91% coverage)
- β Privacy Middleware (33 tests) - Data privacy controls (93% coverage)
- β Goal API (8 tests) - Basic CRUD operations
- β Cash Flow API (5 tests) - Income/expense management
- β Product API (3 tests) - Financial product queries
- β User API (3 tests) - User profile management
- β Snapshot API (13 tests) - Wealth/goal history tracking
- β Wealth Helpers (43 tests) - Financial calculations
- β Constants (37 tests) - Configuration and enums
- β Memory Logger (32 tests) - Debug logging
- β Error Handling (9 tests) - Custom error classes
- β API Routes (7 tests) - Route configuration
Coverage Highlights:
- Main API routes (Goal, Cash Flow, Product, User, Snapshot, Wealth Centre): 100%
- Privacy middleware: 93.47%
- Auth middleware: 90.9%
- Models: 57%
Note: Complex business logic (AI engine, LLM integration, portfolio optimization algorithms) will be covered in future test iterations.
- Unit Tests: 5 test suites for goal engine components
- E2E Tests: 23 Cypress test files covering critical user workflows
The project includes automated GitHub Actions workflows:
- Frontend Tests: Unit tests with coverage reporting
- Backend Tests: API and middleware tests
- Code Quality: ESLint checks and large file detection
- Build Verification: Production build validation and size monitoring
- Matrix testing on Node.js 18.x and 20.x
- Automated testing on push/PR to main branches
- Large deletion detection (>1000 lines)
- Test file deletion warnings
- Prevents accidental code loss
For detailed CI/CD documentation, see .github/workflows/README.md
To add new tests:
- Follow existing patterns in
backend/tests/ - Focus on pure functions and helper utilities
- Ensure tests are stable and maintainable
- Run
npm testto verify all tests pass
We welcome contributions from the community! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes: Follow existing code style
- Test locally: Run
npm testin both frontend and backend directories - Check linting: Run
npm run lintto ensure code quality - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request: Describe your changes in detail
- Wait for CI checks: All automated tests must pass before merging
- CI pipeline will automatically run all tests
- Large deletions (>1000 lines) will trigger warnings
- Ensure test coverage for new features
- Fix any linting errors before requesting review
- Backend: Follow Node.js best practices, use ES6+ modules
- Frontend: Follow React best practices, use functional components and hooks
- Formatting: Use consistent indentation (2 spaces)
- Comments: Add JSDoc comments for functions and components
- Naming: Use camelCase for variables/functions, PascalCase for components/classes
Follow Conventional Commits:
feat: add Monte Carlo simulation dashboard
fix: resolve portfolio optimization bug
docs: update installation instructions
refactor: extract Copilot component from GoalIntakePage
test: add unit tests for privacy middleware
- β Goal-based planning (4-stage pipeline)
- β Wealth management center
- β Portfolio optimization (1,100+ products)
- β Privacy-first AI architecture
- β RAG integration (501 curated chunks)
- β Monte Carlo simulation
Testing & Quality:
- Maintain stable test suite (208 passing tests)
- Add E2E tests for critical user workflows
- Performance monitoring for AI response times
Features:
- Real-time market data integration
- Enhanced portfolio rebalancing
- Mobile-responsive design improvements
- Multi-currency support
- Tax optimization strategies
- Multi-user support (family accounts)
- Financial advisor dashboard
- Advanced reporting & analytics
- API for third-party integrations
- Machine learning for personalized recommendations
- Mobile app (React Native)
- Voice assistant integration
- Blockchain-based asset verification
- Open-source product database
- Community-contributed goal templates
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2026 FinTwin Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software...
- Financial Markets Authority (FMA). (2025). KiwiSaver Annual Report 2025.
- Reserve Bank of New Zealand (RBNZ). (2025). Monetary Policy Statement November 2025.
- Commission for Financial Capability (CFFC). (2024). New Zealand Retirement Expenditure Guidelines.
- Ministry of Housing and Urban Development (MHUD). (2025). Housing in Aotearoa 2025.
- Financial Markets Authority (FMA): KiwiSaver product data (339 funds)
- Managed Funds Association: Managed fund data (750+ funds)
- Banks: Term deposit rates (limited coverage)
- Vectara: RAG platform (501 curated document chunks)
- DeepSeek: Primary LLM API
- MongoDB: Database infrastructure
Note: Bank API integration is limited. The product database primarily focuses on investment products with extensible architecture for future data source expansion.
FinTwin was built by a collaborative team at the University of Auckland, ICT School:
| Member | Role | Responsibilities |
|---|---|---|
| Lucas | Architect | Architecture design, AI/LLM integration, goal engine implementation, API design, database schema, AWS deployment |
| Kuda | Data Lead | Financial compliance review, data cleaning & preparation |
| Ray | Backend Developer | CRUD API implementation, service layer maintenance |
| Ming | Frontend Developer | Data visualization (Recharts), component development, user research & requirements gathering |
| Ava | Frontend Developer & QA | User authentication UI, global styling, backend API testing, user testing & bug reporting |
Special thanks to:
- University of Auckland, ICT School - Research support and guidance
- DeepSeek Team - Providing accessible AI reasoning capabilities
- Vectara Team - Enabling powerful RAG infrastructure
- Financial Markets Authority (NZ) - Open data for financial products
- Open Source Community - Libraries and tools that made this possible
- Name: Lucas
- Role: Lead Architect
- Institution: University of Auckland, ICT School
- Email: Contact via GitHub
- Live Demo: http://13.210.244.120/
- Issues: GitHub Issues
- Discussions: GitHub Discussions
If you use FinTwin in your research, please cite:
@software{fintwin2026,
author = {Lucas and Kuda and Ray and Ming and Ava},
title = {FinTwin: AI-Powered Goal-Based Financial Planning},
year = {2026},
publisher = {University of Auckland},
url = {http://13.210.244.120/}
}Built with β€οΈ for better financial futures



