Inside KitKraft
Pulse — the daily-sales briefing
At 8:00am every morning Pulse pulls yesterday's POS data from all five stores, runs seven deterministic anomaly rules against the trailing 4-week baseline, and writes a one-page Mariam-voice PDF on top of the rule findings. The PDF is delivered to the founders and the five store managers via email and WhatsApp before the stores open. It saves Mariam 90 minutes of WhatsApp every day and gets every manager looking at the same numbers.
Below: a live preview against today's seeded POS dataset. The "Download PDF" button generates a real PDF (not a screenshot of the preview) using the same renderer the cron job uses.
Generating today's briefing…
How it works
- Vercel Cron triggers /api/cron/daily-report at 03:00 UTC (08:00 PKT).
- Pulse reads yesterday's POS data from src/data/sales-fixtures.ts (production: /api/pos hitting Square).
- The rule engine in src/lib/analyze.ts runs 7 anomaly rules — group revenue ±15%, per-store revenue ±20%, top-3 SKU rank shifts, returns spike (2× rolling 28-day), basket size ±15%, stockouts on normally-selling SKUs, margin mix shift > 10pp.
- The findings — and only the findings — are passed to Gemini 2.0 Flash, which writes a 60–120 word summary in Mariam's voice plus one short paragraph per finding card. No invention; the prompt makes that explicit.
- A real PDF is rendered server-side via pdfkit, with KitKraft branding and the same data the dashboard shows.
- Multi-channel dispatch: email to founders + 5 store managers, WhatsApp document to founders. Both gated behind EMAIL_DELIVERY_ENABLED / WHATSAPP_DELIVERY_ENABLED safety switches; default is "would-have-sent" logging.