AWS Builder Center
Architecting Modern Web Applications: Connecting Angular & React to AWS Serverless (S3 + Lambda + API Gateway)

Architecting Modern Web Applications: Connecting Angular & React to AWS Serverless (S3 + Lambda + API Gateway)

Architecting Modern Web Applications: Connecting Angular & React to AWS Serverless (S3 + Lambda + API Gateway)

Software engineering student
Hi everyone!
When developing client-side applications (whether using Angular, React, or Vue), hosting and scaling the backend architecture efficiently is key to maintaining performance and keeping infrastructure costs low.
In traditional setups, running a dedicated Virtual Machine (like EC2) 24/7 for small or medium traffic can be cost-inefficient. A Serverless approach solves this by charging only for actual execution time.
Here is a breakdown of how a production-ready Web App architecture works on AWS:



1. Frontend Hosting with Amazon S3 & CloudFront

Instead of running a web server to deliver HTML, JS, and CSS files, you can build your single-page app ( ng build  or  npm run build ) and upload the static assets to Amazon S3.
  • Amazon S3: Stores static build assets securely.
  • Amazon CloudFront: Acts as a Content Delivery Network (CDN) to serve static files globally with low latency and HTTPS protection.

2. Decoupled Backend with API Gateway & AWS Lambda

Instead of a monolithic Express or Spring Boot server running continuously, APIs are triggered on-demand:
  • Amazon API Gateway: Handles incoming REST API requests from the frontend, routing them securely.
  • AWS Lambda: Executes business logic in response to requests (Node.js, Python, or Java) and scales automatically to zero when idle.
Here is a simple example of an AWS Lambda handler written in Node.js processing a request:
export const handler = async (event) => {
const requestData = JSON.parse(event.body || '{}');
// Business logic processing
const responseBody = {
message: "Data processed successfully",
received: requestData,
timestamp: new Date().toISOString()
};

return {
statusCode: 200,
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*" // Handle CORS for Frontend
},
body: JSON.stringify(responseBody)
};
};


3. Key Benefits of This Architecture

  1. Cost Efficiency: You pay zero dollars when no traffic hits the Lambda functions.
  1. Auto-scaling: API Gateway and Lambda automatically handle concurrent spikes without manual intervention.
  1. Decoupled Security: IAM policies isolate permissions between S3, API Gateway, and database layers.
What architecture patterns are you currently using to deploy your frontend and backend projects on AWS? Let's discuss in the comments!
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article