Skip to content

About

AI-powered Q&A over investment fund factsheets (PRIIP/KID documents). Full-stack RAG pipeline with semantic search, natural language answers with source citations, and near-zero hosting costs on Azure free tiers.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

421 Commits

Folders and files

Repository files navigation

Fund Insights

Note

Microsoft is sunsetting Semantic Kernel in favor of the new Microsoft Agent Framework. Development continues at KanelBulleKapital using the Agent Framework.

A tool that analyzes investment fund factsheets (PRIIP/KID documents), generates relevant questions, and provides answers to common investor queries about fund basics, risk profiles, costs, performance scenarios, and investment terms.

Feature Description
Semantic Search Vector embeddings for accurate document retrieval (RAG over PDF factsheets)
Function Calling Structured fund data queries (performance, ownership, categories) via Semantic Kernel plugins
Hybrid Answers LLM autonomously combines RAG + function calling for comprehensive responses
Natural Language Q&A Ask questions, get answers with source citations
Low Cost Free-tier cloud services (OpenAI, Azure SQL, Cosmos DB)
Local Processing Generate embeddings with LM Studio or Ollama
Flexible Storage In-memory (default) or Azure Cosmos DB vector search

🎬 Demo

Try it live: Fund Insights

⚠️ Demo Notice: This site runs on free tier resources and may experience downtime when limits are reached. Currently processing 15 of 68 SEB funds.

❄️ Cold Start: The backend runs on Azure App Service free tier β€” expect ~30s cold start after 1 hour of inactivity.

Main demo

Supported Languages: All PDF files are in Swedish, but questions can be asked in any language. The AI will respond in the language of your question.

Example PDF: SEB Emerging Marketsfond C USD - Lux.pdf


πŸ€– For AI Agents

IMPORTANT: Before implementing any changes, consult Status.md

  • What features are already implemented
  • Current implementation status of each component
  • Known issues and limitations

Instructions for AI assistants:

  1. Before starting work: Check Status.md to verify feature status
  2. During implementation: Update status from ❌ to ⏳ (in progress)
  3. After completion: Update status to βœ… and document any new features or changes
  4. Always maintain: Keep Status.md synchronized with actual implementation state

πŸ“‹ Overview

A low-cost hobby project that enables semantic Q&A over PDF documents. Upload PDFs, generate embeddings locally, and ask questions in natural language.

Key Features:

  • Semantic search using vector embeddings (RAG over PDF documents)
  • Function calling over structured fund data (performance, ownership, categories)
  • Hybrid answers β€” LLM autonomously combines both approaches
  • Natural language Q&A with source citations
  • Local embedding generation (LM Studio/Ollama)
  • Switchable vector storage: in-memory (default) or Azure Cosmos DB
  • Fund similarity analysis: clusters funds by what they hold and finds the most similar funds (FundClustering)

πŸ—οΈ Architecture

flowchart LR
    subgraph PdfTextExtractor ["PdfTextExtractor (extraction)"]
        PDF[PDF Files] --> PTE[PdfTextExtractor]
        PTE -->|native| PDFPIG[PdfPig]
        PTE -.->|OCR| LMS[LM Studio / OpenAI]
        PTE --> TXT[Text Files]
    end

    subgraph Preprocessor ["Preprocessor (embedding)"]
        TXT --> PRE[Preprocessor]
        PRE --> EMB[embeddings.json]
        PRE -.->|local| LOCAL[Ollama / LM Studio]
        PRE -.->|cloud| OAI_EMB[OpenAI Embeddings]
    end

    subgraph YieldRaccoon ["YieldRaccoon (data collection)"]
        YR[YieldRaccoon] -->|WebView2| FP[Fund Provider]
        YR --> DB[(SQLite\nFundProfile, FundHistoryRecord,\nCountry, Sector,\nFundCountryAllocation, FundSectorAllocation)]
        YR -.->|DualWrite| API
        YR --> CSV[Weekly CSV export\nallocations + metadata]
    end

    subgraph FundClustering ["FundClustering (similarity analysis)"]
        CSV --> FC[Python pipeline]
        FC --> OUT[output/*.json\nclusters, neighbours, map]
        OUT --> VIEW[Cluster map viewer]
    end

    subgraph Runtime ["Backend + Frontend (retrieval & generation)"]
        FE[Frontend] --> API[Backend API]
        EMB -->|default| API
        COSMOS[(Cosmos DB)] -.->|optional| API
        AZSQL[(Azure SQL)] -.->|optional| API
        API -->|RAG + Function Calling| OAI[OpenAI API]
        API -.->|LLM alt| GROQ[Groq API]
    end
Loading

Components

Component Tech Stack Description
PdfTextExtractor .NET 10, PdfPig, LM Studio, OpenAI PDF text extraction library with native + OCR support
Preprocessor .NET 10, Semantic Kernel Read pre-extracted text files, generate embeddings (file or Cosmos DB)
Backend ASP.NET Core 10, Semantic Kernel 1.81, Azure SQL RAG over PDF documents + function calling over structured fund data (FundDataPlugin)
Frontend Next.js 16, React 19, TypeScript, shadcn/ui Chat interface with dark/light theme
YieldRaccoon .NET 10, WPF, EF Core, Rx.NET, WebView2 Fund data crawler with cloud sync, data/statistics export, and privacy filter
FundClustering Python 3.15, pandas, scikit-learn, UMAP Groups equity funds by country + sector allocations, finds similar funds, and draws a cluster map

πŸš€ Quick Start

Prerequisites

Requirement Version Notes
.NET SDK 10.0+ Download
Node.js 18+ Download
LM Studio or Ollama Latest For local embedding generation
OpenAI API Key - Get key (required)
Groq API Key - Get free key (optional alternative)

Configuration: See Configuration & Secrets Guide for complete setup instructions.

1. Extract Text from PDFs

cd PdfTextExtractor
dotnet run --project PdfTextExtractor.Wpf
# Use the WPF GUI to extract text files from your PDFs

See PdfTextExtractor README for CLI and API usage.

2. Generate Embeddings

cd Preprocessor/Preprocessor
# Ensure text files from step 1 are in ./pdfs folder alongside the PDFs
dotnet run

3. Start Backend

cd backend/Backend.API
dotnet user-secrets set "BackendOptions:OpenAIApiKey" "your-key"
dotnet user-secrets set "BackendOptions:LlmProvider" "OpenAI"
cp ../../Preprocessor/Preprocessor/bin/Debug/net10.0/output.json Data/embeddings.json
dotnet run

Optional: Add Azure SQL for structured fund queries (AzureSqlConnectionString), or use Groq as a free LLM alternative. See Backend README.

4. Start Frontend

cd frontend
npm install && cp .env.example .env.local
npm run dev

Open http://localhost:3000


πŸ“ Project Structure

.
β”œβ”€β”€ Preprocessor/           # Embedding generation from pre-extracted text
β”œβ”€β”€ backend/                # ASP.NET Core API
β”‚   β”œβ”€β”€ Backend.API/        # Main API project
β”‚   └── Backend.Tests/      # Unit tests
β”œβ”€β”€ frontend/               # Next.js web app
β”œβ”€β”€ PdfTextExtractor/       # PDF extraction library (native + OCR)
β”‚   β”œβ”€β”€ PdfTextExtractor.Core/       # Core library (DDD, extractors, events)
β”‚   β”œβ”€β”€ PdfTextExtractor.Wpf/        # WPF desktop application
β”‚   └── PdfTextExtractor.Core.Tests/ # NUnit tests
β”œβ”€β”€ YieldRaccoon/           # Fund price crawler (WPF desktop)
β”‚   β”œβ”€β”€ YieldRaccoon.Domain/         # Business logic, entities, value objects
β”‚   β”œβ”€β”€ YieldRaccoon.Application/    # Use-case orchestration, interfaces
β”‚   β”œβ”€β”€ YieldRaccoon.Infrastructure/ # EF Core, event stores, services
β”‚   └── YieldRaccoon.Wpf/           # WPF UI with WebView2
β”œβ”€β”€ FundClustering/         # Fund similarity analysis (Python)
β”‚   β”œβ”€β”€ fund_clustering/             # Pipeline: methods, clustering, naming, neighbours
β”‚   β”œβ”€β”€ tests/                       # pytest tests
β”‚   β”œβ”€β”€ notebooks/                   # explore.ipynb, method walkthrough and comparisons
β”‚   β”œβ”€β”€ viewer/                      # Cluster map viewer (single HTML file)
β”‚   β”œβ”€β”€ data/                        # Weekly CSV export from YieldRaccoon (example week)
β”‚   β”œβ”€β”€ output/                      # Generated JSON for the viewer (example week)
β”‚   └── main.py                      # Pipeline entry point
β”œβ”€β”€ docs/                   # Guides
β”‚   β”œβ”€β”€ AZURE-DEPLOYMENT.md
β”‚   └── SECRETS-MANAGEMENT.md
β”œβ”€β”€ Status.md               # Implementation progress tracker
└── azure-setup.sh          # Azure deployment script

☁️ Deployment

Deploy to Azure with near-zero cost (~$0.03/month):

Resource Tier Cost
Azure App Service F1 Free $0
Azure Static Web Apps Free $0
Application Insights Free (5GB) $0
Azure Key Vault Standard ~$0.03
Azure Cosmos DB Free tier (1000 RU/s) $0
Azure SQL Basic (optional) ~$5/month
OpenAI Embeddings + LLM Pay-per-use ~$0.003
Groq LLM Free tier (optional) $0

Quick Deploy

# 1. Create Azure resources (backend + frontend)
./azure-setup.sh

# 2. Add secrets to GitHub (from script output)
#    - AZURE_WEBAPP_PUBLISH_PROFILE
#    - AZURE_STATIC_WEB_APPS_API_TOKEN

# 3. Add variable to GitHub
#    - NEXT_PUBLIC_API_URL

# 4. Push to main - triggers automatic deployment
git push origin main

GitHub Workflows

Workflow Purpose
deploy-backend.yml Deploy backend to Azure App Service
deploy-frontend.yml Deploy frontend to Azure Static Web Apps
pr-checks.yml Run tests and checks on pull requests

See Azure Deployment Guide for complete documentation.


πŸ“š Documentation

Document Description
Configuration & Secrets Environment variables, API keys, settings
Azure Deployment Production deployment guide
Backend API API endpoints and configuration
Frontend Development and testing
Preprocessor Embedding generation and providers
PdfTextExtractor PDF extraction library (native + OCR)
YieldRaccoon Fund price crawler desktop app
FundClustering Fund clustering pipeline, output format and viewer
Project Status Implementation progress

πŸ› οΈ Tech Stack

Layer Technologies
Preprocessor .NET 10, Semantic Kernel, Ollama/LM Studio/OpenAI
Backend ASP.NET Core 10, Semantic Kernel 1.81, OpenAI, Azure SQL, Cosmos DB
Frontend Next.js 16, TypeScript, Tailwind CSS, shadcn/ui
PdfTextExtractor .NET 10, PdfPig, LM Studio, OpenAI, Rx.NET, WPF
YieldRaccoon .NET 10, WPF, EF Core, Rx.NET, WebView2, DevExpress MVVM, Autofac
FundClustering Python 3.15, pandas, NumPy, scikit-learn (HDBSCAN), umap-learn, Shapely, pytest, Jupyter
Infrastructure Azure App Service, Static Web Apps, Key Vault, Application Insights, Cosmos DB

πŸ“„ License

This is a hobby project for learning Semantic Kernel and AI integration.

About

AI-powered Q&A over investment fund factsheets (PRIIP/KID documents). Full-stack RAG pipeline with semantic search, natural language answers with source citations, and near-zero hosting costs on Azure free tiers.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages