Overview
The Investment module provides AI-powered financial guidance, helping users make informed investment decisions based on their financial situation, risk tolerance, and goals. It includes risk profiling, personalized recommendations, market data integration, and an interactive chat assistant.The Investment AI uses your transaction history to calculate financial metrics like savings capacity, income trends, and spending patterns to provide personalized advice.
Investment Profile Structure
Each account can have an investment profile that stores user preferences:backend/services/ai/prompts/types.ts
Risk Profile Questionnaire
Users complete a questionnaire to determine their investment risk profile:Profile Assessment
backend/controllers/investment/investment-controller.ts
API Endpoint
- Conservative Profile
- Balanced Profile
- Dynamic Profile
- Low risk tolerance
- Prioritizes capital preservation
- Shorter investment horizon (less than 3 years)
- Recommended: Bonds, savings accounts, conservative funds
AI-Powered Recommendations
Generate personalized investment recommendations based on user profile:backend/controllers/investment/investment-controller.ts
Investment AI Service
The AI service combines prompts with market data:backend/services/ai/investment-ai.ts
Investment Chat Assistant
An interactive AI assistant for investment questions:Creating Chat Sessions
backend/controllers/investment/investment-controller.ts
Sending Chat Messages
backend/controllers/investment/investment-controller.ts
Chat with Context
backend/services/ai/investment-ai.ts
Chat sessions automatically expire after 30 minutes of inactivity. A new session is created when the user resumes chatting.
Market Data Integration
The system integrates real-time market data for context-aware recommendations:backend/controllers/investment/investment-controller.ts
Education: Explaining Concepts
Users can ask for explanations of investment concepts:backend/controllers/investment/investment-controller.ts
API Routes
All investment routes require authentication and some use AI rate limiting:backend/routes/investment/investment-routes.ts
Security Features
Input Security Checks
All user inputs to AI endpoints are sanitized and checked for malicious content before processing.
Output Security Checks
AI responses are validated to ensure they don’t contain harmful or inappropriate content.
Best Practices
Complete Profile First
Users should complete the risk profile questionnaire before requesting recommendations.
Update Emergency Fund
Keep emergency fund information current for accurate investment percentage calculations.
Use Chat for Clarification
The chat assistant can explain recommendations and answer follow-up questions.
Monitor AI Availability
Check
ai.isAvailable() before making AI calls and handle unavailability gracefully.