PRODUCTION ARCHITECTURES
Developer Cookbooks & Agent Recipes
Production-tested recipes demonstrating how to build autonomous agents, sync kitchen printers, and automate cash drawer audits.
PYTHON • MCP 2024-11-05
1. Nightly Cash Drawer & Blind Drop Auditor Agent
Runs automatically post-closing to audit all cashier blind drops, verify expected cash balances, and alert management to cash variances.
audit_shifts.pyPython 3.11+
import os
import requests
BRAZZA_API_KEY = os.getenv("BRAZZA_API_KEY")
API_URL = "https://brazza.app/api/v1"
headers = {
"Authorization": f"Bearer ${BRAZZA_API_KEY}",
"Content-Type": "application/json"
}
def audit_daily_shifts(date_str):
resp = requests.get(f"${API_URL}/shifts/summary?date=${date_str}", headers=headers)
data = resp.json()
for shift in data.get("shifts", []):
variance = shift.get("cash_variance", 0)
cashier = shift.get("cashier_name")
if abs(variance) > 200.0:
print(f"[ALERTA FRAUDE] Turno #${shift['id']} - Cajero: ${cashier} - Discrepancia: \$${variance}")
else:
print(f"[OK] Turno #${shift['id']} cuadrado perfectamente.")
if __name__ == "__main__":
audit_daily_shifts("2026-10-05")TYPESCRIPT • WEBHOOKS
2. Verifying Incoming Webhook Signatures in Node.js
Safely verify payload integrity before mutating external database records or triggering hardware actions.
verify_webhook.tsNode.js
import crypto from 'crypto';
export function verifyBrazzaSignature(rawBody: string, signatureHeader: string, secret: string): boolean {
const parts = signatureHeader.split(',');
const timestamp = parts.find(p => p.startsWith('t='))?.split('=')[1];
const signature = parts.find(p => p.startsWith('v1='))?.split('=')[1];
if (!timestamp || !signature) return false;
const signedPayload = `${timestamp}.${rawBody}`;
const expectedHash = crypto
.createHmac('sha256', secret)
.update(signedPayload)
.digest('hex');
return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expectedHash));
}