A full-stack analytics dashboard for visualizing AI Note-Taking Pin sales data
React + Flask + Polars
Quick Start • Features • API • Data Format • Troubleshooting
| Feature | Description |
|---|---|
| KPI Dashboard | Real-time metrics for revenue, transactions, units sold, and averages |
| Interactive Charts | Revenue by region, sales channel breakdown, daily/monthly trends |
| Data Table | Sortable, paginated view with search and export capabilities |
| Advanced Filters | Filter by date range, region, channel, and price range |
| File Upload | Drag-and-drop CSV upload with automatic data validation |
| Responsive Design | Works seamlessly on desktop, tablet, and mobile |
| Requirement | Version | Check Command |
|---|---|---|
| Node.js | v16+ | node --version |
| Python | v3.8+ | python --version |
| npm | v8+ | npm --version |
1. Clone the repository
git clone https://github.com/promptadvisers/claude-code-analytics.git
cd claude-code-analytics2. Backend Setup
# Navigate to backend
cd backend
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # macOS/Linux
# venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Start the server
python app.pyBackend runs at
http://localhost:5001
3. Frontend Setup (new terminal)
# Navigate to frontend
cd frontend
# Install dependencies
npm install
# Start development server
npm startFrontend runs at
http://localhost:3000
4. Open your browser
Navigate to http://localhost:3000 — the dashboard will load automatically.
claude-code-analytics/
│
├── backend/
│ ├── app.py # Flask API server (routes & endpoints)
│ ├── data_processor.py # Data processing with Polars
│ ├── requirements.txt # Python dependencies
│ └── data/ # Auto-generated backup files
│
├── frontend/
│ ├── src/
│ │ ├── App.tsx # Main React component
│ │ ├── components/
│ │ │ ├── KPICards.tsx # KPI metric cards
│ │ │ ├── Charts.tsx # Recharts visualizations
│ │ │ ├── DataTable.tsx # Paginated data table
│ │ │ └── FileUpload.tsx # CSV upload component
│ │ ├── services/
│ │ │ └── api.ts # Axios API client
│ │ └── types/
│ │ └── index.ts # TypeScript interfaces
│ ├── package.json
│ └── tailwind.config.js
│
├── data/
│ └── AI_Note_Taking_Pin_Sales_Data__2025_.csv # Sample dataset
│
└── README.md
The dashboard expects CSV files with the following schema:
| Column | Type | Example | Description |
|---|---|---|---|
Sale_ID |
Integer | 1 |
Unique transaction identifier |
Date |
Date | 2025-04-25 |
Transaction date (YYYY-MM-DD) |
Units_Sold |
Integer | 5 |
Number of units in transaction |
Price_Per_Unit |
Float | 149.00 |
Unit price in USD |
Revenue |
Float | 745.00 |
Total revenue (auto-calculated) |
Region |
String | North America |
Geographic region |
Sales_Channel |
String | Online Store |
Sales channel type |
Sale_ID,Date,Units_Sold,Price_Per_Unit,Revenue,Region,Sales_Channel
1,2025-11-24,4,149,596,Asia,Retail Partner
2,2025-04-25,5,149,745,Africa,Online Store
3,2025-10-30,14,149,2086,North America,Online Store
4,2025-04-22,8,149,1192,Africa,Retail PartnerNorth America • South America • Europe • Asia • Africa
Direct Sales • Online Store • Retail Partner • Event Booth
Base URL: http://localhost:5001/api
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Server health check |
| Endpoint | Method | Description |
|---|---|---|
/kpi |
GET | Key performance indicators (revenue, units, averages) |
/revenue-by-region |
GET | Revenue aggregated by geographic region |
/revenue-by-channel |
GET | Revenue aggregated by sales channel |
/daily-trends |
GET | Daily revenue and transaction trends |
/monthly-trends |
GET | Monthly aggregated trends |
/price-distribution |
GET | Price point distribution analysis |
/filter-options |
GET | Available filter values (regions, channels, date range) |
| Endpoint | Method | Parameters | Description |
|---|---|---|---|
/data |
GET | page, per_page, sort_by, sort_order, filters |
Paginated transaction data |
/analytics/filtered |
POST | JSON body with filter criteria | Filtered analytics data |
/upload |
POST | multipart/form-data |
Upload new CSV file |
curl "http://localhost:5001/api/data?page=1&per_page=10&sort_by=Date&sort_order=desc"curl -X POST -F "file=@sales_data.csv" http://localhost:5001/api/upload| Setting | Value | Location |
|---|---|---|
| Port | 5001 |
backend/app.py |
| Data File | data/AI_Note_Taking_Pin_Sales_Data__2025_.csv |
backend/app.py |
| Max Upload Size | 16 MB | backend/app.py |
| CORS | Enabled (all origins) | backend/app.py |
| Setting | Value | Location |
|---|---|---|
| Port | 3000 |
Default React |
| API Proxy | http://localhost:5001 |
frontend/package.json |
| Request Timeout | 10 seconds | frontend/src/services/api.ts |
| Technology | Purpose |
|---|---|
| React 18 | UI framework |
| TypeScript | Type safety |
| Tailwind CSS | Styling |
| Recharts | Data visualization |
| Axios | HTTP client |
| Headless UI | Accessible components |
| Technology | Purpose |
|---|---|
| Flask 3.0 | Web framework |
| Flask-CORS | Cross-origin requests |
| Polars | High-performance data processing |
| Watchdog | File system monitoring |
# Find and kill the process
lsof -ti:5001 | xargs kill -9
# Then restart the backend
python app.py# Find and kill the process
lsof -ti:3000 | xargs kill -9
# Then restart the frontend
npm start- Verify backend is running:
curl http://localhost:5001/api/health - Check browser console for CORS errors
- Hard refresh:
Cmd+Shift+R(Mac) orCtrl+Shift+R(Windows)
- Verify the CSV file exists:
ls -la data/AI_Note_Taking_Pin_Sales_Data__2025_.csv
- Check backend console for errors
- Test the API directly:
curl http://localhost:5001/api/kpi
- Ensure file is valid CSV format
- Check file size (max 16 MB)
- Verify column names match expected schema
- Check backend console for detailed error messages
# Frontend tests
cd frontend && npm test
# Backend (if tests exist)
cd backend && python -m pytest# Frontend build
cd frontend && npm run build
# The build output will be in frontend/build/- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes
- Commit:
git commit -m "Add your feature" - Push:
git push origin feature/your-feature - Open a Pull Request
MIT License — see LICENSE for details.
Built with React, Flask, and Polars