How lucasnscr/ai-financial-analyst works
Project type and purpose
• This is a Spring Boot–based backend microservice (no UI) that implements an AI Personal Financial Analyst. It ingests real-time stock and crypto data via an external API, persists raw data in MongoDB, converts it into embeddings using an LLM, stores embeddings in PostgreSQL with PGVector, and exposes two REST endpoints: one to load/update data and one to chat/query the model.
Top-level architectural layers (from file tree & README)
• Presentation/API layer
– Controllers: LoadDataController, ChatController
– Secured by Keycloak JWT (SecurityConfig, JwtConverter)
• Service/Business logic layer
– DataLoadingService (orchestrates fetch → convert → store)
– ChatService (orchestrates query → RAG retrieval → LLM invoke → formatting)
• Adapter/Integration layer
– AlphaClient* classes (classification, economy, fundamentals, market, newsAndSentimentals, technical) using WebClient
– Converters (ClassificationConverter, EconomyConverter, etc.) transform raw API DTO → domain model
– Formatters prepare text/metadata for LLM
– AIFinancialRepository orchestrates embedding generation + vector store retrieval
• Persistence layer
– MongoDB (spring-boot-starter-data-mongodb, repositories per domain model)
– PostgreSQL with PGVector (spring-ai-pgvector-store)
• AI/ML layer
– LLM models (OpenAI GPT-4o, DeepSeek R1 via spring-ai-openai & spring-ai-ollama)
– LLMContent component gathers formatted prompts & embeddings
• Infrastructure/DevOps
– Dockerfile + docker-compose.yml (local MongoDB, PGVector, Mongo-Express)
– GitHub Actions (maven.yml)
– Terraform scripts (AWS VPC, RDS, ElasticCache, Lambda, Cognito, MongoDB Atlas, etc.)