
Building a GenAI Learning App on Amazon ECS
Hands-on lessons from deploying an AI learning app with ECS, Bedrock, and DynamoDB.
Building a GenAI Learning App on Amazon ECS
Introduction
I recently completed the AWS SimuLearn: Generative AI App for Teaching and Learning hands-on lab on AWS Skill Builder.
This was one of the most interesting and challenging labs in my AWS learning journey because it combined generative AI, containerized applications, Amazon ECS, Amazon DynamoDB, and automated learning feedback into a single solution.
In my previous labs, I explored Amazon Bedrock, prompt engineering, RAG, AI agents, and fine-tuning.
This time, I learned how to deploy a containerized educational application that uses multiple foundation models to help teachers create assignments and students improve their answers.
Here are my key takeaways.
1. Understanding the Business Scenario
The goal was to create a generative AI-powered educational application for teachers and students.
Traditionally, teachers spend significant time preparing assignments, writing questions, evaluating answers, and providing personalized feedback.
The proposed solution uses generative AI to automate parts of this workflow.
Teachers can:
- Generate questions and answers from educational content.
- Interact with an AI tutor to test the learning experience.
- Save assignments for future use.
- Review generated questions and tutoring conversations.
Students can:
- Select an assignment.
- Submit answers to questions.
- Receive automatically generated similarity scores.
- Get suggestions for improving grammar and sentence structure.
The application demonstrates how generative AI can assist educators while providing students with immediate learning support.
2. Exploring the Solution Architecture
The application combines several AWS services.
AWS Service | Responsibility |
|---|---|
Amazon ECS | Runs the containerized application |
Amazon ECR | Stores the application's Docker image |
Application Load Balancer | Routes incoming requests to the application |
Amazon Bedrock | Provides access to foundation models |
Amazon DynamoDB | Stores assignments, answers, and scores |
Amazon EC2 | Provides a development environment for deployment tasks |
The application itself is developed using Python and Streamlit.
The architecture follows this workflow:
Teachers / Students → Application Load Balancer → Amazon ECS → Amazon Bedrock / DynamoDB
I found it helpful to separate the system into three layers:
- Application layer: Streamlit provides the user interface.
- Compute layer: Amazon ECS runs the application inside a container.
- AI and data layer: Amazon Bedrock generates AI responses, while DynamoDB stores application data.
This separation makes the architecture easier to understand and maintain.
3. Deploying a Containerized Application with ECS and ECR
One of the most valuable parts of the lab was working with Amazon ECS and Amazon ECR.
Unlike several of my previous AWS labs that used Lambda as the application backend, this solution runs a containerized application on Amazon ECS.
The deployment workflow involved:
- Working with the application's Python source code and Docker configuration.
- Using a container image stored in Amazon ECR.
- Configuring an ECS task definition.
- Updating the application configuration, including the foundation model ID.
- Deploying the application through an ECS service.
- Accessing the application through an Application Load Balancer.
I also explored AWS Systems Manager Session Manager to connect securely to the EC2 development environment without manually managing SSH access.
One important concept I learned was the distinction between ECS and ECR:
Amazon ECR stores the container image, while Amazon ECS runs containers created from that image.
The Application Load Balancer provides an entry point for users accessing the running application.
4. Generating Assignments with Amazon Bedrock
The application contains a Python page named:
1_Create_Assignments.py This page allows teachers to enter educational content and generate questions and answers using a foundation model on Amazon Bedrock.
The application uses the Boto3 Converse API:
bedrock_client.converse() The prompt asks the model to generate five questions and answers based on the input material and return them in a structured JSON format.
This demonstrated how generative AI can help transform reading materials into reusable teaching resources.
I also explored the Tutoring Feedback Loop, which uses conversation history to support multi-turn interactions.
Instead of treating every message independently, the application maintains the conversation context so the AI tutor can provide relevant follow-up questions and hints.
After generating an assignment, the application stores its information in Amazon DynamoDB.
5. Managing Assignments with DynamoDB
The second application page is:
2_Show_Assignments.py Its responsibility is to retrieve and display assignments stored in DynamoDB.
The application uses Boto3 to interact with the database:
boto3.resource("dynamodb") Assignments are stored in the
assignments table.Each assignment can include:
- An assignment ID.
- The original learning material.
- Generated questions and answers.
- A tutoring conversation transcript.
The application retrieves this information and displays it through Streamlit.
This helped me understand how DynamoDB can support a generative AI application by storing structured records independently of the model inference process.
6. Evaluating Student Answers with Embeddings
This was one of my favorite technical concepts in the lab.
The third application page is:
3_Complete_Assignments.py Students select an assignment, choose a question, and enter their answers.
Instead of comparing the student's answer with the reference answer using exact text matching, the application uses Amazon Titan Text Embeddings V2.
The model converts both answers into numerical vectors.
The application then calculates cosine distance between the vectors and converts the result into a similarity-based score.
The workflow looks like this:
Reference Answer → Titan Embeddings → Vector A
Student Answer → Titan Embeddings → Vector B
Vector A + Vector B → Cosine Similarity → Score
This approach allows the application to recognize similarities in meaning even when students use different words.
However, an important lesson is that semantic similarity is not the same as factual correctness.
Two answers can have similar meanings while differing in important factual details. Therefore, similarity-based scores should be treated as learning signals rather than definitive academic grades.
7. Generating Personalized Learning Feedback
The application also integrates a Mistral foundation model through Amazon Bedrock to help students improve their English.
The code provides two feedback capabilities:
Grammar improvement
The model reviews the student's answer and suggests corrections to grammatical errors.
Sentence improvement
The model rewrites the student's answer using alternative words and sentence structures while attempting to preserve the original meaning.
The application also uses DynamoDB to store student responses and their highest recorded scores.
This helped me see how multiple AI models can be used for different tasks within one application.
- A generative model creates assignments.
- An embedding model evaluates semantic similarity.
- Another generative model provides language improvement suggestions.
Instead of relying on one model for everything, the application selects different AI capabilities based on the task.
8. Exploring Bedrock Guardrails
The lab also introduced a DIY challenge involving Amazon Bedrock Guardrails.
The objective was to extend the tutoring feedback loop with a denied-topic policy that could block inappropriate content.
The application code supports attaching a Guardrail to a Converse API request through
guardrailConfig .This illustrated an important concept:
A conversational AI application needs more than a capable foundation model. It also needs policies that help control inappropriate interactions.
For real-world educational applications, safeguards and human oversight are important, especially when students rely on AI-generated feedback.
9. Key Lessons Learned
This lab reinforced several important concepts.
1. ECS and ECR serve different purposes.
ECR stores container images, while ECS orchestrates the running application containers.
2. Generative AI applications can combine multiple models.
The same application can use one model for content generation, another for embeddings, and another for language improvement.
3. Embeddings enable semantic comparison.
Converting text into vectors makes it possible to evaluate similarity beyond exact word matching.
4. DynamoDB provides persistent application storage.
Assignments, conversation transcripts, student answers, and scores can be stored separately from the AI inference process.
5. Container deployment introduces operational considerations.
Application configuration, task definitions, container images, networking, and IAM permissions all play a role in deployment.
6. AI-generated educational feedback requires evaluation.
A working application does not guarantee that every generated question, score, or suggestion is correct.
10. Final Thoughts
Completing this lab helped me better understand how to combine generative AI with containerized cloud applications.
Previously, I focused on invoking foundation models, building RAG systems, and customizing LLMs.
This time, I explored how to deploy an AI-powered application using Amazon ECS, connect it to DynamoDB, and integrate multiple foundation models through Amazon Bedrock.
My biggest takeaway is:
Building a useful generative AI application is not just about calling a model. It is about combining application development, container deployment, data storage, and specialized AI capabilities into a complete system.
For future exploration, I would like to experiment with automated deployments using CI/CD, improve student answer evaluation, and add authentication and more comprehensive monitoring.
This was another valuable step in my AWS learning journey!
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article