Skip to content

Notes from the lab

Cloud-Native AI built RESTful application launched via ECS Fargate

Published
Filed under Blog

Project Overview

I recently designed and implemented a production-grade RESTful API service using Spring Boot and AWS cloud infrastructure, leveraging AI-assisted development practices. This microservice manages authors and their books, demonstrating modern cloud-native application development practices, Infrastructure as Code (IaC) principles, and effective AI tool utilization.

AWS Architecture of the RESTful Springboot Application

Technical Highlights

Backend Development

  • Developed a Spring Boot 3.x REST API using Java 17
  • Implemented JPA/Hibernate for database operations
  • Utilized Lombok for reduced boilerplate code
  • Built with Maven for dependency management and building
  • Containerized using Docker with multi-stage builds
  • Automated setup and troubleshooting via Terraform and Bash script

Cloud Infrastructure

AWS Services Utilized:

  • ECS (Elastic Container Service) with Fargate for serverless container orchestration
  • RDS (Relational Database Service) for MySQL database management
  • Application Load Balancer for traffic distribution
  • ECR (Elastic Container Registry) for container image management
  • CloudWatch for monitoring and logging
  • VPC with public and private subnets across multiple AZs
  • S3 Bucket for storing Terraform state file and DynamoDB for storing Terraform Lock file
$ ./scripts/setup-aws.sh prod
Setting up AWS infrastructure for environment: prod
Creating S3 bucket: terraform-state-author-books-prod
{
"Location": "http://terraform-state-author-books-prod.s3.amazonaws.com/"
}

Waiting for bucket to be created...
Enabling bucket versioning...
Enabling bucket encryption...
Blocking public access...
Creating DynamoDB table: terraform-state-lock-prod
{
"Table": {
"AttributeDefinitions": [
{
"AttributeName": "LockID",
"AttributeType": "S"
}
],
"TableName": "terraform-state-lock-prod",
"KeySchema": [
{
"AttributeName": "LockID",
"KeyType": "HASH"
}
],
"TableStatus": "ACTIVE",
"CreationDateTime": "2024-11-10T11:34:09.441000-06:00",
"ProvisionedThroughput": {
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 1,
"WriteCapacityUnits": 1
},
"TableSizeBytes": 0,
"ItemCount": 0,
"TableArn": "arn:aws:dynamodb:us-west-2:954976283848:table/terraform-state-lock-prod",
"TableId": "752b33fb-4b73-4748-8bfb-2f6364016171",
"DeletionProtectionEnabled": false
}
}

DynamoDB table terraform-state-lock-prod already exists
Creating backend configuration...
AWS infrastructure setup complete!
Created/Updated:
- S3 Bucket: terraform-state-author-books-prod
- DynamoDB Table: terraform-state-lock-prod
- Backend Config: /c/Users/mtand/Projects/Dev/Java/springboot/authors-api-deployed-in-aws/terraform/environments/prod/backend.tfvars
Dev and Prod S3 buckets for managing Terraform state file
Dev and Prod DynamoDB tables for managing Terraform Lock file

Infrastructure as Code

  • Complete infrastructure defined using Terraform
  • Modular architecture with separate modules for
  • – Networking (VPC, subnets, route tables)
  • – Security (IAM roles, security groups)
  • – Container orchestration (ECS, ALB)
  • – Database (RDS)
Output of AWS resources created via Terraform
Pushed the Springboot app image to ECR

AI-Assisted Development

AI Prompt Engineering:

  • Leveraged Claude AI for architecture design and best practices
  • Utilized AI-assisted code generation and optimization
  • Implemented AI-driven infrastructure design patterns
  • Employed systematic prompt engineering for complex technical solutions
  • Used AI tools for code review and improvement suggestions

Architecture Highlights

High Availability:

Multi-AZ deployment with redundancy

As instance becomes unhealthy ECS Fargate automatically replace the instance with new instance

Security:

  • Network segregation with public and private subnets
  • Least-privilege IAM roles
  • Security groups for granular access control

Scalability:

  • Auto-scaling capabilities with ECS
  • Load balancing across multiple availability zones
AWS Application Load Balancer
EC2 Target groups

Maintainability:

  • Infrastructure as Code and bash script for reproducible deployments
  • Containerization for consistent environments
  • Modular Terraform configuration for easier maintenance

Key Features

  • RESTful CRUD operations for authors and books
  • Relational data model with JPA/Hibernate
  • Automated infrastructure deployment
  • Production-ready configuration
  • Comprehensive error handling
  • Cloud-native design principles

Technical Skills Demonstrated

Development:

  • Java 17
  • Spring Boot 3.x
  • Docker
  • Terraform
  • REST API Design
  • Database Design

Cloud & Infrastructure:

  • AWS Services (ECS, RDS, ECR, VPC, IAM)
  • Infrastructure as Code
  • Microservices Architecture
  • Cloud Architecture
  • Security Best Practices
ECS Cluster with two running task launched via Fargate
AWS Load Balancer
Application image that was pushed to ECR
The MySQL RDS database instance in AWS
Created tables and inserted initial data into RDS database instance was SQL client

AI & Automation:

  • AI Prompt Engineering
  • Large Language Model Integration
  • AI-Assisted Code Development
  • AI-Driven Architecture Design
  • Systematic Prompt Construction
  • AI Tool Optimization

Development Practices

  • Infrastructure as Code (IaC)
  • Containerization
  • CI/CD readiness
  • Cloud-native design
  • Security-first approach
  • High availability patterns
  • Scalable architecture
  • AI-augmented development workflow

AI Integration Highlights

Prompt Engineering Excellence:

  • Crafted precise, contextual prompts for optimal AI assistance
  • Developed structured approaches to complex technical problems
  • Leveraged AI for architecture validation and improvement
  • Used AI tools for code optimization and best practices
  • Implemented AI-assisted documentation generation

Development Efficiency:

  • Reduced development time through effective AI tool usage
  • Improved code quality with AI-driven suggestions
  • Enhanced architecture decisions with AI-assisted analysis
  • Streamlined documentation process using AI tools
  • Accelerated problem-solving through AI collaboration

This project demonstrates proficiency in modern cloud application development, from backend programming to infrastructure automation, while showcasing the effective use of AI tools and prompt engineering for enhanced development efficiency. The combination of traditional development skills with AI-assisted methodologies represents a forward-thinking approach to software development.

Impact and Results

  • Reduced development time by leveraging AI-assisted coding
  • Improved code quality through AI-driven reviews and suggestions
  • Enhanced architecture design through AI-assisted planning
  • Accelerated infrastructure deployment using AI-optimized templates
  • Streamlined development workflow with AI tool integration

This hybrid approach of traditional software development skills combined with AI prompt engineering capabilities represents the future of software development, where AI tools are effectively leveraged to enhance productivity and quality while maintaining robust engineering practices.

Successful GET Request returns all books and author details
Successful POST Requests to add an author
Newly created Author added to the author table in the backend MySQL DB
Cloudwatch log monitoring
Detailed CloudWatch Log monitoring
CloudWatch application log monitoring
Destroyed all the resources created on AWS via Terraform

I posted the project code to Github, you can find it here : https://github.com/aggrey-aggrey/springboot-restapi-built-with-claudeai-running-on-aws-ecs-fargate