InstaviZ is an AI-powered data visualization platform that allows users to upload CSV datasets, query them using natural language, and generate charts dynamically.
This repository contains the backend of InstaviZ, built with Node.js, Express, and MongoDB, and integrated with AI models (Gemini) for intelligent data analysis and chart generation.
-
CSV Upload & Parsing
-
Handles large CSV files efficiently
-
Automatically extracts rows, columns, and sample data
-
MongoDB Data Storage
-
Dataset metadata stored separately from dataset rows
-
Dynamic schema for CSV rows (supports any column structure)
-
AI‑Driven Chart Generation
-
Natural language → MongoDB aggregation pipelines
-
Bar charts, pie charts, and analytical summaries
-
Fallback local chart generation when AI fails
-
AI Chat with Data
-
Users can ask questions about uploaded datasets
-
Detects when user requests charts vs normal chat
-
Cost‑optimized AI model switching
-
Authentication & Guest Support
-
JWT‑based authentication for logged‑in users
-
Automatic guest user creation using cookies
-
Token‑based usage limits
-
API Key Rotation
-
Gemini API key rotation on quota / rate‑limit errors
-
Ensures high availability and cost control
-
Secure & Scalable Architecture
-
Middleware‑based auth handling
-
Modular service structure
-
Clean separation of concerns
- Runtime: Node.js
- Framework: Express.js
- Language: TypeScript
- Database: MongoDB (Mongoose)
- AI Models: Google Gemini (1.5 / 2.5 Flash)
- Auth: JWT + Guest cookies
- Storage: Cloud object storage (R2 / S3 compatible)
- CSV Parsing: Streaming‑based CSV parser
src/
├─ controllers/ # Request handlers
├─ services/ # AI, chart, dataset logic
├─ middlewares/ # Auth & token checks
├─ model/ # Mongoose models
├─ routes/ # API routes
├─ utils/ # Helpers & prompt builders
└─ config/ # AI tools & configuration