# KPI Analysis - Quick Start Guide

## 🚀 Getting Started in 3 Steps

### Step 1: Start the Application
```bash
cd kpi_analysis
python run.py
```

You should see:
```
✅ All required packages are installed
✅ .env file found
✅ Required directories created
🗄️  Setting up database...
✅ Database initialized successfully
🚀 Starting KPI Analysis Dashboard in development mode...
📊 Dashboard: http://localhost:8000
📚 API Docs: http://localhost:8000/docs
```

### Step 2: Login
1. Open browser: http://localhost:8000
2. You'll be redirected to login page
3. Use default credentials:
   - Username: `admin`
   - Password: `super`

### Step 3: Upload and Analyze
1. Click **"Upload File"** button in the Files tab
2. Select your KPI Excel file (e.g., "KPI Manager Information Technology.xlsx")
3. Click **"Upload"**
4. Wait for processing (status will change from "Processing..." to "Processed")
5. Click **"View Analysis"** to see results
6. Click **"Report"** to download PDF

## 📊 What You'll See

### Dashboard Overview
- **Total Files**: Number of uploaded files
- **Avg Score**: Average performance score (shows 0% until files are analyzed)
- **Achievement Rate**: KPI achievement percentage (shows 0% until files are analyzed)
- **Reports Generated**: Number of PDF reports (shows 0 until files are analyzed)

### Empty State (No Data)
When no files are uploaded, you'll see:
- Empty charts with placeholder data
- "No activity yet. Upload a KPI file to get started."
- "No files uploaded yet. Click 'Upload File' to get started."

### After Upload
Once a file is uploaded and processed:
- File appears in the Files table with "Processed" status
- Click "View Analysis" to see:
  - Overall Score
  - Achievement Rate
  - Perspective Scores (Financial, Customer, Internal Process, Learning & Growth)
  - AI-generated Recommendations
- Click "Report" to download professional PDF report

## 🎯 Sample File

Use the included sample file to test:
```
KPI Manager Information Technology.xlsx
```

This file contains:
- Employee KPI data
- Multiple perspectives (Financial, Customer, Internal Process, Learning & Growth)
- Monthly performance data
- Achievement status

## 🔧 Troubleshooting

### Issue: "Authentication failed"
**Solution**: Check credentials in `.env` file:
```env
ENABLE_FALLBACK_AUTH=true
FALLBACK_ADMIN_USERNAME=admin
FALLBACK_ADMIN_PASSWORD=super
```

### Issue: "File upload failed"
**Solution**: 
- Check file format (must be .xlsx or .xls)
- Check file size (max 50MB)
- Ensure `uploads/` directory exists

### Issue: "Analysis not available yet"
**Solution**: 
- Wait a few seconds for background processing
- Refresh the page
- Check server logs for errors

### Issue: Charts not showing
**Solution**:
- Charts show empty state when no data
- Upload a file first
- Wait for processing to complete

## 📝 Tips

1. **First Time Setup**: The database is created automatically on first run
2. **No Dummy Data**: All data comes from uploaded files - dashboard starts empty
3. **Background Processing**: Analysis runs in background, so you can continue using the app
4. **PDF Reports**: Generated automatically after analysis completes
5. **AI Insights**: If OpenAI API key is configured, you'll get AI-powered insights

## 🎉 You're Ready!

The system is now ready to:
- ✅ Accept Excel file uploads
- ✅ Parse KPI data automatically
- ✅ Generate AI-powered insights
- ✅ Create interactive charts
- ✅ Produce professional PDF reports

Start by uploading your first KPI file!
