This guide covers setting up both local and production databases for the Lunch Buddy application.
- Podman installed and running
- Node.js and npm installed
-
Start the local DynamoDB container:
podman run -p 8000:8000 amazon/dynamodb-local
-
Create the local tables:
cd backend NODE_ENV=development node scripts/setup-dynamodb.js
The local setup will create four tables:
LunchBuddyRegistrationsLunchBuddyMatchHistoryLunchBuddyLocationsLunchBuddyMatchSchedule
- AWS account with DynamoDB access
- AWS IAM user with appropriate permissions
- AWS credentials configured
Create an IAM user with the following permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:CreateTable",
"dynamodb:PutItem",
"dynamodb:GetItem",
"dynamodb:DeleteItem",
"dynamodb:Scan",
"dynamodb:Query"
],
"Resource": "arn:aws:dynamodb:*:*:table/*"
}
]
}Set the following environment variables in your production environment:
AWS_REGION=your-region # e.g., us-east-1
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
DYNAMODB_TABLE_PREFIX=your-prefix # Optional, for environment separation- Set up your AWS credentials in the environment
- Run the setup script:
cd backend NODE_ENV=production DYNAMODB_TABLE_PREFIX=prod_ node scripts/setup-dynamodb.js
This will create four tables in your production DynamoDB:
{prefix}LunchBuddyRegistrations{prefix}LunchBuddyMatchHistory{prefix}LunchBuddyLocations{prefix}LunchBuddyMatchSchedule
- Table Name:
{prefix}LunchBuddyRegistrations - Primary Key:
userId(String) - Attributes:
name(String)email(String)department(String)location(String)preferences(String, JSON serialized)createdAt(String, ISO date)updatedAt(String, ISO date)
- Table Name:
{prefix}LunchBuddyMatchHistory - Primary Key:
matchId(String) - Attributes:
date(String, ISO date)location(String)matches(String, JSON serialized)
- Table Name:
{prefix}LunchBuddyLocations - Primary Key:
locationId(String) - Attributes:
name(String) - Display name of the locationcustomMessage(String, optional) - Custom notification message template for this locationcreatedAt(String, ISO date) - When the location was createdupdatedAt(String, ISO date) - When the location was last modified (added when customMessage is updated)
- Table Name:
{prefix}LunchBuddyMatchSchedule - Primary Key:
id(String) - Attributes:
date(String, ISO date)
The application supports customizable notification messages for each location:
🎉 You've been matched for lunch in {location} with {buddyName}!
Common available days: {commonDays}
Email: {buddyEmail}
Reach out to schedule your lunch! 🍽️
{location}- Name of the location where the match was made{buddyName}- Name of the matched lunch buddy{buddyEmail}- Email address of the matched lunch buddy{commonDays}- Comma-separated list of days both participants are available
- Custom messages are stored in the
customMessagefield of the Locations table - If
customMessageisnullor empty, the default template is used - Template variables are replaced at notification send time
# AWS Configuration
AWS_REGION=your-region
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
# Optional
DYNAMODB_TABLE_PREFIX=your-prefixFor local development, no AWS credentials are needed. The application will automatically use the local DynamoDB instance.
- Create initial locations:
cd backend
node scripts/create-initial-locations.js- Verify location setup:
node scripts/verify-locations.js- Locations can be managed through the admin interface
- Each location must have a designated site leader
- Location data is used for:
- Participant registration
- Match generation
- Statistics tracking
When adding location support to an existing deployment:
- Update table schemas
- Run migration scripts
- Verify data integrity
- Update application configuration
-
Table Creation Fails
- Check AWS credentials
- Verify IAM permissions
- Check if table already exists
-
Connection Issues
- Verify AWS region
- Check network connectivity
- Verify DynamoDB service status
-
Permission Errors
- Review IAM permissions
- Check AWS credentials
- Verify resource ARNs
-
Enable AWS SDK logging:
export AWS_SDK_LOAD_CONFIG=1 export AWS_SDK_LOG_LEVEL=debug
-
Check AWS CloudWatch logs for DynamoDB operations
For additional support:
- Check AWS DynamoDB documentation
- Review application logs
- Contact system administrator