Lexi uses Single-table design with DynamoDB:
# List all tables
aws dynamodb list-tables --region <REGION>
# Describe table in detail
aws dynamodb describe-table \
--table-name <TABLE_NAME> \
--region <REGION>
Result will include:
Partition Key (PK): Entity type + ID
USER#<user_id>
FLASHCARD#<flashcard_id>
SESSION#<session_id>
SCENARIO#<scenario_id>
Sort Key (SK): Timestamp or entity type
CREATED#2026-05-02T10:30:00Z
UPDATED#2026-05-02T10:30:00Z
METADATA#<type>
# Scan table (retrieve items)
aws dynamodb scan \
--table-name <TABLE_NAME> \
--region <REGION> \
--limit 10
# Scan with filter
aws dynamodb scan \
--table-name <TABLE_NAME> \
--filter-expression "attribute_exists(#pk)" \
--expression-attribute-names '{"#pk":"PK"}' \
--region <REGION>
# Query with partition key
aws dynamodb query \
--table-name <TABLE_NAME> \
--key-condition-expression "PK = :pk" \
--expression-attribute-values '{":pk":{"S":"USER#<user_id>"}}' \
--region <REGION>
# Query with partition key + sort key
aws dynamodb query \
--table-name <TABLE_NAME> \
--key-condition-expression "PK = :pk AND begins_with(SK, :sk)" \
--expression-attribute-values '{":pk":{"S":"USER#<user_id>"},":sk":{"S":"CREATED"}}' \
--region <REGION>
# Add item to table
aws dynamodb put-item \
--table-name <TABLE_NAME> \
--item '{
"PK": {"S": "USER#123"},
"SK": {"S": "CREATED#2026-05-02T10:30:00Z"},
"email": {"S": "user@example.com"},
"name": {"S": "John Doe"}
}' \
--region <REGION>
# Get item from table
aws dynamodb get-item \
--table-name <TABLE_NAME> \
--key '{
"PK": {"S": "USER#123"},
"SK": {"S": "CREATED#2026-05-02T10:30:00Z"}
}' \
--region <REGION>
# Update item
aws dynamodb update-item \
--table-name <TABLE_NAME> \
--key '{
"PK": {"S": "USER#123"},
"SK": {"S": "CREATED#2026-05-02T10:30:00Z"}
}' \
--update-expression "SET #name = :name" \
--expression-attribute-names '{"#name":"name"}' \
--expression-attribute-values '{":name":{"S":"Jane Doe"}}' \
--region <REGION>
# Delete item
aws dynamodb delete-item \
--table-name <TABLE_NAME> \
--key '{
"PK": {"S": "USER#123"},
"SK": {"S": "CREATED#2026-05-02T10:30:00Z"}
}' \
--region <REGION>
# View read capacity
aws cloudwatch get-metric-statistics \
--namespace AWS/DynamoDB \
--metric-name ConsumedReadCapacityUnits \
--start-time 2026-05-01T00:00:00Z \
--end-time 2026-05-02T00:00:00Z \
--period 3600 \
--statistics Sum \
--region <REGION>
# View write capacity
aws cloudwatch get-metric-statistics \
--namespace AWS/DynamoDB \
--metric-name ConsumedWriteCapacityUnits \
--start-time 2026-05-01T00:00:00Z \
--end-time 2026-05-02T00:00:00Z \
--period 3600 \
--statistics Sum \
--region <REGION>
# View user errors
aws cloudwatch get-metric-statistics \
--namespace AWS/DynamoDB \
--metric-name UserErrors \
--start-time 2026-05-01T00:00:00Z \
--end-time 2026-05-02T00:00:00Z \
--period 3600 \
--statistics Sum \
--region <REGION>
# Create backup
aws dynamodb create-backup \
--table-name <TABLE_NAME> \
--backup-name lexi-backup-2026-05-02 \
--region <REGION>
# List backups
aws dynamodb list-backups \
--table-name <TABLE_NAME> \
--region <REGION>
# Restore from backup
aws dynamodb restore-table-from-backup \
--target-table-name <NEW_TABLE_NAME> \
--backup-arn <BACKUP_ARN> \
--region <REGION>
Issue: Access denied
# Check IAM role
aws iam get-role-policy \
--role-name <LAMBDA_ROLE> \
--policy-name <POLICY_NAME>
Issue: Table does not exist
# Check table status
aws dynamodb describe-table \
--table-name <TABLE_NAME> \
--region <REGION>
Issue: Too many items
# Delete old items
aws dynamodb scan \
--table-name <TABLE_NAME> \
--filter-expression "attribute_exists(#pk)" \
--region <REGION>
Continue to API Gateway to learn how to configure API endpoints.