WorkOutly is a fitness and workout management application Powered by IOS HealthKit and Integrated with Android Health Connect that leverages AWS services for backend infrastructure. This document guides you through configuring AWS components like DynamoDB, Lambda, API Gateway, S3, and CloudFront for both REST API and WebSocket functionalities.
- Kotlin Multiplatform Health Integration:
- iOS: Powered by HealthKit.
- Android: Integrated with Health Connect.
- Workout Tracking: Log and track your workouts in real time.
- Steps and Activity Monitoring: Monitor daily step counts and activity trends.
- Health Analytics: Visualize key health metrics such as calories burned, heart rate, and more.
- Customizable Goals: Set personal fitness goals and track progress.
- User-Friendly Interface: A clean and simple design focused on usability.
- AWS-Backed Architecture:
- DynamoDB: For storing user video exercises and live session chat.
- AWS Lambda: For serverless computation and real-time data processing.
- API Gateway REST API and WebSocket: To provide secure and scalable communication between the app and backend.
- CloudFront and S3: For fast and reliable content delivery and static asset hosting.
- An AWS account.
- AWS CLI installed and configured.
- Basic knowledge of AWS services.
- Create a DynamoDB Table:
- Go to the DynamoDB service in the AWS Management Console.
- Click
Create table
and provide the following details:- Table name:
WorkOutlyTable
- Primary key:
id (String)
- Table name:
- Enable on-demand or provisioned capacity as per your application's needs.
- Add Additional Attributes:
- Add attributes like
userId
,workoutDetails
,timestamp
, etc., based on your application's data model.
- Add attributes like
- Use AWS SDK (e.g., boto3 for Python, AWS SDK for JavaScript) to interact with the table programmatically.
- Create a Lambda Function:
- Go to the Lambda service and click
Create function
. - Select
Author from scratch
and provide:- Function name:
WorkOutlyFunction
- Runtime: Choose your preferred runtime (e.g., Node.js, Python, Java).
- Function name:
- Go to the Lambda service and click
- Add Permissions:
- Attach a role with the following policies:
AmazonDynamoDBFullAccess
CloudWatchLogsFullAccess
- Attach a role with the following policies:
- Deploy Code:
- Upload your code zip or use an inline editor.
- Ensure the code has necessary SDK calls to DynamoDB and any other required services.
- Create a REST API:
- Go to API Gateway and click
Create API
>REST API
. - Choose
New API
and provide an API name.
- Go to API Gateway and click
- Define Resources and Methods:
- Add resources (e.g.,
/workouts
,/users
). - Add HTTP methods (e.g., GET, POST, PUT, DELETE) to each resource.
- Add resources (e.g.,
- Integrate with Lambda:
- Choose
Lambda Function
as the integration type. - Link the created Lambda function.
- Choose
- Deploy API:
- Create a deployment stage (e.g.,
dev
,prod
).
- Create a deployment stage (e.g.,
- Create a WebSocket API:
- Choose
WebSocket API
and provide:- WebSocket name.
- Routes like
$connect
,$disconnect
,broadcast
.
- Choose
- Integrate with Lambda:
- Attach Lambda functions to the WebSocket routes.
- Deploy WebSocket API:
- Deploy the API and note the WebSocket URL.
- Create an S3 Bucket:
- Go to S3 and click
Create bucket
. - Provide a bucket name (e.g.,
workoutly-static-assets
). - Enable public access if necessary for static content.
- Go to S3 and click
- Upload Files:
- Upload your static web files (e.g., HTML, CSS, JavaScript).
- Configure Bucket Policy:
- Add a policy to allow public read access for static assets (optional).
- Create a CloudFront Distribution:
- Go to CloudFront and click
Create Distribution
. - Choose
Web
as the delivery method. - Set the origin domain name to your S3 bucket.
- Configure caching and SSL/TLS settings.
- Go to CloudFront and click
- Link Domain (Optional):
- Use Route 53 or another DNS provider to map a custom domain to the CloudFront distribution.
- Use versioning in S3 for better content management.
- Leverage invalidation in CloudFront to update cached content.
- Enable HealthKit in Your Project:
- Go to your Xcode project settings.
- Under
Signing & Capabilities
, click+ Capability
and addHealthKit
.
- Request Permissions:
- Use
HKHealthStore
to request permissions to read/write health data.
- Use
- Access Health Data:
- Use
HKSampleQuery
or other HealthKit queries to retrieve data like steps, heart rate, or workouts.
- Use
- Add Health Connect Dependency:
- Include the Health Connect API in your
build.gradle
:implementation "androidx.health.connect:health-connect-client:<latest_version>"
- Include the Health Connect API in your
- Request Permissions:
- Use
HealthPermissions
to request user consent for accessing health data.
- Use
- Access Health Data:
- Use
HealthConnectClient
to read or write health and fitness data.
- Use