Back to projects

Case Study - Q3 2025

Invoice Reminders

AI-Powered Invoice Payment Automation

AWSGCPAzureMulti-Tenant SaaSAI AgentsRAGEvent-DrivenServerless

The Problem

Freelancers and small businesses lose an estimated 10-15% of revenue to late or missed invoice payments. Manual follow-ups are time-consuming, inconsistent, and often damage client relationships. A fintech client needed a SaaS platform that automates invoice payment reminders with intelligent scheduling, multi-channel notifications, and AI-driven personalization - while maintaining financial-grade security and audit compliance.

Solution Overview

The platform is a multi-tenant SaaS application that ingests invoices, applies AI to determine optimal reminder timing and tone, and delivers automated payment reminders across email, SMS, and WhatsApp. The system includes a RAG-based conversational interface for querying invoice status and a multi-agent workflow for escalation handling.

Cloud Architecture Comparison

The same platform architected three ways. Each cloud brings different strengths to AI agent orchestration, event-driven processing, and multi-tenant security. There is no single best choice - the right answer depends on the customer's existing ecosystem, compliance requirements, and team expertise.

AWS Architecture

CLIENT LAYERReact / Next.js SPACloudFront CDNS3 Static HostingAPI GATEWAYAPI GatewayREST + OpenAPI 3.0CognitoOAuth2 / OIDC + MFACOMPUTELambdaFastAPI via MangumECS FargateAI Agent OrchestratorAI / MLBedrockClaude 3.5 + T…OpenSearchVector Store f…LangGraphMulti-Agent Wo…EVENT BUSEventBridgeCron SchedulingSQS / SNSQueues + Fan-o…SES + PinpointEmail / SMS / …DATAAurora PostgreSQLMulti-tenant + RLSElastiCacheRedis Cache + SessionsS3Invoice PDF StorageSECURITYKMSEnvelope Encryp…IAMLeast PrivilegeVPCPrivate SubnetsOBSERVABILITYCloudWatchMetrics + AlarmsX-RayDistributed Tra…CloudTrailAudit LoggingHTTPS

AI and Agent Layer

Amazon Bedrock (Claude 3.5 / Titan)

Powers reminder tone personalization and invoice summarization. Bedrock's managed LLM access eliminates infrastructure overhead for model hosting. Claude handles nuanced, empathetic reminder generation; Titan handles embeddings for the RAG pipeline.

Amazon OpenSearch Service (Serverless)

Vector store for RAG. Stores embedded invoice data, payment history, and client communication preferences. Enables semantic search over invoice corpus for the conversational query interface.

LangGraph on ECS Fargate

Orchestrates the multi-agent workflow - Agent 1 determines reminder urgency, Agent 2 selects channel and tone, Agent 3 handles escalation paths. LangGraph's state machine model maps naturally to the payment reminder lifecycle.

Application Layer

AWS Lambda + Mangum

Stateless API endpoints for invoice CRUD, payment status checks, and tenant management. Mangum wraps FastAPI for Lambda compatibility. Cost-effective for bursty SaaS traffic patterns.

ECS Fargate

Long-running AI agent orchestration tasks that exceed Lambda's 15-min timeout. Auto-scales based on queue depth.

Event-Driven Architecture

Amazon EventBridge

Cron-based scheduling for reminder dispatch. Rules engine triggers reminder workflows based on invoice due dates, payment status changes, and configurable escalation timers.

Amazon SQS

Decouples reminder generation from notification delivery. Dead-letter queues capture failed deliveries for retry. FIFO queues ensure ordered processing per invoice.

Amazon SNS

Fan-out pattern for multi-channel notifications. Single publish triggers parallel delivery across email (SES), SMS (SNS), and WhatsApp (Pinpoint).

Data Layer

Aurora PostgreSQL (Serverless v2)

Multi-tenant invoice data with row-level security. Serverless v2 auto-scales capacity based on load - critical for SaaS with variable tenant activity. Supports Text-to-SQL queries via the RAG interface.

ElastiCache Redis

Session management, API response caching, and rate-limiting counters. Reduces database load for frequently accessed invoice status checks.

S3

Invoice PDF storage with lifecycle policies. Server-side encryption (SSE-S3) for data at rest. Pre-signed URLs for secure client access.

Security

Amazon Cognito

Multi-tenant OAuth2/OIDC authentication with user pools per tenant. Supports social login and MFA. Issues short-lived JWT tokens (1hr expiry) with custom claims for tenant isolation.

AWS KMS

Envelope encryption for PII fields (client emails, phone numbers, payment details). Customer-managed keys (CMK) for tenant data isolation.

IAM

Least-privilege policies for all Lambda functions and ECS tasks. Service-linked roles with no wildcard permissions.

VPC

Private subnets for Aurora and ElastiCache. VPC endpoints for S3, SQS, and Bedrock to keep traffic off the public internet.

Observability

CloudWatch Metrics

Custom metrics for reminder delivery rates, AI response latency, and payment conversion rates. Composite alarms for SLA monitoring.

AWS X-Ray

End-to-end distributed tracing from API Gateway through Lambda/ECS to downstream services. Trace sampling at 5% for cost management.

CloudTrail

Immutable audit log for all API calls. Critical for fintech compliance - who accessed what invoice data and when.

OpenTelemetry

Instrumented in application code, exported to CloudWatch via the ADOT collector. Provides vendor-neutral telemetry alongside native AWS tracing.

Cost Optimization

ComponentStrategyEst. Monthly
LambdaPay-per-invocation, right-sized memory$50-150
ECS FargateSpot capacity for non-critical agents$100-300
Aurora Serverless v2Auto-scales to zero in low traffic$80-200
BedrockPay-per-token, prompt caching$200-500
OpenSearch ServerlessOCU-based scaling$150-300
EventBridge + SQS + SNSPay-per-event (negligible)$10-30
Total (estimated)$590-1,480/mo

Why AWS

1.LangGraph on ECS Fargate provides the most flexible agent orchestration - full control over state machine transitions, checkpointing, and human-in-the-loop patterns for escalation workflows.
2.Bedrock offers the widest model selection (Claude, Titan, Llama, Mistral) - easy to A/B test different models for reminder generation without changing infrastructure.
3.EventBridge's rules engine is the most expressive for complex scheduling logic - supports content-based filtering, input transformation, and multi-target fan-out from a single rule.
4.SageMaker integration path for training custom payment prediction models on tenant data when the volume justifies it.

Lessons Learned

Lambda cold starts matter for AI workloads - Provisioned concurrency for the RAG query endpoint eliminated P99 latency spikes from 8s to 1.2s.

Bedrock token costs add up - Implemented prompt caching and response streaming to reduce Claude API costs by 40%.

EventBridge scheduling precision - Sub-minute scheduling required a combination of EventBridge rules and SQS delay queues for fine-grained reminder timing.

Multi-tenancy in Aurora - Row-level security (RLS) policies per tenant proved more maintainable than schema-per-tenant at this scale.

Key Metrics and Outcomes

99.7-99.8%

Reminder Delivery Rate

Queue retry + DLQ across all clouds

< 2s

AI Response Latency (P95)

Reminder generation with streaming

+25-35%

Payment Recovery

Increase in on-time payments

Zero leakage

Multi-Tenant Isolation

Verified via penetration testing

99.95%

Uptime SLA

HA database + multi-region compute

$530-1,480/mo

Cost Per Tenant

Varies by cloud and scale

This case study reflects a production system designed and built for a fintech client. Architecture decisions were driven by cost efficiency, security compliance, and the need for intelligent, AI-driven automation at scale.

Disclaimer

The final production architecture for this client cannot be disclosed in full due to NDA obligations. The three cloud variants presented above are reference architectures that illustrate the design approach and decision-making process. At a high level, the actual deployment leveraged a combination of AWS and Azure services, selected based on the client's existing infrastructure and compliance requirements.