CodePlayground is a modern, cloud-native code execution platform that enables developers to write, execute, and share code snippets in real-time. Built with Next.js, Spring Boot, and deployed on AWS infrastructure.
- π₯οΈ Real-time Code Editor - Monaco-based editor with syntax highlighting
- β‘ Code Execution - Execute JavaScript, Python, and Java code safely
- π Code Management - Save, organize, and manage code snippets
- π Code Sharing - Share code snippets with unique URLs
- π Multi-language Support - JavaScript, Python, Java support
- π± Responsive Design - Works on desktop and mobile devices
- π Secure Execution - Containerized code execution environment
- βοΈ Cloud-Native - Deployed on AWS with auto-scaling
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Next.js App β β Spring Boot β β PostgreSQL β
β (Frontend) ββββββ (Backend) ββββββ (Database) β
β Port: 3000 β β Port: 8080 β β Port: 5432 β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
β
βββββββββββββββββ
β AWS Load β
β Balancer β
βββββββββββββββββ
- Next.js 14 - React framework with App Router
- TypeScript - Type-safe JavaScript
- Tailwind CSS - Utility-first CSS framework
- Monaco Editor - VSCode-like code editor
- Zustand - Lightweight state management
- Spring Boot 3 - Java enterprise framework
- Spring Data JPA - Data persistence layer
- PostgreSQL - Relational database
- Docker - Containerization
- AWS ECS - Container orchestration
- AWS ALB - Application Load Balancer
- AWS RDS - Managed PostgreSQL
- AWS ECR - Container registry
- Terraform - Infrastructure as Code
- AWS CLI configured with appropriate permissions
- Docker installed and running
- Terraform 1.5+ installed
- Node.js 20+ and npm
- Java 17+ and Gradle
git clone <repository-url>
cd code-playground-
Update configuration file:
cp deploy/terraform.tfvars.example deploy/terraform.tfvars # Edit deploy/terraform.tfvars with your settings -
Required changes in
deploy/terraform.tfvars:- Replace
YOUR_ACCOUNT_IDwith your AWS account ID - Replace
YOUR_REGIONwith your preferred AWS region - Change
CHANGE_ME_TO_SECURE_PASSWORDto a secure database password - Change
CHANGE_ME_TO_SECURE_JWT_SECRETto a secure JWT secret
- Replace
Option A: One-click Deployment (Recommended)
./deploy.shOption B: Step-by-Step Deployment
# 1. Build and push images
./deploy.sh --build-only
# 2. Deploy infrastructure
./deploy.sh --infra-only# Start all services with Docker Compose
docker-compose up -d
# Access the application
open http://localhost:3000code-playground/
βββ apps/
β βββ frontend/ # Next.js application
β β βββ src/
β β β βββ app/ # App Router pages
β β β βββ components/ # React components
β β β βββ store/ # State management
β β β βββ types/ # TypeScript types
β β βββ Dockerfile # Frontend container
β β βββ package.json # Dependencies
β β
β βββ backend/ # Spring Boot application
β βββ src/main/java/ # Java source code
β β βββ controller/ # REST controllers
β β βββ service/ # Business logic
β β βββ entity/ # JPA entities
β β βββ repository/ # Data repositories
β βββ Dockerfile # Backend container
β βββ build.gradle # Dependencies
β
βββ deploy/ # Infrastructure code
β βββ terraform.tfvars # Configuration file
β βββ main.tf # Main Terraform configuration
β βββ variables.tf # Variable definitions
β βββ ecs-resources.tf # ECS resources
β
βββ k8s/ # Kubernetes manifests (alternative)
βββ monitoring/ # Monitoring configurations
βββ docker-compose.yml # Local development
βββ deploy.sh # Deployment script
βββ README.md # This file
Frontend:
Environment variables are configured in next.config.js with default values:
NEXT_PUBLIC_API_BASE_URL: Defaulthttp://localhost:8080/api/v1NEXT_PUBLIC_APP_NAME: DefaultCode Playground
Override these during Docker build if needed using --build-arg.
Backend (apps/backend/application.yml):
spring:
datasource:
url: jdbc:postgresql://localhost:5432/codeplayground
username: codeplayground_admin
password: your-password
jpa:
hibernate:
ddl-auto: updateKey settings in deploy/terraform.tfvars:
aws_region- AWS deployment regionbackend_image- Backend Docker image URLfrontend_image- Frontend Docker image URLdatabase_password- PostgreSQL passwordjwt_secret- JWT signing secret
The platform includes comprehensive monitoring:
- Application Metrics - Custom Spring Boot metrics
- Infrastructure Monitoring - AWS CloudWatch integration
- Log Aggregation - Centralized logging with ELK stack
- Health Checks - Application and infrastructure health monitoring
Access monitoring dashboards:
# Grafana Dashboard
open http://<alb-dns>/grafana
# Application Logs
aws logs tail /ecs/code-playground --follow# Frontend tests
cd apps/frontend
npm test
# Backend tests
cd apps/backend
./gradlew test
# E2E tests
cd e2e
npm test# Load testing with k6
cd performance
./run-performance-tests.sh- Authentication - JWT-based authentication
- Authorization - Role-based access control
- Code Execution - Sandboxed execution environment
- Data Protection - Encrypted data in transit and at rest
- Network Security - VPC with private subnets
- Compliance - Follows AWS security best practices
# Deploy new version alongside current
terraform apply -var="deployment_strategy=blue-green"
# Switch traffic to new version
terraform apply -var="active_deployment=green"# Gradual deployment with zero downtime
aws ecs update-service --service code-playground-frontend --force-new-deployment# ECS Service Auto Scaling
resource "aws_appautoscaling_target" "ecs_target" {
max_capacity = 10
min_capacity = 2
resource_id = "service/${aws_ecs_cluster.main.name}/${aws_ecs_service.app.name}"
scalable_dimension = "ecs:service:DesiredCount"
service_namespace = "ecs"
}# Scale frontend service
aws ecs update-service --service code-playground-frontend --desired-count 3
# Scale backend service
aws ecs update-service --service code-playground-backend --desired-count 51. Deployment Fails
# Check Terraform state
terraform refresh
terraform plan
# Verify AWS credentials
aws sts get-caller-identity2. Application Not Accessible
# Check ECS service status
aws ecs describe-services --services code-playground-frontend
# Check load balancer health
aws elbv2 describe-target-health --target-group-arn <target-group-arn>3. Database Connection Issues
# Check RDS instance status
aws rds describe-db-instances --db-instance-identifier code-playground-db
# Test database connectivity
psql -h <rds-endpoint> -U codeplayground_admin -d codeplayground# Application logs
aws logs tail /ecs/code-playground --follow
# ECS service events
aws ecs describe-services --services code-playground-frontend --query 'services[0].events'
# CloudFormation stack events (if using)
aws cloudformation describe-stack-events --stack-name code-playground- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow existing code style and conventions
- Add tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting PR
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation - Check this README and inline documentation
- Issues - Report bugs and request features via GitHub issues
- Community - Join our community discussions
- β Fixed JavaScript TypeError in AWS environment
- β Added defensive programming for language configuration
- β Improved error handling and fallback values
- β Enhanced deployment scripts and documentation
- π Complete AWS infrastructure setup
- π ECS-based container orchestration
- π Auto-scaling and load balancing
- π Comprehensive monitoring setup
- π Initial release
- β¨ Core code editing and execution features
- β¨ Spring Boot backend with PostgreSQL
- β¨ Next.js frontend with real-time updates
Built with β€οΈ by the CodePlayground Team