Paatam: Enterprise AI SaaS & Cloud Infra
Architected the full enterprise backend and cloud infrastructure from High-Level Design (HLD) to production deployment. Features a 4-tier tenant hierarchy, 153 live REST endpoints, zero-trust RBAC across 5 roles, and a decoupled serverless AI grading pipeline.
Synchronous Bottlenecks in AI Exam Evaluation
In educational institutions, grading multi-page handwritten student exam sheets is subject to sudden, extreme traffic spikes. When 35 teachers simultaneously upload classroom exam bundles (averaging 35 multi-page PDF scripts each), synchronous HTTP processing caused:
- HTTP 504 Gateway Timeouts while waiting for external OCR and LLM grading APIs
- Database connection starvation in PostgreSQL due to hundreds of open connection holds
- Orphaned jobs and unrecoverable silent data loss upon transient network interruptions
Architecture & Data Flow
Data isolation strictly follows Corporate ➔ Branch ➔ Class ➔ Section governed by zero-trust RBAC middleware across 5 roles (Super Admin, Corporate Admin, Branch Admin, Teacher, Student). Sequential database IDs are replaced with Sonyflake 64-bit distributed IDs to prevent enumeration attacks and guarantee future horizontal sharding capability.
Deployed in AWS ap-south-2 via Terraform. ECS Fargate containers run in private subnets with NAT Gateway routing. Amazon RDS Proxy sits before PostgreSQL 16, multiplexing thousands of incoming connections into a stable connection pool to eliminate exhaustion.
Multi-stage asynchronous pipeline: Direct S3 presigned URL uploads trigger SQS queues (ocr-queue, eval-queue) with 15-minute visibility timeouts. Dedicated Dead-Letter Queues (DLQs) retain failed messages for 14 days.
An Amazon EventBridge cron trigger runs every 15 minutes, waking a Sweeper Lambda function to query Postgres for orphaned jobs stuck in-flight and automatically re-enqueue them idempotently.
Paatam Request & Pipeline Canvas
AWS WAF + ALB
Terminates HTTPS traffic via AWS ACM certificates in ap-south-2. Rate limits abuse (max 2,000 req/5m) and forwards traffic across private ECS target groups.
- TLS 1.3 Termination
- Cross-zone load balancing
- HTTP/2 enabled
- Target health checks :3000/health
resource "aws_lb" "main" {
name = "paatam-prod-alb"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.alb.id]
subnets = aws_subnet.public[*].id
enable_deletion_protection = true
}Core Terraform Modules
# RDS Proxy Configuration for Paatam SaaS
resource "aws_db_proxy" "postgres" {
name = "paatam-rds-proxy"
debug_logging = false
engine_family = "POSTGRESQL"
idle_client_timeout = 120
require_tls = true
role_arn = aws_iam_role.rds_proxy.arn
vpc_security_group_ids = [aws_security_group.rds_proxy.id]
vpc_subnet_ids = aws_subnet.isolated_db[*].id
auth {
auth_scheme = "SECRETS"
description = "PostgreSQL 16 master credentials"
iam_auth = "DISABLED"
secret_arn = aws_secretsmanager_secret.db_credentials.arn
}
}
resource "aws_db_proxy_default_target_group" "target_group" {
db_proxy_name = aws_db_proxy.postgres.name
connection_pool_config {
connection_borrow_timeout = 120
max_connections_percent = 90
max_idle_connections_percent = 50
}
}