This repo is the foundation for a technical interview/project.
Given a data set, calculate a Z-Score. This repo uses the following formula:
Z=(((X/M)^L) – 1)/LS
* This formula assumes L is > 0. You could expand this logic to handle L = 0 with a different forumla.
This is a fully functioning API Gateway + Lambda Function + DynamoDB project.
- The endpoint expects 3 query parameters
agemos
,sex
,head_circumference
- Once the endpoint is hit, it will retrieve the values for M, L and S from the DynamoDB
- L, M, S and the
head_circumference
value will be used to calculate the Z-Score - The response will look like:
Z Score calculation was successful!
Data retrieved from DB for Z Score: {
"Sex": {
"S": "1"
},
"L": {
"N": "1.424084853"
},
"M": {
"N": "48.72064621"
},
"S": {
"N": "0.029242207"
},
"P25": {
"N": "47.75563267"
},
"Agemos": {
"S": "24.5"
}
}
Your query params were {
"agemos": "24.5",
"sex": "1",
"head_circumference": "50"
}
The Z Score is 0.0007721242974448446
This started out as a standard TypeScript repo with a function and tests (like this one)...but I pivoted and decided to focus on the logistics of creating a project with AWS tools. I've created lambdas based projects before, but handed them off to a DevOps team and focused exclusively on the logic of the lambda.
Getting an understanding of the "Infrastructure as Code" in the CdkZCalcServerlessStack.ts
class made the concept very approachable.
The cdk watch
command (which hotswaps your lamda function changes as you make them) is amazing.
- A fully functioning test suite
- I'd focus much more on error handling (The pre-generated code that AWS tutorials provide have extensive examples of error messaging logic.)
- I'd remove anything that reveals implementation details from the response objects
- I'd create a security policy for the endpoint
- Decide to use a DB is one option, another option would be to load your CSV Data into an AWS bucket and parse it
- Creating the DB Schema in this repo so that it's a 100% functioning project
- You could iterate on the lambda to calculate other Z Scores.
- You could iterate on the lambda to calculate Z Scores with the alternate formula.
- You could create an additional call type to retrieve a data set from the DB for plotting.
Creating a graphing app for this data.
- You could use a new API call that would return the data, based on gender.
- You'd use that response to plot your ranges.
- You'd need an array of measurements to plot over those ranges.
- You could use the Z Score call to show the Z Score on hover. (Assuming that's something people would want to see)
- This project was created with AWS's CDK
- Marcia Villalba's videos can get you started with CDK
- I created DynamoDB table using the AWS NoSQL Workbench, therefore you can't use this project "as is" without creating an identical table
- This project has been successfully deployed
This is a project for CDK development with TypeScript.
The cdk.json
file tells the CDK Toolkit how to execute your app.
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testscdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template