```html

Building a Multi-Tenant Executive Reporting System: AWS Lambda, SES, and Real-Time Dashboard Integration

Over the past development session, we built and deployed a comprehensive executive reporting infrastructure across four distinct business entities (JADA, QueenofSanDiego, QuickDumpNow, and DangerousCentaur), integrated with AWS SES for delivery and a real-time dashboard backend. This post covers the architecture decisions, deployment patterns, and technical implementation details.

What Was Done

We created a multi-stakeholder reporting system that generates five specialized executive reports from distinct perspectives:

  • CEO perspective — Asset inventory, revenue gaps, and 30-day prioritized actions
  • CTO perspective — Stack audit, security hardening roadmap, cost optimization
  • Accounting perspective — Revenue recognition, chart of accounts, profitability pathway
  • CMO perspective — Channel strategy, OTA deployment sequencing, blast campaign ROI modeling
  • CFO perspective — Burn rate modeling, capital deployment framework, monthly revenue targets

Reports were generated as formatted text, sent via AWS SES to designated recipients with BCC archive, and corresponding tasks were created on a Kanban-style progress dashboard.

Technical Architecture

Report Generation Pipeline

The core report generation lives in /Users/cb/Documents/repos/tools/send_exec_reports.py. This script:

  • Loads environment variables from repos.env for SES credentials and verified sender addresses
  • Reads project handoff documents from /Users/cb/Documents/repos/agent_handoffs/projects/ (e.g., shipcaptaincrew.md, project-specific files)
  • Generates role-specific narrative reports with structured sections (KPIs, shortfalls, action items)
  • Formats reports as plain-text email bodies for maximum deliverability
  • Batches SES send operations to avoid API throttling

A secondary version, send_exec_reports_2.py, exists for parallel testing and A/B variations.

AWS SES Integration

Reports are delivered through AWS SES with the following configuration:

  • Verified sender: admin@queenofsandiego.com (configured in AWS SES console)
  • Primary recipient: c.b.ladd@gmail.com
  • BCC archive: admin@queenofsandiego.com for audit trail
  • Rate limiting: 5 reports sent with 100ms delays between API calls to stay well below the 14 emails/second SES limit

SES variables are read from environment configuration to support multi-environment deployments (dev, staging, production). The script validates that required variables exist before attempting sends:

AWS_SES_REGION = os.getenv('AWS_SES_REGION', 'us-west-2')
SES_FROM_ADDRESS = os.getenv('SES_FROM_ADDRESS', 'admin@queenofsandiego.com')

Dashboard Backend Integration

Corresponding tasks are created on a progress dashboard via direct HTTP requests. For each report, we POST task metadata including:

  • Report title and executive role
  • Generated timestamp
  • Status flags (pending, in-review, completed)
  • Deep links to specific action items

The dashboard backend is a Lambda function deployed at /Users/cb/Documents/repos/sites/queenofsandiego.com/tools/ (varies by tenant), with DynamoDB as the persistent store for task state.

Lambda and Frontend Deployment for Ship Captain Crew

During this session, the Ship Captain Crew tool (a booking and crew management system for QueenofSanDiego) received multiple rounds of updates:

Lambda Function Updates

File: /Users/cb/Documents/repos/sites/queenofsandiego.com/tools/shipcaptaincrew/lambda_function.py

Key improvements deployed:

  • Event checklist lifecycle — Added create_event(), load_checklist(), and timing hook functions for departure/return events
  • JWT authentication — Implemented stateless token generation and validation using JWT_SECRET from Lambda environment variables
  • Magic link auth — Added /magic-auth endpoint that accepts short codes stored in DynamoDB, validates them, and returns JWT tokens
  • Role assignment and claiming — Implemented role state machine: guest → claimed role → captain/crew with designation and release endpoints
  • Guest waiver flow — Integrated on_hold logic to pause guest confirmations pending waiver completion
  • Email integration — Added claim notification emails via SES with magic links for role acceptance

The Lambda was syntax-checked using Python's AST parser before each deployment to catch runtime errors early:

python -m py_compile lambda_function.py

Deployment involved zipping the function and uploading via AWS CLI:

zip -r lambda_function.zip lambda_function.py
aws lambda update-function-code \
  --function-name shipcaptaincrew \
  --zip-file fileb://lambda_function.zip \
  --region us-west-2

Frontend Updates

File: /Users/cb/Documents/repos/sites/queenofsandiego.com/tools/shipcaptaincrew/frontend/index.html

Frontend enhancements included:

  • Timing panel — Displays event departure and return times with sunset calculation for San Diego location
  • Checklist modal — Renders task list with completion tracking, calls loadChecklist() on page load
  • Role claim UI — Modal dialog for accepting captain or crew roles with JWT token submission
  • Waiver page — Shows waiver acceptance form and integrates with on_hold guest state

Frontend was deployed to S3 and CloudFront invalidated for immediate cache refresh:

aws s3 cp index.html \
  s3://queenofsandiego-shipcaptaincrew-frontend/index.html \
  --cache-control "max-age=3600"

aws cloudfront create-invalidation \
  --distribution-id E[DISTRIBUTION_ID] \
  --paths "/*"

Key Infrastructure Decisions

Why AWS SES Over Third-Party Services?

SES is 100x cheaper than SendGrid or Mailgun at scale (~$0.10 per 1,000 emails), and we already have AWS credentials. However, it requires pre-verified sender addresses and has stricter rate limits. We mitigated this by