-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
This guide will walk you through setting up the UF r/place project on your local machine and deploying it to AWS.
Before you begin, make sure you have:
- Node.js 18 or higher - Download from nodejs.org
- npm (comes with Node.js)
- Git - Download from git-scm.com
- AWS Account with proper permissions - See the AWS Configuration Guide for detailed setup instructions
- AWS CLI configured - Follow the AWS Configuration Guide for installation and setup
# Check Node.js version (should be 18+)
node --version
# Check npm version
npm --version
# Check Git
git --version
# Check AWS CLI
aws --versiongit clone https://github.com/ufosc/UF_r-place.git
cd UF_r-place# Install all dependencies for both workspaces
npm installThis will install dependencies for:
- Root workspace (build scripts)
-
infra/workspace (CDK and infrastructure dependencies) -
web/workspace (Next.js and frontend dependencies)
Important: Before proceeding, follow the AWS Configuration Guide to:
- Set up your AWS account and credentials
- Ensure you have the required permissions for CDK deployment
- Configure AWS CLI or environment variables
Once configured, verify your setup:
aws sts get-caller-identitySet the required CDK environment variables (see AWS Configuration Guide for details):
# Set your AWS account ID and region
export CDK_ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
export CDK_REGION=$(aws configure get region)
# Verify they're set correctly
echo "Account: $CDK_ACCOUNT, Region: $CDK_REGION"This is a one-time setup per AWS account and region:
npm run cdk:bootstrapIf you see an error about unable to resolve AWS account, make sure you've completed step 4 above.
npm run cdk:deployThis will:
- Build the TypeScript infrastructure code
- Create AWS resources (Lambda function, API Gateway)
- Deploy your stack to AWS
- Output the API URL when complete
Important: Save the ApiUrl output from this command - you'll need it in the next step.
Create the environment file for the frontend:
# Replace <ApiUrl> with the URL from the previous step
echo "NEXT_PUBLIC_API_URL=<paste-api-url-here>" > web/.env.localExample:
echo "NEXT_PUBLIC_API_URL=https://abc123def4.execute-api.us-east-1.amazonaws.com/prod/" > web/.env.localnpm run devThis starts the Next.js development server at http://localhost:3000
- Open your browser to http://localhost:3000
- You should see "UF r/place" as the heading
- Below it should display "API says: Hello from UF r/place API!"
If you see an error message instead, check:
- The API URL in
web/.env.localis correct and ends with/ - The backend deployment completed successfully
- Your AWS credentials are still valid
-
Modify Lambda functions in
infra/lambda/ -
Update infrastructure in
infra/lib/ -
Deploy changes:
npm run cdk:deploy
-
Modify components in
web/app/ -
Changes are automatically hot-reloaded when running
npm run dev -
For production builds:
npm run build
From the root directory:
# Development
npm run dev # Start frontend dev server
npm run build # Build both frontend and backend
npm run lint # Run linting
# Deployment
npm run deploy # Deploy backend infrastructure
npm run cdk:deploy # Same as above
npm run cdk:bootstrap # Bootstrap CDK (one-time setup)From individual workspaces:
# Backend (from infra/ directory)
npm run build # Compile TypeScript
npm run synth # Generate CloudFormation templates
npm run deploy # Deploy to AWS
npm run destroy # Remove all AWS resources
# Frontend (from web/ directory)
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLintUF_r-place/
├── package.json # Root workspace & scripts
├── infra/ # AWS Infrastructure
│ ├── bin/app.ts # CDK app entry point
│ ├── lib/ # Infrastructure definitions
│ ├── lambda/ # Lambda function code
│ └── cdk.out/ # Generated CloudFormation (git-ignored)
└── web/ # Next.js Frontend
├── app/ # App Router pages & components
├── .env.local # Environment variables (git-ignored)
└── .next/ # Next.js build output (git-ignored)
This means CDK couldn't determine your AWS account/region. See the AWS Configuration Guide for detailed troubleshooting. Quick check:
- Verify AWS credentials:
aws sts get-caller-identity - Set CDK environment variables:
export CDK_ACCOUNT=... CDK_REGION=...
- Ensure the URL in
web/.env.localends with/ - Check that the backend deployment completed successfully
- Verify the API Gateway was created in the AWS console
You need to create web/.env.local with the API URL from step 7.
Check the AWS Configuration Guide for detailed troubleshooting steps. Common issues include:
- Missing required AWS permissions (see the permissions section)
- CDK environment variables not set correctly
- AWS credentials not configured properly
When you're done experimenting or want to clean up AWS resources to avoid any potential costs:
# Remove all project resources (recommended)
npm run destroy
# Alternative command (same effect)
npm run cdk:destroyThis will delete:
- Lambda functions
- API Gateway
- CloudWatch log groups
- IAM roles created for the project
- The entire CloudFormation stack (
UfRPlaceBackend)
If you want to remove everything including CDK bootstrap resources:
# 1. First destroy project resources
npm run destroy
# 2. Then remove CDK bootstrap stack (only if you won't use CDK again)
aws cloudformation delete-stack --stack-name CDKToolkit
# 3. Verify cleanup
aws cloudformation list-stacks --stack-status-filter CREATE_COMPLETENote: The CDK bootstrap resources (CDKToolkit stack) cost ~$0.02/month and can be reused for other CDK projects.
To check what resources remain:
# Check CloudFormation stacks
aws cloudformation list-stacks --stack-status-filter CREATE_COMPLETE
# Check Lambda functions
aws lambda list-functions --query 'Functions[?starts_with(FunctionName, `UfRPlace`)].FunctionName'For detailed cleanup instructions, see the AWS Configuration Guide.
Once you have the basic setup working:
- Review AWS configuration - Check the AWS Configuration Guide for security best practices and production setup
- Explore the code - Check out the Project Overview for architecture details
- Add new features - See the Extensibility Guide
- Deploy to production - Consider setting up CI/CD pipelines
- Check the AWS Configuration Guide for detailed AWS setup
- Review the Extensibility Guide for adding new features
- Look at the existing code in
infra/andweb/directories - Check AWS CloudWatch logs for Lambda function errors
- Use
npm run synthto see generated CloudFormation templates