# Quick Start Guide

## Step 1: Install Dependencies

```bash
cd office-addins
npm install
```

## Step 2: Start the Development Server

```bash
npm start
```

This will start a local server at `https://localhost:3000`

## Step 3: Install the Add-ins

### Word Add-in

1. Open Microsoft Word
2. Go to **Insert** → **Get Add-ins** → **My Add-ins**
3. Click **Upload My Add-in**
4. Browse to `office-addins/word/manifest.xml`
5. Click **Upload**
6. The "Document Tagger" button will appear in the Home ribbon

### Excel Add-in

1. Open Microsoft Excel
2. Go to **Insert** → **Get Add-ins** → **My Add-ins**
3. Click **Upload My Add-in**
4. Browse to `office-addins/excel/manifest.xml`
5. Click **Upload**
6. The "Spreadsheet Tagger" button will appear in the Home ribbon

### Outlook Add-in

**For Outlook Desktop:**
1. Open Outlook
2. Go to **File** → **Manage Add-ins**
3. Click **Add Custom Add-in** → **Add from File**
4. Browse to `office-addins/outlook/manifest.xml`
5. Click **Install**

**For Outlook Web:**
1. Open Outlook on the web
2. Click Settings (gear icon) → **View all Outlook settings**
3. Go to **Mail** → **Customize actions** → **Custom add-ins**
4. Click **Add from file**
5. Upload `office-addins/outlook/manifest.xml`

## Step 4: Configure Backend Connection

The add-ins are configured to connect to: `https://145.223.82.98:8484`

Ensure your backend has these endpoints:
- `POST /login` - Authentication
- `POST /api/document-tags` - Save tags
- `POST /api/check-attachments` - Verify attachments

## Step 5: Test the Add-ins

### Testing Word/Excel

1. Open Word or Excel
2. Click the "Document Tagger" or "Spreadsheet Tagger" button
3. Login with your credentials
4. Type some sensitive content (e.g., "My email is test@example.com")
5. Click "Scan Document Content" or "Scan All Sheets"
6. Verify tags are detected

### Testing Outlook

1. Compose a new email
2. Attach an untagged Word or Excel file
3. Try to send the email
4. You should see an error preventing the send
5. Tag the document using Word/Excel add-in
6. Try sending again - it should work

## Troubleshooting

### Add-in Not Appearing
- Clear Office cache: Delete `%LOCALAPPDATA%\Microsoft\Office\16.0\Wef\`
- Restart Office applications

### Cannot Connect to Backend
- Verify `https://145.223.82.98:8484` is accessible
- Check CORS is enabled on the backend
- Check browser console for errors

### Login Fails
- Verify backend `/login` endpoint is working
- Check credentials are correct
- Inspect network tab in browser developer tools

## Development Tips

### Debug Mode
Open browser developer tools:
- **Word/Excel:** Right-click in taskpane → Inspect
- **Outlook:** F12 in Outlook Web

### Hot Reload
After making changes:
1. Save files
2. In Office app, close and reopen the taskpane
3. For Outlook, restart Outlook

### Manifest Validation
```bash
npm run validate
```

## Production Deployment

1. **Get SSL Certificate**
   ```bash
   # Self-signed for testing
   openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
   ```

2. **Update Manifest Files**
   - Replace `https://localhost:3000` with your production URL
   - Update in all manifest.xml files

3. **Deploy to Web Server**
   ```bash
   # Upload all files to your web server
   scp -r office-addins/* user@yourserver:/var/www/addins/
   ```

4. **Start HTTPS Server**
   ```bash
   npm run start:https
   ```

## Need Help?

- Check the main README.md for detailed documentation
- Review the API Reference section
- Check browser console for errors
- Verify all endpoints are responding

## Common Test Scenarios

### Scenario 1: Tag Detection
1. Open Word
2. Write: "Call me at 555-123-4567 or email john@example.com"
3. Scan document
4. Should detect: PHONE, EMAIL tags

### Scenario 2: Financial Data
1. Open Excel
2. Enter credit card: "4532 1234 5678 9012"
3. Enter text: "Financial report confidential"
4. Scan spreadsheet
5. Should detect: CREDIT_CARD, CONFIDENTIAL tags

### Scenario 3: Email Blocking
1. Create Word document WITHOUT scanning
2. Compose email in Outlook
3. Attach the document
4. Try to send
5. Should be BLOCKED with error message

### Scenario 4: Email Allowed
1. Create Word document
2. Scan it with Document Tagger
3. Compose email in Outlook
4. Attach the tagged document
5. Send email
6. Should SEND successfully

## Next Steps

- Customize regex patterns in `shared/tagging-service.js`
- Add custom tag types for your organization
- Integrate with your existing security systems
- Set up automated testing
- Deploy to production environment

Happy tagging! 🏷️
