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.
- Overview
- Features
- Architecture
- Tech Stack
- Project Structure
- Installation
- Usage
- AI Chat Interface
- Data Profiling Engine
- Sample Data
- Configuration
- Contributing
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.
| 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 |
| 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 |
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 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 β β
β ββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| 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 |
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.)
- Python 3.11+
- Node.js 18+
- A Google Gemini API key
git clone https://github.com/crastatelvin/ops-intelligence-copilot.git
cd ops-intelligence-copilotcd backend
python -m venv venv
# Activate virtual environment
source venv/bin/activate # Linux / macOS
venv\Scripts\activate # Windows
pip install -r requirements.txt# Create a .env file in the backend/ directory
echo "GEMINI_API_KEY=your_gemini_api_key_here" > .envuvicorn main:app --reloadAPI will be running at http://localhost:8000
cd ../frontend
npm install
npm startFrontend will be running at http://localhost:3000
- Open the app at
http://localhost:3000 - Drag and drop a CSV or Excel file onto the upload zone, or click Browse File
- The backend instantly profiles your data and returns KPIs, insights, anomalies, and chart data
- You are automatically redirected to 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
Click Upload New File in the top-right corner of the dashboard to reset and start fresh.
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.textChat endpoint: POST /query β accepts { "question": "your question here" }
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 |
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 |
# 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/.
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_storeis a single global dict β not safe for multi-user concurrent sessions; use Redis or a session ID keyed store instead - Never commit your
.envfile or expose yourGEMINI_API_KEYpublicly - Add file size and type validation before deploying to production
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -m 'Add your feature' - Push:
git push origin feature/your-feature - 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.
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!