# Punkit Creative — Management Auto 3: Board Pack Generator
## Developer Handover & Implementation Guide

This is the most complex automation in the Management Suite. A Board Pack that previously took the CFO and PA 2–3 full days is now generated automatically, reviewed via a premium dashboard, and distributed as a pixel-perfect PDF — all without human intervention beyond a single approval click.

---

## 1. System Architecture

### Layer 1 — CFO Approval Dashboard (`board_pack_dashboard.html`)
A fully custom, sidebar-navigated CFO dashboard containing all 7 sections of the board pack.

| Section | Data Source | Description |
|---|---|---|
| Executive Summary | OpenAI GPT-4o | AI-written 3-paragraph board narrative |
| Financial Highlights | Xero API (P&L + Balance Sheet) | Revenue, cash, margins, AR/AP |
| Revenue & Pipeline | HubSpot API | Deals, pipeline value, win rate, targets |
| Marketing & Audience | Google Analytics 4 | Traffic, conversions, top channels |
| HR & Operations | BambooHR API | Headcount, turnover, open positions |
| Key Risks & Opportunities | OpenAI GPT-4o | AI-generated Risk Register (severity-ranked) |
| Resolutions Required | CFO Manual Input | Editable agenda items for the board meeting |

Additional features:
- **Manage Board Members:** The CFO can add/remove recipients directly in the dashboard.
- **Approve & Distribute:** Single button triggers the full PDF generation and distribution workflow.

### Layer 2 — PDF Generation (Browserless.io)
When the CFO clicks "Approve & Distribute", the dashboard sends a POST to the n8n Approval Webhook. n8n then calls the **Browserless.io API** to render the live dashboard as a pixel-perfect, print-ready A4 PDF. This ensures the PDF looks exactly as beautiful as the dashboard.

**Cost:** Browserless.io pricing starts at ~$50/month. This is easily absorbed into the R6,000–R12,000 monthly retainer.

### Layer 3 — Distribution & Filing (n8n)
After the PDF is generated:
1. n8n uploads the PDF to a designated **Google Drive** folder (e.g., `Board Packs / 2026-07`).
2. n8n fetches the full board member list from the dashboard DB.
3. n8n emails the PDF as an attachment to each board member individually, with a personalized greeting.

---

## 2. Deployment Steps

### Step 1: Deploy the CFO Dashboard
1. Host `board_pack_dashboard.html` on a secure, authenticated route (e.g., `https://punkit.co.za/board-pack-review`).
2. Connect the page to your backend DB so it dynamically renders the AI commentary and financial data pushed by n8n.
3. Ensure the "Approve & Distribute" button POSTs to the n8n `board-pack-approved` webhook URL.

### Step 2: Import & Configure the n8n Workflow
1. Import `board_pack_workflow.json` into the production n8n instance.
2. Authenticate the following nodes:
   - **Xero (×2):** OAuth2 with `accounting.reports.read` scope.
   - **HubSpot:** Private App token with `crm.objects.deals.read`.
   - **Google Analytics:** Service Account JSON with GA4 Property read access.
   - **BambooHR:** Basic Auth (API Key + subdomain).
   - **OpenAI:** Active API key.
   - **Gmail (×2):** Authorize the sending address (CFO email + board distribution).
   - **Google Drive:** Service Account or OAuth2 with `drive.file` scope. Update `BOARD_PACKS_FOLDER_ID` to the target folder ID.
   - **Browserless.io:** Replace `YOUR_BROWSERLESS_API_KEY` with the live key.
3. Update the CRON trigger date (currently set to the 28th of each month) to match the client's board meeting schedule.

### Step 3: Testing
1. Manually trigger the CRON section of the workflow.
2. Verify all 5 data sources return data.
3. Verify the CFO notification email arrives correctly.
4. Open the dashboard and verify all sections are populated.
5. Click "Approve & Distribute" and verify:
   - The PDF is generated correctly.
   - The PDF is uploaded to Google Drive.
   - All board members receive the email with the attached PDF.

---

## 3. Adding New Sections
To add a new pack section (e.g., "Legal & Compliance"):
1. Add a new data-fetch node to the n8n workflow.
2. Pass the data to the OpenAI node's prompt.
3. Add a new `<div class="card">` section to the HTML dashboard.
4. Add a new `<a class="nav-item">` link to the sidebar.

---

## 4. Assumptions Made
- **Board meeting schedule:** Monthly (28th trigger, meeting on 30th/1st). Adjust CRON as required.
- **PDF renderer:** Browserless.io selected for premium rendering quality.
- **Board member list:** Managed via the "Board Members" panel in the dashboard and stored in the backend DB.
