DataInsightBot is an AI-powered business analytics project that helps users understand company data by simply asking questions in natural language.
Instead of manually writing SQL queries, users can ask questions like "Which department has the highest average salary?" and the application uses Gemini AI to generate the required SQL query, fetch the data from the database, and explain the result in simple terms.
The project also includes a Machine Learning module that uses Random Forest to predict future sales revenue.
- Ask questions about company data using natural language
- Automatically generate SQL queries using Gemini AI
- Execute queries on a SQLite database
- Get AI-generated explanations of query results
- View query results in a clean table
- Predict future sales revenue using Machine Learning
- Modern web interface built with HTML, CSS and JavaScript
- SQL validation for safer database queries
- HTML
- CSS
- JavaScript
- Python
- FastAPI
- Uvicorn
- Google Gemini API
- google-genai
- SQLite
- Pandas
- Scikit-learn
- Random Forest Regression
DataInsightBot/
│
├── backend/
│ ├── database/
│ ├── chat_service.py
│ ├── database_query.py
│ ├── database_setup.py
│ ├── gemini_service.py
│ ├── insert_data.py
│ ├── main.py
│ ├── ml_prediction.py
│ ├── schema.py
│ ├── sql_validator.py
│ └── test_database.py
│
├── frontend/
│ ├── index.html
│ ├── script.js
│ └── style.css
│
├── .gitignore
└── README.md
The AI Analyst follows this simple flow:
User Question
↓
Gemini AI
↓
SQL Query Generation
↓
SQL Validation
↓
SQLite Database
↓
Query Result
↓
AI Explanation
↓
User
For example, a user can ask:
Which department has the highest average salary?
DataInsightBot converts the question into an SQL query, runs it on the database, and then explains the result in simple terms.
The ML module works separately by using historical sales data with a Random Forest model to generate future revenue predictions.
git clone https://github.com/soumya-prasad-1/DataInsightBot.git
cd DataInsightBot
pip install fastapi uvicorn python-dotenv pandas scikit-learn google-genai
Create a file named .env inside the backend folder.
backend/.env
Add your API key:
GEMINI_API_KEY=your_api_key_here
Keep this file private. Do not upload it to GitHub.
Run this command from the project folder:
uvicorn backend.main:app --reload
The backend will run at:
http://127.0.0.1:8000
Open frontend/index.html using VS Code Live Server.
You can ask questions such as:
- Which department has the highest average salary?
- Which department has the most employees?
- What are the total sales?
- Show me the sales data.
- Which department has the lowest average salary?
The project includes a Random Forest Regression model for sales prediction.
It uses historical sales data to learn patterns and predict future revenue. The predictions are displayed directly in the web interface.
The project includes SQL validation before executing generated queries.
The Gemini API key is stored in an environment file and is excluded from GitHub using .gitignore.
While building DataInsightBot, I worked with:
- Natural language to SQL generation
- Gemini API integration
- FastAPI backend development
- SQLite database operations
- SQL validation
- Machine Learning with Random Forest
- HTML, CSS and JavaScript
- Connecting a frontend with a Python backend
- Handling API responses and errors
Soumya Prasad
B.Tech CSE (Data Science)