DataSense is an intelligent, multi-agent web application that transforms raw data files (CSV, JSON, XLSX, PDF) into interactive business dashboards and insights in minutes. It leverages the Gemini API to analyze uploaded data, intelligently suggest visualizations, and configure complex chart mappings automatically. Users can also interact with their data using natural language through an integrated chat interface.
- Intelligent File Parsing: Supports various formats including structured tabular data (CSV, XLSX, JSON) and unstructured text (PDF).
- Automated Dashboard Generation: AI analyzes the data schema and automatically generates relevant charts (Bar, Line, Pie, Scatter, etc.) with correct column mappings.
- Natural Language Interaction: Chat with your data to ask questions or request specific visualization types.
- Dynamic UI: Charts and components update in real-time as you interact with the AI assistant.
- Knowledge Graph Extraction: For unstructured or relational data, AI builds a visual Knowledge Graph representing key entities and their relationships.
- Modern UI: Clean, responsive, light-themed glassmorphism interface built with Tailwind CSS.
DataSense uses a separated frontend/backend architecture with a dedicated AI processing layer.
graph TD
%% Frontend Components
subgraph Frontend [React Application - Vite, Tailwind, Recharts]
UI[User Interface]
Uploader[File Upload Component]
Dashboard[Dynamic Dashboard Component]
ChatUI[Chat Interface Component]
UI --> Uploader
UI --> Dashboard
UI --> ChatUI
end
%% Backend Components
subgraph Backend [Python FastAPI Server]
API[FastAPI Endpoints]
Parser[Data Parser Module]
AIAgent[AI Agent Pipeline]
API --> Parser
API --> AIAgent
end
%% External
External[Google Gemini API]
%% Data Flow
Uploader -- "Upload File (CSV, PDF, etc.)" --> API
Parser -- "Extract Schema & Samples" --> AIAgent
AIAgent -- "Analyze & Configure" --> External
External -- "JSON Insights & Chart Configs" --> AIAgent
API -- "Return Tabular Data & Configs" --> Dashboard
ChatUI -- "User Query" --> AIAgent
AIAgent -- "Natural Language & Chart Tags" --> ChatUI
ChatUI -- "Trigger New Chart `<CHART: Type>`" --> Dashboard
- Upload Phase: The user uploads a file via the React frontend.
- Parsing Phase: The FastAPI backend parses the file. If tabular, it extracts maximum 300 rows and generates detailed column metadata (types, distinct values, min/max). If PDF, it extracts text.
- AI Pipeline Stage 1: The data schema is sent to Gemini to generate an executive summary and suggest 3-4 optimal chart types.
- AI Pipeline Stage 2: Using the suggested chart types, Gemini maps exact column names to required chart axes (e.g.,
x_key,y_keys,label_key). - Dashboard Render: The frontend receives the payload and renders fully configured interactive Recharts.
- Chat Interaction: When a user requests a new chart in the chat (e.g., "show me a pie chart"), Gemini outputs a hidden
<CHART: Pie Chart>tag. The frontend intercepts this tag, dynamically configures the required columns viaautoConfigForType(), and injects the new chart into the dashboard view.
- React 18 (Vite)
- TypeScript
- Tailwind CSS v4 (Light theme + Glassmorphism)
- Recharts (Data Visualization)
- Framer Motion (UI Animations)
- Lucide React (Icons)
- Python 3.11
- FastAPI (Web framework)
- Google Generative AI (Gemini) (LLM engine)
- Pandas (Data manipulation)
- PyPDF2 (PDF extraction)
- Node.js v20.19+
- Python 3.10+
- A Google Gemini API Key
- Navigate to the
backenddirectory. - Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate - Install dependencies:
pip install -r requirements.txt
- Create a
.envfile and add your API key:GEMINI_API_KEY=your_api_key_here
- Start the FastAPI server:
uvicorn main:app --reload --port 8000
- Navigate to the
frontenddirectory. - Install dependencies:
npm install
- Start the Vite development server:
npm run dev
- Open
http://localhost:5173in your browser.
DataSense relies on precision prompt engineering rather than raw language generation.
- The Analyzer Agent: Responsible for ingesting the data schema. It strictly outputs JSON containing
content_summaryandinsights. It is instructed to act as a Data Scientist, prioritizing actionable business intelligence. - The Configuration Agent: Takes the list of suggested chart types and the data schema, and acts as a "Frontend Developer". It maps specific keys like
x_key,y_keys, andvalue_keyso the Recharts library knows exactly what data to plot. - The Chat Agent: Handles the conversation history. It is programmed with a strict negative constraint: Never output code blocks. Instead, if a user requests a new layout or metric visualization, it outputs an HTML-like tag (e.g.,
<CHART: Scatter Plot>) alongside conversational text. The React frontend parses this tag to update application state, bridging the gap between natural language and UI rendering seamlessly.