Skip to content

crastatelvin/ops-intelligence-copilot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Š Ops Intelligence Copilot

An AI-Powered Operational Data Analysis & Natural Language Q&A Platform

Python FastAPI React Gemini Recharts License: MIT


Ops Intelligence Copilot is a full-stack AI web application that transforms raw operational data into instant, actionable intelligence. Upload any CSV or Excel file and get auto-generated KPI summaries, Z-score anomaly detection, dynamic trend charts, and a natural language chat interface powered by Google Gemini Flash β€” all in one clean, no-setup dashboard.


Upload CSV or Excel AI Q&A Anomaly Detection


πŸ“‹ Table of Contents


🧠 Overview

Ops Intelligence Copilot is a lightweight but powerful business intelligence tool built for operations teams, analysts, and managers who need fast answers from their data β€” without writing a single line of SQL or Python.

Users can:

  • Upload any CSV or Excel operational dataset via drag-and-drop or file picker
  • Instantly receive a KPI summary strip (row count, column count, column averages)
  • View auto-detected anomalies flagged via Z-score analysis (Β±2 standard deviations)
  • Explore a dynamic trend chart rendered from the primary numeric column
  • Ask plain-English questions about their data and receive AI-powered answers via Google Gemini Flash
  • Reset and re-upload a new file anytime from the dashboard

The backend is built with FastAPI, holds the uploaded dataframe in memory for the session, and passes data context (column names, statistical summary, and a 5-row sample) to Gemini for accurate, grounded responses.


πŸ’» Application Preview



{82DD1B1B-6CB3-492D-9A39-081EFE80EBE9}

{35E76ADA-0EA2-4D95-8B34-658FE56A2945}

{576061B8-32EF-4D9E-8E34-FB7D7137E7AA}

{21EFAE31-4DAE-490F-86FD-AE6DC1A60BC4}

{36D5E71C-D97B-4C8D-AE96-E63EB77B8FC4}

{83F067E6-244D-4728-A7E3-3DB3B9C1F2BC}

✨ Features

Feature Description
πŸ“ Drag-and-Drop Upload Upload CSV or Excel files (.csv, .xlsx, .xls) via drag-and-drop or file browser
πŸ“Š KPI Strip Auto-generated cards showing row count, column count, and column averages on upload
πŸ“‹ Data Insights Panel Column type breakdown, missing value report, and shape summary
⚠️ Anomaly Detection Z-score based outlier detection across all numeric columns with percentage reporting
πŸ“ˆ Trend Chart Recharts line chart auto-rendered from the first numeric column (first 20 rows)
πŸ’¬ AI Chat Q&A Natural language question answering powered by Google Gemini Flash with Markdown rendering
πŸ”„ Session Reset Upload a new file anytime; previous data is cleared and replaced
🌐 REST API Clean FastAPI backend with /upload, /query, and /status endpoints

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Browser / React App                 β”‚
β”‚                                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ UploadPage β”‚  β”‚DashboardPage β”‚  β”‚ChatInterface β”‚  β”‚
β”‚  β”‚  (drop +   β”‚  β”‚  KPIStrip    β”‚  β”‚  (Gemini AI  β”‚  β”‚
β”‚  β”‚   browse)  β”‚  β”‚  InsightCard β”‚  β”‚   Q&A chat)  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β”‚  ChartViewer β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚        β”‚         β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚  POST /upload  β”‚                 β”‚ POST /query
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              FastAPI Backend (main.py)               β”‚
β”‚                                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚            data_service.py                      β”‚ β”‚
β”‚  β”‚   profile_data() β†’ KPIs Β· Insights Β· Anomalies  β”‚ β”‚
β”‚  β”‚   Z-score detection Β· Chart data Β· Shape info   β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚            gemini_service.py                    β”‚ β”‚
β”‚  β”‚   ask_gemini() β†’ Google Gemini Flash API        β”‚ β”‚
β”‚  β”‚   Context: columns + sample + stats summary     β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                β”‚
β”‚  β”‚  df_store (dict) β”‚  ← In-memory DataFrame store   β”‚
β”‚  β”‚  "current" β†’ df  β”‚                                β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Tech Stack

Layer Technology
Frontend React 18, Recharts, react-markdown, Axios
Backend FastAPI, Uvicorn, Python 3.11+
Data Processing Pandas, NumPy, OpenPyXL
AI / LLM Google Gemini Flash (gemini-flash-latest) via google-genai SDK
Styling Inline React styles (no external CSS framework)
File Support CSV, XLSX, XLS

πŸ“ Project Structure

ops-intelligence-copilot/
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ main.py               # FastAPI app β€” /upload, /query, /status routes
β”‚   β”œβ”€β”€ data_service.py       # Data profiling: KPIs, anomalies, insights, chart data
β”‚   β”œβ”€β”€ gemini_service.py     # Google Gemini Flash integration β€” ask_gemini()
β”‚   β”œβ”€β”€ requirements.txt      # Python dependencies
β”‚   └── .env                  # GEMINI_API_KEY environment variable
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   └── index.html        # HTML entry point
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.jsx           # Root component β€” toggles UploadPage ↔ DashboardPage
β”‚   β”‚   β”œβ”€β”€ index.js          # React DOM entry
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ UploadPage.jsx    # Drag-and-drop upload UI with loading state
β”‚   β”‚   β”‚   └── DashboardPage.jsx # Main dashboard layout: KPI + Chart + Chat
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ KPIStrip.jsx      # KPI summary cards (rows, cols, averages)
β”‚   β”‚   β”‚   β”œβ”€β”€ InsightCard.jsx   # Data insights list + anomaly warnings
β”‚   β”‚   β”‚   β”œβ”€β”€ ChartViewer.jsx   # Recharts line chart for primary numeric column
β”‚   β”‚   β”‚   └── ChatInterface.jsx # Gemini-powered chat UI with Markdown rendering
β”‚   β”‚   └── services/
β”‚   β”‚       └── api.js            # Axios wrappers: uploadFile, queryData, getStatus
β”‚   └── package.json
β”‚
└── sample_data/
    └── ops_sample.csv        # 12-row sample ops dataset (revenue, churn, tickets, etc.)

πŸš€ Installation

Prerequisites

1. Clone the Repository

git clone https://github.com/crastatelvin/ops-intelligence-copilot.git
cd ops-intelligence-copilot

2. Backend Setup

cd backend
python -m venv venv

# Activate virtual environment
source venv/bin/activate        # Linux / macOS
venv\Scripts\activate           # Windows

pip install -r requirements.txt

3. Configure Environment Variables

# Create a .env file in the backend/ directory
echo "GEMINI_API_KEY=your_gemini_api_key_here" > .env

4. Start the Backend

uvicorn main:app --reload

API will be running at http://localhost:8000

5. Frontend Setup

cd ../frontend
npm install
npm start

Frontend will be running at http://localhost:3000


πŸ’» Usage

Uploading Data

  1. Open the app at http://localhost:3000
  2. Drag and drop a CSV or Excel file onto the upload zone, or click Browse File
  3. The backend instantly profiles your data and returns KPIs, insights, anomalies, and chart data
  4. You are automatically redirected to the Dashboard

Reading the Dashboard

  • KPI Strip β€” top cards show total rows, columns, and averages for the first two numeric columns
  • Data Insights Panel β€” lists column types, missing value status, and data shape
  • Anomaly Warnings β€” red-highlighted cards for any column with Z-score outliers, including outlier count and percentage
  • Trend Chart β€” line chart of the primary numeric column across the first 20 rows

Uploading a New File

Click Upload New File in the top-right corner of the dashboard to reset and start fresh.


πŸ’¬ AI Chat Interface

The built-in chat panel lets you ask plain-English questions about your uploaded data, powered by Google Gemini Flash.

Example questions you can ask:

  • "What is the average revenue per month?"
  • "Which column has the most anomalies?"
  • "Is there a trend between churn rate and ticket volume?"
  • "Which month had the highest resolution time?"
  • "Summarize the overall performance of this dataset"

Gemini receives your dataset's column names, statistical summary, and a 5-row sample as context β€” so all answers are grounded in your actual data.

# gemini_service.py β€” core prompt construction
def ask_gemini(question: str, summary: str, columns: list, sample: str) -> str:
    prompt = f"""
You are an intelligent data analyst assistant for an Ops Intelligence Copilot tool.

COLUMNS: {columns}
DATA SAMPLE (first 5 rows): {sample}
STATISTICAL SUMMARY: {summary}
USER QUESTION: {question}

Answer clearly in plain English. Use professional Markdown formatting.
Keep response under 200 words.
    """
    response = client.models.generate_content(model="gemini-flash-latest", contents=prompt)
    return response.text

Chat endpoint: POST /query β€” accepts { "question": "your question here" }


πŸ”¬ Data Profiling Engine

The data_service.py module runs on every file upload and returns a structured insights payload.

What it computes:

Output Description
insights Human-readable list: shape, column types, missing values
kpis Per-column stats: mean, max, min, sum, median
anomalies Z-score outliers (Β±2 std dev): count and percentage per column
chart_data First 20 non-null values of the primary numeric column
primary_chart_col Name of the first numeric column (used as chart title)
shape { rows, cols } β€” raw dataset dimensions
columns Full column name list

πŸ“‚ Sample Data

A sample operational dataset is included at sample_data/ops_sample.csv to test the app immediately:

Column Description
month Month label (Jan–Dec)
revenue Monthly revenue in USD
customers Active customer count
tickets_raised Support tickets opened
tickets_resolved Support tickets closed
churn_rate Monthly churn percentage
avg_resolution_time Average days to resolve a ticket

βš™οΈ Configuration

# backend/.env
GEMINI_API_KEY=your_gemini_api_key_here
// frontend/src/services/api.js
const BASE_URL = process.env.REACT_APP_API_URL || 'http://localhost:8000';

To point the frontend at a deployed backend, set REACT_APP_API_URL in a .env file inside frontend/.


πŸ”’ Security Notes

This project is built for local and internal use. Before any public deployment:

  • The backend uses allow_origins=["*"] β€” restrict this to your frontend domain in production
  • The in-memory df_store is a single global dict β€” not safe for multi-user concurrent sessions; use Redis or a session ID keyed store instead
  • Never commit your .env file or expose your GEMINI_API_KEY publicly
  • Add file size and type validation before deploying to production

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Commit your changes: git commit -m 'Add your feature'
  4. Push: git push origin feature/your-feature
  5. Open a Pull Request

Ideas for improvement: persistent file storage (S3/disk), multi-file session support, chart type selector (bar/pie/scatter), export insights as PDF, multi-turn conversation history for the chat, user authentication, streaming Gemini responses.


License

This project is licensed under the MIT License. See LICENSE.

                                Made with ❀️ by [Crasta Telvin](https://github.com/crastatelvin)

                                         ⭐ Star this repo if you find it useful!

About

πŸ“Š Upload CSV/Excel ops data β†’ ask questions in plain English β†’ get AI-powered KPI summaries, anomaly detection & dynamic charts. Built with React + FastAPI + Gemini Flash.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages