Skip to content

Webnovare/SensibleAI-Finance-Assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SensibleAI Finance Assistant

Natural language financial analysis over MySQL, powered by Streamlit, LangChain, and Groq.

GitHub stars Python Streamlit MySQL Groq


Why

Finance teams should be able to ask direct business questions without hand-writing SQL every time.

SensibleAI Finance Assistant is a small end-to-end prototype inspired by OneStream SensibleAI, developed by Adam Hanafi and Alex Kiwi. It connects a Streamlit chat interface to a Groq-powered LangChain SQL agent, then queries MySQL financial tables for totals, category analysis, budget variance, and supporting visualizations.

The goal is to show the full path from data model to natural language querying to charts in one easy-to-run demo.

Features

Feature What it does
Natural language chat Ask questions like "Which category overspent the most?"
SQL agent Uses LangChain's SQL database toolkit with a Groq chat model.
MySQL schema Stores actual transactions and monthly category budgets.
Visual analytics Shows category breakdowns, monthly spend trends, and budget-vs-actual tables.
Seed data Includes example Q1 2025 financial records for a fast local demo.

Architecture

graph TD A[Streamlit Frontend] --> B[Groq LLM Agent] B --> C[LangChain SQLDatabase Tool] C --> D[MySQL Database] D --> E[transactions table] D --> F[budgets table] A --> G[Streamlit Charts] B --> H[Finance-Focused System Prompt]


## Setup

### 1. Clone the repo

```bash
git clone https://github.com/Webnovare/SensibleAI-Finance-Assistant.git
cd SensibleAI-Finance-Assistant

2. Create a virtual environment

Windows PowerShell:

python -m venv .venv
.\.venv\Scripts\Activate.ps1

macOS or Linux:

python3 -m venv .venv
source .venv/bin/activate

3. Install dependencies

pip install streamlit pandas sqlalchemy pymysql python-dotenv langchain-community langchain-groq langchain-core

4. Create environment variables

Create a .env file in the project root:

GROQ_API_KEY=your_groq_api_key_here
DB_PASSWORD=your_mysql_password_here

The app currently connects to MySQL using:

user: root
host: localhost
database: sensibleai_finance

For production or shared demos, use a dedicated read-only database user instead of root.

5. Create and seed the MySQL database

Make sure MySQL is running, then import the schema and demo data:

mysql -u root -p < mysql/sensibleai_finance.sql
mysql -u root -p sensibleai_finance < mysql/dumby-data.sql

If your MySQL client does not like the final EXIT; line in the seed file, run the script interactively instead:

mysql -u root -p
source mysql/sensibleai_finance.sql;
source mysql/dumby-data.sql;

6. Run the app

streamlit run app.py

Then open the local Streamlit URL shown in your terminal, usually:

http://localhost:8501

Try It

Ask questions such as:

  • What is the total Development Costs?
  • Calculate the variance for Marketing Costs in 2025-01.
  • Which category overspent the most?
  • Give me a high-level summary of Q1 2025 expenses.
  • Show Marketing Costs by month.

Data Model

Table Purpose
transactions Actual spending by date, month, category, department, and amount.
budgets Monthly budget targets by category and department.

The prompt expects these exact category names:

  • Development Costs
  • Operational Costs
  • Marketing Costs
  • Travelling Cost
  • Training Cost
  • Maintenance Cost

Star History

Star history chart

About

Mini OneStream SensibleAI-inspired financial analysis platform with natural language to SQL and visualizations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages