# Quick Start Guide

## What I've Built

A professional **Sales Dashboard** web application that connects to your Google Sheets database. The app includes:

### ✅ Features Implemented

1. **Google Authentication** - Secure OAuth 2.0 login
2. **Google Sheets Integration** - Direct connection to your sales data
3. **Professional Dashboard** - Clean, modern UI
4. **Advanced Filtering** - Filter by:
   - Cliente (Client name)
   - Zona (Zone/Region)
   - Comercial (Salesperson)
   - Familia (Product family)
   - Mês (Month)
5. **Summary Statistics** - Key metrics display:
   - Total Records
   - Total Faturação (Revenue)
   - Unique Clients
   - Total Quantity
6. **Data Visualization** - Sortable data tables

---

## Quick Setup (5 Minutes)

### Step 1: Install Dependencies
```bash
pip install -r requirements.txt
```

### Step 2: Google Cloud Setup

1. Go to: https://console.cloud.google.com/
2. Create a new project
3. Enable APIs:
   - Google Sheets API
   - Google Drive API
4. Create OAuth 2.0 Client ID:
   - Click "Create Credentials"
   - Choose "OAuth 2.0 Client ID"
   - Select "Desktop application"
5. Download as JSON → Save as `credentials.json` in project root

### Step 3: Run the App
```bash
python app.py
```

Open: http://localhost:5000

### Step 4: Connect Your Data

1. Click "Login with Google"
2. On the dashboard, find your Google Sheets ID:
   - Open your sheet in Google Sheets
   - Copy the ID from URL: `https://docs.google.com/spreadsheets/d/SHEET_ID/edit`
3. Paste it in the "Connect to Sheet" box
4. Click "Connect to Sheet"

---

## Important Notes

⚠️ **Make sure your Google Sheet has:**
- Header row with these exact column names:
  - Cliente, Zona, Comercial, Desconto, Prazo Pagamento Dias, Código, Referencia, Familia, Mês, Quant, Faturaçao
- Data starting from row 2

---

## File Structure

```
Sales Dashboard App_VScode/
├── app.py                      # Main Flask application
├── requirements.txt            # Dependencies
├── credentials.json            # (You'll create this)
├── README.md                   # Full documentation
├── QUICKSTART.md              # This file
├── templates/
│   ├── index.html             # Login page
│   ├── base.html              # Base template
│   └── dashboard.html         # Main dashboard
└── static/                    # For assets (CSS, JS)
```

---

## Next Steps

After the basic setup works, you can:

1. **Add more visualizations** - Charts, graphs, summaries
2. **Export data** - Download as CSV/Excel
3. **Add editing** - Update data directly from dashboard
4. **Deploy** - Move from localhost to production server
5. **Custom metrics** - Add more calculations specific to your business

---

## Troubleshooting

**Problem: "State mismatch" error on login**
- Clear session: Visit http://localhost:5000/clearsession
- Try logging in again

**Problem: Spreadsheet not found**
- Verify the Sheets ID is correct
- Make sure the sheet is shared with your Google account

**Problem: Data not loading**
- Check column headers match exactly (with accents)
- Verify numeric columns have numbers, not text
- Ensure data exists below the header row

---

## Need Help?

- Check README.md for full documentation
- Ensure credentials.json is in the same folder as app.py
- Try http://localhost:5000/clearsession if something breaks

Good luck! 🚀
