Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

InsightAI

An AI-powered business analytics platform (prototype). Upload a CSV or Excel file and get an instant AI-generated executive summary, KPIs, auto-suggested charts, and a chatbot that answers questions about your data.

How it works

  1. Upload a .csv / .xlsx / .xls file from the dashboard.
  2. The backend processes it in the background:
    • An LLM detects the header row (even in messy spreadsheets) and the data is cleaned.
    • A FAISS vector store is built over the rows for retrieval-augmented Q&A.
    • Mistral (via OpenRouter) generates an executive summary, chart suggestions, and KPIs.
  3. The dashboard shows the AI summary, interactive Recharts visualizations, and a chat panel where you can ask questions like "What caused the revenue dip last quarter?".

Project structure

├── backend/                    # FastAPI backend (port 8006)
│   ├── app/
│   │   ├── main.py             # App entry point, routers, CORS
│   │   ├── routes/             # auth, upload, preview, kpis, charts, gpt (/ask), dashboard, admin
│   │   ├── models/             # SQLAlchemy models: User, UploadedFile, ParsedData
│   │   ├── tasks/              # Background file-processing pipeline
│   │   ├── utils/              # JWT auth, embeddings/LLM helpers
│   │   └── custom_models/      # LangChain wrapper for the Mistral chat API
│   ├── .kiro/specs/            # Feature requirement specs
│   ├── requirements.txt        # Direct dependencies
│   └── requirements.lock.txt   # Pinned versions (pip freeze)
└── frontend/                   # React 19 + Tailwind CSS app (port 3000)
    └── src/
        ├── api/                # Axios API layer (JWT attached automatically)
        ├── pages/              # Home, Login, Register, Dashboard, Admin, ...
        ├── components/         # Navbar, charts, tables, route guards
        └── context/            # Login state

Tech stack

Layer Tech
Backend FastAPI, SQLAlchemy, PostgreSQL, Uvicorn
AI / ML LangChain, Mistral (direct + via OpenRouter), FAISS, sentence-transformers
Auth JWT (python-jose), bcrypt (passlib), role-based access (user/admin)
Frontend React 19, React Router 7, Tailwind CSS, Recharts, Chart.js, Framer Motion

Getting started

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • PostgreSQL (with a database created for the app)
  • API keys: Mistral and OpenRouter

1. Backend

cd backend
python -m venv env
env\Scripts\activate          # Windows  (source env/bin/activate on macOS/Linux)
pip install -r requirements.txt

# Configure secrets
copy .env.example .env        # then edit .env with your DB URL and API keys

# Run (tables are created automatically on startup)
uvicorn app.main:app --reload --port 8006

API docs are served at http://localhost:8006/docs.

2. Frontend

cd frontend
npm install

copy .env.example .env        # points at http://localhost:8006 by default

npm start

The app opens at http://localhost:3000.

3. Accounts

  • Register a normal user from the UI (/register).
  • To create an admin, POST to /api/register with "role": "admin" and the admin_code matching ADMIN_SECRET from the backend .env. Admins are redirected to /admin/dashboard after login, where they can view all users/files and delete files.

API overview

All endpoints are prefixed with /api and (except register/login) require a Bearer JWT.

Method Endpoint Description
POST /register Create an account (role: admin requires admin_code)
POST /login Get JWT + user info
POST /upload Upload CSV/Excel, returns file_id, processing runs in background
GET /status/{file_id} Poll processing status (pendingprocessed / failed)
GET /dashboard/{file_id} Unified view: summary, charts, KPIs, preview rows
GET /preview/{file_id} Sample parsed rows
GET /kpis/{file_id} Statistical KPIs (cached; ?refresh=true to regenerate)
GET /charts/{file_id} AI-suggested chart configs + data (cached; ?refresh=true)
POST /ask RAG Q&A over the uploaded file ({file_id, question})
GET /admin/users List all users (admin only)
GET /admin/files List all files (admin only)
DELETE /admin/files/{id} Delete a file, its data, and its file on disk (admin only)
GET /admin/files/{id}/preview Preview any file's parsed data (admin only)

Environment variables

Backend (backend/.env): DATABASE_URL, JWT_SECRET_KEY, ADMIN_SECRET, MISTRAL_API_KEY, OPENROUTER_API_KEY — see .env.example.

Frontend (frontend/.env): REACT_APP_SERVER_IP — the backend base URL.

⚠️ Never commit .env files. They are excluded by .gitignore; use the .env.example templates.

Notes

  • Uploaded files (uploads/), vector stores (vectorstores/), and generated charts (charts/) are runtime data and are git-ignored.
  • For production, restrict the CORS allow_origins list in app/main.py to your frontend's domain.

About

AI-powered analytics dashboard: turn CSV/Excel uploads into executive summaries, KPIs, charts, and a chat-with-your-data assistant.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages