This reference architecture builds on my AWS cloud architecture experience and explores secure, reusable infrastructure for enterprise generative AI workloads.
The objective was to move beyond standalone model invocation and explore how AI capabilities could be integrated into an enterprise application environment, with emphasis on private networking, workload identity, authentication, and a reusable application pattern.
The lending domain was selected as an illustrative use case to demonstrate both Retrieval-Augmented Generation (RAG) and general-purpose foundation-model inference.
Browser requests pass through the Next.js frontend and Backend for Frontend (BFF), then through scoped API authorization and private VPC connectivity to FastAPI workloads on private EKS nodes.
01
Sign in
The Next.js BFF handles Cognito OAuth 2.0 Authorization Code with PKCE and maintains an encrypted, HTTP-only session.
02
Forward request
The browser calls the BFF, which forwards the session access token to API Gateway.
03
Authorize
API Gateway validates the Cognito token and the scope required by the selected use case.
04
Connect privately
VPC Link V2 routes API traffic to an internal NLB and the FastAPI service on private EKS nodes.
05
Run use case
FastAPI validates the request and invokes the matching application workflow.
06
Generate or retrieve
Bedrock Converse generates responses; Policy Q&A first retrieves relevant Knowledge Base passages.
Architectural Decisions
Decision
Engineering rationale
Next.js frontend and BFF
Handle the OAuth code exchange, encrypted browser session, and server-side API forwarding.
Cognito + API Gateway scopes
Authenticate users and enforce distinct OAuth scopes at the API boundary.
VPC Link V2 + internal NLB
Connect API Gateway privately to the Kubernetes-managed application service.
Private EKS + Pod Identity
Run the FastAPI workload without embedding long-lived AWS credentials in containers.
Bedrock Converse + Knowledge Bases
Share model inference while supporting retrieval-backed policy answers.
Amazon S3 Vectors
Provide the vector store used by the Bedrock Knowledge Base in the lab.
GitHub Actions validation
Run repository checks and secret scanning; the workflow does not deploy AWS infrastructure.
Single-replica lab workload
Keep the temporary POC cost-conscious; this is not an availability design.
Two Implemented and Validated Use Cases
Foundation-model inference
Application Summary
Accepts validated, synthetic financial application data and uses Amazon Bedrock Converse to produce a natural-language summary. Pydantic request models validate fields such as income, debt, missed payments, requested amount, and optional credit score.
This is not an automated lending decision or credit-scoring system.
Retrieval-augmented generation
Lending Policy Q&A
Retrieves up to five passages from a Bedrock Knowledge Base, then uses Bedrock Converse to answer questions with source references. The workflow instructs the model to treat retrieved passages as untrusted reference data and acknowledge when evidence is insufficient.
Citation correctness and claim-level grounding are not independently verified.
POC Validation Evidence
Anonymous requests to protected API Gateway endpoints were rejected with HTTP 401.
Authenticated Application Summary and Policy Q&A requests returned HTTP 200 in the lab.
Policy Q&A returned generated answers with source references from the sample policy knowledge base.
Both use cases ran through API Gateway, VPC Link V2, the internal NLB, private EKS, and the relevant Bedrock service.
OAuth scope isolation between protected use cases was validated using machine-client tests. The Cognito User Pool was recreated afterward; the existing validation was considered sufficient for this POC, so the test was not repeated.
These are functional POC checks, not a formal security assessment, performance benchmark, or AI quality certification.
Key Architecture Decisions
Decision
Engineering rationale
Next.js frontend and BFF
Handle the OAuth code exchange, encrypted browser session, and server-side API forwarding.
Cognito + API Gateway scopes
Authenticate users and enforce distinct OAuth scopes at the API boundary.
VPC Link V2 + internal NLB
Connect API Gateway privately to the Kubernetes-managed application service.
Private EKS + Pod Identity
Run the FastAPI workload without embedding long-lived AWS credentials in containers.
Bedrock Converse + Knowledge Bases
Share model inference while supporting retrieval-backed policy answers.
Amazon S3 Vectors
Provide the vector store used by the Bedrock Knowledge Base in the lab.
GitHub Actions validation
Run repository checks and secret scanning; the workflow does not deploy AWS infrastructure.
Single-replica lab workload
Keep the temporary POC cost-conscious; this is not an availability design.
Implementation Status
POC complete
Implemented and exercised in a temporary AWS lab
Application Summary and Lending Policy Q&A implemented as separate API use cases
Cognito login and per-use-case OAuth scope enforcement validated in the lab
Private API Gateway → VPC Link V2 → internal NLB → EKS request path exercised
Bedrock Converse and Knowledge Base retrieval exercised by the use cases
Python test suite and repository validation workflow included in the source repository
Terraform modules and Kubernetes manifests document the lab infrastructure
Planned, not implemented
Production-hardening roadmap
Application-level authorization, tenant-aware RAG, and document access controls
Tighter network boundaries and TLS for private integrations
Multiple replicas, autoscaling, and recovery mechanisms
Operational observability, tracing, alerts, and cost attribution
AI governance, guardrails, and stronger prompt-injection defenses
Retrieval, groundedness, and citation evaluation
Container, frontend, and infrastructure delivery checks
The lab used a single application replica, a 29-second API Gateway integration timeout, and an HTTP private integration to the NLB. The AWS application infrastructure was decommissioned after validation to limit cost; this page describes the implemented reference, not a currently running service or production-ready lending system.