An intelligent, responsive financial services chatbot that provides accurate answers with reliable source citations. Features advanced URL generation for Investopedia resources and comprehensive financial knowledge coverage.
Example queries:
- "What is cryptocurrency?"
- "Explain credit default swap in simple terms"
- "How does compound interest work?"
- "What are the risks of trading stocks?"
The bot provides clear, concise explanations and always includes valid Investopedia source links for further reading.
- Frontend (Vercel): finsathi-chatbot-madhavp.vercel.app
- Backend (Render): madhavp-financial-service-backend.onrender.com
- GitHub Repo: Madhav-P-2005/LLM_Powered-Financial-Service-ChatBot
- π¨οΈ Conversational chat UI with history
- β³ Loading indicator while the model generates
- π Answers in simple financial language
- π Smart URL Generation: Always provides valid Investopedia links using:
- Canonical URL mappings for 200+ financial terms
- Heuristic URL generation with validation
- Alphabetical directory fallback system
- π Dark/Light theme (auto-applies based on saved or system preference)
- π§Ή "Clear chat" and "Home" buttons on chat page
- π± Fully responsive UI (mobile-first)
- π OpenAI key loaded securely from backend
.env(never exposed to browser) - π§© Custom favicon and branding (
public/finsathi.svg) replacing default Vite icon
- Curated Knowledge First: Common topics like "cryptocurrency", "credit default swap", "bank", "phishing" return high-quality answers with verified Investopedia citations from a curated knowledge base.
- OpenAI Fallback: For other queries, the backend calls OpenAI with optimized prompts for concise, educational responses.
- Advanced URL Resolution: Multi-tier system ensures valid Investopedia links:
- Exact canonical mapping lookup
- Partial matching with priority scoring
- Heuristic URL generation with validation
- Alphabetical directory fallback
- No Broken Links: System validates URLs before returning them to users.
LLM-Powered Financial Services Chatbot/
βββ financial-service-chatbot-backend/
β βββ app.py # Flask API (curated KB + OpenAI fallback)
β βββ config/.env # OPENAI_API_KEY and optional OPENAI_MODEL
β βββ requirements.txt # Backend dependencies
β βββ MyEnvironment/ # Python venv (ignored)
βββ financial-service-chatbot-frontend/
β βββ src/
β β βββ components/
β β β βββ Navbar.jsx # Header (auto theme application)
β β β βββ Footer.jsx # Themed footer with socials
β β βββ pages/
β β β βββ HomePage.jsx # Landing
β β β βββ ChatPage.jsx # Chat UI with Clear/Home buttons
β β βββ App.jsx, main.jsx, index.css
β βββ tailwind.config.js # darkMode: 'class'
β βββ package.json
βββ Readme.md # This file
βββ .gitignore # Includes config/.env, __pycache__/, etc.
- Node.js (LTS) and npm
- Python 3.11+ (venv recommended)
From: financial-service-chatbot-backend/
- Create and activate venv (Windows PowerShell):
python -m venv MyEnvironment
./MyEnvironment/Scripts/Activate.ps1- Install dependencies:
python -m pip install -r requirements.txt- Configure environment: Create
config/.envwith:
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx
OPENAI_MODEL=gpt-4o-mini- Run Flask:
$Env:FLASK_APP = "app.py"
$Env:FLASK_ENV = "development"
flask run --host 127.0.0.1 --port 5000Backend runs at: http://127.0.0.1:5000
From: financial-service-chatbot-frontend/
- Install:
npm install- Run dev:
npm run devFrontend runs at: http://localhost:5173
Open the app, go to "Chat" and ask:
- What is a credit default swap?
- What is cryptocurrency?
- What is a bank?
You should get clear explanations with valid Investopedia source URLs.
- React 18, Vite 5
- Tailwind CSS 3
- Axios, React Router, React Icons
- Python Flask 3, Flask-CORS
- OpenAI Python SDK
Backend requirements.txt (core):
- Flask, flask-cors
- openai
- python-dotenv
- requests
Backend: financial-service-chatbot-backend/config/.env
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx
OPENAI_MODEL=gpt-4o-miniDo not commit .env. It is already gitignored.
Endpoint:
- POST
/chat - Request JSON:
{ "message": "What is a credit default swap?" }- Response JSON:
{ "response": "- β’ Short, simple bullet points...\n- ...\nSource: https://..." }CORS is configured for local development and production deployment.
- Push repo to GitHub.
- Create a new Web Service.
- Environment variables:
OPENAI_API_KEYOPENAI_MODEL(optional; defaultgpt-4o-mini)
- Start command:
gunicorn app:app- After deploy, note your backend URL (e.g.,
https://your-backend.onrender.com).
- Build command:
npm run build- Publish directory:
dist- Ensure your frontend Axios points to your backend URL for production (if needed, add an env or simple conditional).
PRs and suggestions welcome. Open an issue for bugs or improvements.
This project is licensed under the MIT License. See the LICENSE file for details.
Built with π by Madhav P