Skip to content

ShreeKumbhar/InsightGen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

📊 InsightGen: AI-Powered Data Analysis Dashboard

FastAPI React Vite Pandas OpenAI

InsightGen is a full-stack, AI-driven data analysis platform. It empowers users to seamlessly upload CSV datasets, automatically extract deep analytical insights, and dynamically build interactive visualizations using both manual controls and intuitive Natural Language Prompts.


✨ Key Features

  • 🚀 Instant Automated Analysis: Upload a CSV and immediately get data types, missing value analysis, and statistical correlations.
  • 🤖 AI-Generated Insights: Translates complex data correlations into human-readable business insights.
  • 📈 Interactive Chart Builder: Dynamically plot your data with Bar, Line, or Pie charts using an intuitive point-and-click interface.
  • 💬 Natural Language Querying: Just type what you want to see (e.g., "Show me the total revenue by region"), and the system automatically builds the correct chart.
  • 📄 Extensible Export Options: Download your generated insights into TXT or beautifully formatted PDF reports.
  • ⚡ High Performance: Built on FastAPI and Vite for lightning-fast backend processing and frontend rendering.

🏗️ Architecture

graph LR
    A[User / Frontend React] -->|Upload CSV / Query| B(FastAPI Backend)
    B --> C{Pandas Engine}
    C -->|Data Cleaning & Stats| B
    B --> D[OpenAI API]
    D -->|Natural Language Parsing & Insights| B
    B -->|JSON Response & Recommendations| A
Loading

🛠️ Tech Stack

Frontend:

  • Core: React (Vite)
  • Visuals: Recharts (Data Visualization)
  • Styling: Standard CSS for responsive, modern UI

Backend:

  • Language: Python 3
  • Framework: FastAPI (REST API)
  • Data Engine: Pandas
  • Server: Uvicorn (ASGI)

🚦 Getting Started

Follow these step-by-step instructions to get a local copy of InsightGen up and running.

Prerequisites

  • Python 3.8+ installed on your machine.
  • Node.js 16+ and npm installed.
  • An active OpenAI API Key.

1. Backend Setup (FastAPI)

Navigate to the backend directory:

cd backend

Create and activate a Python virtual environment:

# macOS/Linux
python3 -m venv .venv
source .venv/bin/activate

# Windows
python -m venv .venv
.venv\Scripts\activate

Install the required dependencies:

pip install -r requirements.txt

Set up your Environment Variables:

cp .env.example .env

Open the .env file and insert your actual API key:

OPENAI_API_KEY=your_real_openai_api_key_here

Start the Backend Server:

uvicorn app.main:app --reload --port 8000

The backend API is now running at http://127.0.0.1:8000.
Check out the interactive API Docs at http://127.0.0.1:8000/docs.


2. Frontend Setup (React)

Open a new terminal window and navigate to the frontend directory:

cd frontend

Install the Node.js packages:

npm install

Start the Development Server:

npm run dev

The application will be running at http://127.0.0.1:5173. Open this URL in your browser to start analyzing data!


💡 Usage Guide & Natural Language Examples

  1. Upload Data: Click the Upload CSV button and select a file. (You can test using the generated files in the sample-data/ folder).
  2. Review Insights: The panel will automatically populate with human-readable correlations and data summary.
  3. Chart Builder & Natural Language: Use the manual dropdowns to plot data, OR try typing these exact prompts in the chat box:
    • "Show me the total revenue by region"
    • "What is the average profit for each category?"
    • "Plot the trend of units sold over date"
    • "Display total revenue by product as a pie chart"
  4. Export: Click the "Export PDF" or "Export TXT" buttons to save your insights offline.

🔌 API Endpoints Reference

Method Endpoint Description
POST /analyze Upload a CSV file via form-data to extract columns, rows, correlational insights, and chart recommendations.
POST /query-chart Send a natural language string and available columns to map it to the ideal chart configuration.
POST /query Processes a prompt and returns the ideal chart configuration logic {"x": "col", "y": "col", "chart": "type"}.
POST /export-insights/txt Send an array of insight strings to generate and download a plain text report.
POST /export-insights/pdf Send an array of insight strings to generate and download a formatted PDF report.

📂 Project Structure

insightgen/
├── backend/                  # FastAPI Backend Application
│   ├── app/
│   │   ├── __init__.py
│   │   ├── analyzer.py       # Core Pandas dataframe analysis logic
│   │   ├── main.py           # FastAPI routes & App definition
│   │   └── schemas.py        # Pydantic models for request/response validation
│   ├── requirements.txt      # Python dependencies
│   └── .env.example          # Environment variables template
├── frontend/                 # React/Vite Frontend Application
│   ├── index.html
│   ├── package.json
│   ├── vite.config.js
│   └── src/
│       ├── App.jsx           # Main Application Component
│       ├── components/       # Reusable UI Components
│       ├── services/         # API connection logic
│       └── styles.css        # Global Styles
└── sample-data/              # Sample CSV files

🚀 Deployment Recommendations

  • Frontend: Update the API base URL in frontend/src/services/api.js to point to your live backend domain, then host via Vercel, Netlify, or AWS S3.
  • Backend: Wrap the FastAPI application in a Dockerfile and deploy via Render, Railway, or AWS ECS/EC2. Remember to securely inject the .env variables to your cloud provider.
  • Handling Large Data: For extremely large files (200MB+), consider converting the in-memory Pandas dataframe loading into distributed chunks or background task queues (e.g., Celery/Redis).

About

AI-powered data analysis dashboard that transforms CSV datasets into actionable insights and interactive visualizations using natural language queries.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors