Skip to content

An AI-powered Financial Learning Assistant that helps users learn finance concepts interactively using FastAPI, LangChain/LangGraph, and Streamlit. It supports real-time chat streaming, note saving/exporting, and contextual learning with conversation memory.

Notifications You must be signed in to change notification settings

ceodaniyal/finlearn-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💸 Financial Learning Assistant

An AI-powered conversational assistant that helps users learn finance concepts interactively.
It is built with:

  • FastAPI → Backend for handling chat streaming and tools
  • LangGraph / LangChain → Orchestrating conversations and tool calls
  • Streamlit → Frontend chat interface with conversation history
  • (Optional) MongoDB → Storing conversation history and progress notes

🌐 Business Context

FinCorp's retail clients often find complex financial concepts confusing.
This assistant aims to simplify investment concepts for beginners by providing structured explanations, examples, actionable steps, and related topics, enabling users to learn, track progress, and apply knowledge effectively.


⚡ Features

  • Real-time streaming chat responses using Server-Sent Events (SSE)
  • Support for conversation memory (checkpoint-based threads)
  • Integrated tools:
    • save_progress_tool → save personal finance learning notes
    • export_notes_tool → export saved notes as JSON
  • Frontend built in Streamlit with:
    • Chat UI (like ChatGPT)
    • Sidebar with conversation history
    • “Start New Conversation” button

🏗️ Architecture

The system is divided into two main parts:

  1. Backend (FastAPI)

    • /chat_stream/{message} endpoint streams AI responses
    • Tools for saving/exporting notes
    • Conversation state handled via LangGraph checkpoints
  2. Frontend (Streamlit)

    • User chat interface
    • Displays conversation history
    • Interacts with backend via SSE

🔹 Architecture Diagram

Architecture Diagram


🚀 Getting Started

1️⃣ Clone the repository

git clone https://github.com/your-username/finlearn-bot.git
cd finlearn-bot

2️⃣ Backend Setup

cd backend
python -m venv .venv
source .venv/bin/activate   # On Windows: .venv\Scripts\activate
pip install -r requirements.txt

Run the backend:

uvicorn app.main:app --reload

API available at:

http://127.0.0.1:8000

Interactive docs:

http://127.0.0.1:8000/docs

Chat Stream API Image 1 Chat Stream API Image 2


3️⃣ Frontend Setup

cd frontend/streamlit
pip install -r requirements.txt
streamlit run app.py

App runs at:

http://localhost:8501

Streamlit chat UI


🔌 API Documentation

Chat Streaming Endpoint

GET /chat_stream/{message}

Streams responses from the AI assistant.

Query Parameters:

  • message → User input (string)
  • checkpoint_id → Continue an existing conversation

Response (SSE Events):

data: {"type": "checkpoint", "checkpoint_id": "abc123"}

data: {"type": "content", "content": "Hello"}
data: {"type": "content", "content": " world!"}

data: {"type": "end"}

🛠️ Tools

save_progress_tool

  • Saves learning notes under a topic.
  • Example Query: User: "Save notes under Investing: Dollar-cost averaging is a strategy to reduce risk." Bot: "✅ Your notes for Investing have been saved."

export_notes_tool

  • Exports all saved notes in JSON format.
  • Example Query: User: "Export my notes." Bot: "📤 Here are your saved notes: { ... }"

Save Progress Tool Export Notes Tool


💬 Example Queries (with structured learning framework)

  1. Learn finance concepts User: "What is SIP?" Bot:

    Concept: SIP (Systematic Investment Plan) is a method of investing a fixed amount regularly in mutual funds.
    Example: Investing ₹5000 every month in a fund.
    Action Steps: Choose a mutual fund, set up auto-debit, monitor monthly.
    Related Topics: Mutual Funds, Compounding, Investment Strategy
    
  2. Save notes User: "Save notes under Budgeting: Always track your expenses." Bot: "✅ Your notes for Budgeting have been saved."

  3. Export notes User: "Can you export my notes?" Bot: "📤 Here are your saved notes: { ... }"

  4. Contextual learning User: "Explain dollar-cost averaging again." Bot continues the explanation considering previous context.

Conversation


📊 Monitoring with LangSmith

This project integrates with LangSmith to monitor:

  • Tool usage
  • LLM calls
  • Streaming events

LangSmith trace


🚀 Future Improvements

  • Persisting conversations in MongoDB for real chat history

  • Adding authentication per user

  • Personalized learning:

    • Recommend next concepts based on saved notes or progress
    • Adaptive explanations based on user’s familiarity
    • Topic tagging for easier retrieval
  • More advanced financial analysis tools

  • Richer UI with graphs/charts in Streamlit


👤 Author

Daniyal Khan

About

An AI-powered Financial Learning Assistant that helps users learn finance concepts interactively using FastAPI, LangChain/LangGraph, and Streamlit. It supports real-time chat streaming, note saving/exporting, and contextual learning with conversation memory.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages