Wealth Portfolio RAG Agent Development
Development assistant for a full-stack Natural Language Cross-Platform Data Query RAG Agent for wealth portfolio management serving high-net-worth clients (film stars, sports personalities) with portfolios valued at 100+ crores.
Architecture Overview
**Backend Stack:**
Python FastAPI for API layerLangChain for RAG orchestrationOpenAI GPT-4 for language understandingSentence Transformers for embeddings**Frontend Stack:**
React with TypeScriptTailwind CSS for stylingChart.js for data visualization**Database Architecture:**
MongoDB: Client profiles and portfolio holdingsMySQL: Transaction recordsChromaDB: Domain knowledge vectors**Authentication:**
JWT-based token systemRole-based access control (admin, manager, analyst)Code Generation Guidelines
When generating code for this project:
1. Backend Development (FastAPI + LangChain)
Use async/await patterns for all database operationsImplement comprehensive error handling with try/except blocksStructure endpoints with proper dependency injectionValidate request/response models with PydanticUse LangChain chains for RAG query processingImplement proper database connection pooling**Example pattern:**
```python
@app.post("/api/query")
async def query_portfolio(request: QueryRequest, user: User = Depends(get_current_user)):
try:
# Validate input
# Query databases
# Process through RAG chain
# Return structured response
except Exception as e:
# Log error
# Return user-friendly error response
```
2. Frontend Development (React + TypeScript)
Use functional components with TypeScript interfacesImplement proper type safety for all props and stateUse Tailwind CSS utility classes for stylingCreate reusable component patternsHandle loading and error states explicitlyImplement responsive design patterns**Type safety requirements:**
Define interfaces for API responsesType all component propsUse TypeScript strict mode3. Database Operations
**MongoDB (Client Data):**
Collections: `clients`, `portfolio_holdings`Use async MongoDB driverImplement proper indexing strategies**MySQL (Transactions):**
Table: `transactions`Use parameterized queriesImplement connection pooling**ChromaDB (Vector Store):**
Store domain knowledge embeddingsImplement similarity searchHandle vector updates4. RAG System Implementation
Build context-aware query chainsImplement retrieval from multiple data sourcesUse prompt engineering for wealth management domainHandle multi-database query orchestrationProvide source attribution in responses5. Security Practices
Validate all user inputsImplement rate limiting on API endpointsUse environment variables for secretsSecure JWT token handlingImplement role-based authorization checksSanitize database queries6. Error Handling
Provide meaningful error messagesLog errors with sufficient contextHandle network failures gracefullyImplement retry logic for transient failuresReturn appropriate HTTP status codes7. Code Organization
Maintain separation of concernsUse service layer pattern for business logicKeep components small and focusedFollow consistent naming conventionsDocument complex logic with commentsDomain-Specific Considerations
**Wealth Management Context:**
Portfolio values in crores (1 crore = 10 million)Multi-asset class support (stocks, bonds, real estate, alternatives)Risk assessment and analyticsRegulatory compliance awarenessHigh-value client confidentiality**Natural Language Query Support:**
Handle conversational queries about portfoliosSupport questions across multiple data sourcesProvide financial insights and recommendationsGenerate visualizations from query resultsTesting Requirements
Write unit tests for business logicTest API endpoints with realistic dataValidate RAG chain outputsTest error handling pathsEnsure responsive UI across devicesPerformance Considerations
Optimize database queriesImplement caching where appropriateUse lazy loading for large datasetsMinimize API response timesOptimize vector search operationsWhen assisting with this project, prioritize code quality, security, type safety, and maintainability while maintaining the sophisticated requirements of wealth portfolio management for high-net-worth individuals.