Welcome to the next phase of the HealthHub evolution. In this hands-on project, I expanded the serverless capabilities of our healthcare platform to include Artificial Intelligence. I architected and deployed a complete serverless healthcare application on AWS designed to solve a critical problem: language barriers in patient care.🛠️ 2. Project Description and ObjectiveThis project implements a scalable, serverless architecture on AWS to convert medical information into natural speech across multiple languages. The Objective is to deploy a full-stack application (Frontend and Backend) where medical notes entered in English are automatically translated and converted into audio files for patients.Key Features of this Deployment:Multi-language Support: Powered by Amazon Translate to process me…
Welcome to the next phase of the HealthHub evolution. In this hands-on project, I expanded the serverless capabilities of our healthcare platform to include Artificial Intelligence. I architected and deployed a complete serverless healthcare application on AWS designed to solve a critical problem: language barriers in patient care.🛠️ 2. Project Description and ObjectiveThis project implements a scalable, serverless architecture on AWS to convert medical information into natural speech across multiple languages. The Objective is to deploy a full-stack application (Frontend and Backend) where medical notes entered in English are automatically translated and converted into audio files for patients.Key Features of this Deployment:Multi-language Support: Powered by Amazon Translate to process medical text.Natural Voice Generation: Powered by Amazon Polly to convert text into lifelike speech.Serverless Backend: Using AWS Lambda to orchestrate AI flows without managing servers.Secure Storage & Authentication: Using Amazon S3, DynamoDB, and Amazon Cognito to securely manage patient records and generated audio assets.🧱 3. Architecture DiagramBelow is the architecture designed for this solution. It leverages event-driven triggers to process data in real-time. Amazon Cognito secures access for Doctors and Patients. Hosted on S3, allowing users to input data. Amazon API Gateway routes requests to the backend. AWS Lambda triggers Translate and Polly to generate audio. DynamoDB stores metadata; S3 holds the generated audio files.🧭 4. Step-by-Step Implementation WalkthroughPrerequisites : Creating IAM Role and EC2 instanceCreate IAM role with Use Case: EC2Permission: AdministratorAccess2. Create a EC2 Workstation (EC2), SSH connection and open the web based terminal (Ec2 insance connect)AMI: Amazon Linux 2023 AMISSH Key: we do not need to create key pair as we will be using Ec2 instant connect but you can create a key key, save the private key in your local computer folder and form a ssh connectionIAM instance profile: associate this instance profile with the role created: tcb-hh-role3. Check the tools and services currently available in Ec2 using the commands below:aws –versionnode -vserverless –versionWe need to install Node.js (and NPM)and Serverless on our Amazon EC2 workstationNPM (Node Package Manager): This allows us to manage project dependencies and install the multiple versions of Node.js and switch between them. Node.js helps us to execute JavaScript on the server side.Serverless: serverless allows us to define infrastructure as code (IAC) and serverless yaml shows services to be deployed. Serveless.yml file would be used to define the Lambda functions and DynamoDB tables.# Download and run the NVM installation script from GitHub using curl and bashcurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash# Reload the shell configuration file to apply changes made by the NVM installersource ~/.bashrc# Use NVM to download and install the latest Long-Term Support version of Node.jsnvm install –lts# Run a Node.js command that prints the message along with the current Node.js versionnode -e “console.log(’Executando Node.js ’ + process.version)“npm -v# Install Serverless Framework version 3 globally using npmnpm install -g serverless@3# Display the installed version of the Serverless Framework using the ‘serverless’ commandserverless –versionStep 01: HealthHub Backend ImplementationDownloading and Unzipping Project Files# 1. Downloads the project source code zip file from the AWS S3 bucketwget https://tcb-bootcamps.s3.us-east-1.amazonaws.com/aicloud-bootcamp/v1/module4/healthhub-module-4.zip# 2. Extracts the contents of the downloaded zip fileunzip healthhub-module-4.zip# 3. Navigates into the newly extracted project directorycd healthhub-module-4/# 4. Lists the files in the current directory to verify contentsls# 5. Navigates specifically into the backend application foldercd health-hub-backend/# 6. Displays the file that defines the project’s Node.js dependencies and scriptscat package.json# 7. Displays the Serverless Framework configuration file (infrastructure definitions)cat serverless-compose.yml # 9. Visualizes the folder structure of the ‘src’ directory (up to 3 levels deep)tree -L 3 src/# 10. Downloads and installs all the Node.js dependencies listed in package.jsonnpm install (It’ll take about ~ 2 minutes)Installing Dependencies For Each Service’s Project:# 1. Displays the dependencies specific to the ‘doctor-service’ microservicecat src/services/doctor-service/package.json# 2. Loops through every service folder in ‘src/services/’, enters each one, and installs its dependenciesfor service in src/services/*; do (cd “$service” && npm install) doneBefore we execute our deployment commands, let’s verify the current state of our AWS account. We want to ensure our environment is clean to clearly see the resources the Serverless Framework will create for us later.Go to the AWS Console and check the following services: Ensure no existing User Pools related to HealthHub exist. Check for existing roles; the list should be standard/empty of project-specific roles. The dashboard should be empty of APIs. No tables named Patients, Doctors, or Appointments should exist yet. Verify no project-specific buckets are present. Log groups should be minimal. No functions should be listed in the region you are deploying to.Run the commands below to deploy:# 1. Executes the deployment script defined in package.json npm run deploy# 2. Displays the complete log file from the deployment process for detailed reviewcat .serverless/compose.log# 3. Filters the log file to immediately show only lines containing “error” (case-insensitive)cat .serverless/compose.log | grep -i errorWe can also check for errors in CloudWatch | Log groupsIf error on any service deployment process, you can try re-deploy it by running the following command:# 4. If we run into errors, we can deploy services individually# Deploying service individuallyserverless deploy –stage dev –service service-name# Example for a service name “ai-interaction-service“serverless deploy –stage dev –service ai-interaction-serviceStep 2: Validating AWS Service’s CreatedAfter we run the “deploy” command, we can open CloudFormation stack and check the deployment status.If you check your logs and deployment was successful and you don’t see the stacks in cloud formation, it is almost certainly due to one of two reasons: or .When the deployment is complete, we can use the AWS Management Console to verify that our infrastructure was provisioned correctly.Access the following services to confirm creation: Check for the stack ( hh- ) to see the deployment status.AWS Lambda | Function: hh-ai-interaction-dev-getInteraction Verify the User Pool and App Client were created. Confirm that new roles for Lambda execution are present. Look for the HTTP/REST API endpoints. Ensure the Patients, Doctors, and Appointments tables exist. Check for the deployment bucket used by the Serverless Framework. Verify log groups are created for your Lambda functions. Confirm your backend functions are listed and active.Make sure you verify that the following services listed above have been deployedStep 3: HealthHub Frontend ImplementationWe are going to install the frontend project dependencies via CLI using the commands below:# 1. Navigates specifically into the backend application foldercd ../health-hub-frontend# 2. Displays the file that defines the project’s Node.js dependencies and scriptscat package.json# 3. Visualizes the folder structure of the ‘src’ directory (up to 3 levels deep)tree -L 3 src/# 4. package and dependencies managernpm installGetting Your API Base URL:Defining the API Base URL for VITE:Vite is a frontend project build tool designed to offer a faster and lighter development experience for modern web projects.# 1. Visualizes the folder structure of the ‘src’ directory (up to 3 levels deep)tree -L 3 src/# Long listing of files including hidden filesls -la# Creates a new .env configuration file from the example template and immediately opens it in the nano editor to set the API Base URL for Vitecp .env.example .env && nano .envThe API gateway acts as the brain functioning as router endpoint and main entry point. We need to add the API URL to the env file which stores the application input endpoint.Step 4: Running HealthHub Serverless Applicationuse this command line below to get your EC2 Workstation Instance Public IP Address and run the healthub serveless application:# Make sure you are in the frontend directory# get the public ip from console directly or use the command below in cliaws ec2 describe-instances | grep -i PublicIpAddress #Renames the Tailwind configuration file from JavaScript (.js) to CommonJS (.cjs). This is required because our project runs as an ES Module, but this config file uses CommonJS syntaxmv tailwind.config.js tailwind.config.cjs#Starts the development server and exposes it to the public network# The “– –host” flag allows external access so you can view the app via your EC2 Public IP# Running HealthHub Serverless Application: npm run dev – –hostStep 5: Accessing HealthHub Serverless ApplicationIn order to access this app I need to release this port on AWS EC2Before accessing the application, we must allow traffic to reach the Vite development server running on port 5173. By default, the Security Group only allows SSH (port 22).Go to the AWS Console > EC2 > Security Groups The Security Group attached to our EC2 workstation, “Edit inbound rules” > “Add rule” 0.0.0.0/0 (Anywhere-IPv4)With the port now open, look at your terminal. You will likely see an output indicating the server is running locally:Press enter or click to view image in full sizeCopy the of the EC2 instance (which we retrieved in the previous step via the CLI or AWS Console).Replace localhost with that Public IP in your browser’s address bar.Your final URL should look like this: http://<YOUR_EC2_PUBLIC_IP>:5173Browsers often try to force “Secure” connections so we need to make sure is being used and NOT . For this demonstration, we are accessing the application directly via the EC2 Public IP using . In a production environment, best practice requires using to encrypt data in transit. However, SSL certificates are typically issued to Domain Names (e.g., healthhub.com), not raw IP addresses. To keep this guide focused on the application architecture, we are bypassing the domain setup and using standard HTTP.We have now successfully accessed the web app.Step 6: Adding a Doctor and a PatientWe are going to test the application and add sample records below using the register button:Date of Birth: 01/01/1990Specialization: RadiologyLicense Number: A407B56431Email: Jermima.bells@gmail.comDate of Birth: 01/01/2005Step 7: Testing Healthub AI speech FeatureLogin in as the doctor and we are going to use the AI speech feature we just added to healthhub.We can monitor the amazon translate metrics using cloudwatchAmazon CloudWatch | Log groups: /aws/lambda/hh-ai-interaction-dev-textToSpeechHealthHub has been deployed and is working correctly with the audio genereated by AWS AI speech featureStep 8: Removing Resources CreatedThe final and one of the most important step is to clean up our account and delete resources used to prevent unwanted costs and billing.Empty S3 Bucket: hh-dev-xxxxxxxxxxxx-ai-interactionGo to folder health-hub-backendsls remove or serverless removehh-user-dev must be remove manually!!Delete All File: rm -rf * We deployed a complex microservices backend (Users, Appointments, Doctors, Patients, and ) without manually clicking through the console for every resource.AI-Powered Accessibility: We integrated and to automatically translate medical instructions and convert them into natural, lifelike speech, breaking down language barriers for patients. We connected a modern React frontend (Vite) to a serverless backend via API Gateway, handling real-world challenges like CORS and Environment Variables. We implemented a robust login system using , ensuring that sensitive patient and doctor data remains secure while accessing AI features. We verified the system end-to-end by registering a doctor, creating a patient account, booking an appointment, and successfully generating multi-lingual audio instructions in real-time.6. Services and Technologies Used (Overview & Explanation) A cloud service that converts text into lifelike speech. We used Polly to take the translated medical instructions and generate high-quality audio files, making the information accessible to patients who may have difficulty reading or prefer auditory learning. A neural machine translation service that delivers fast, high-quality, and affordable language translation. This was the core of our accessibility feature. It allowed us to input medical notes in English and instantly translate them into the patient’s native language before converting them to speech. A serverless compute service that runs code in response to events. Lambda acted as the “brain” of our AI operations. It received the text from the frontend, sent it to Translate, passed the result to Polly, and then saved the reference to DynamoDB. A service that handles user identity and authentication. It managed the security roles, ensuring that only registered doctors could input medical notes and only authorized patients could access their private health records. Object storage built to retrieve any amount of data from anywhere. S3 was used to host our frontend assets and, crucially, to store the audio files generated by Amazon Polly so they could be streamed to the patient’s device. A fully managed NoSQL database service. We used DynamoDB to store the structured medical records, including the links to the translation audio files and patient metadata.📚 7. References & Resources