Code Runner is a web-based application that allows users to write, compile, and execute code directly from their browser. The platform is inspired by Judge0, providing seamless code execution powered by AWS infrastructure. This documentation explains the purpose of Code Runner, the tools used, and the complete AWS-based deployment workflow.
Code Runner is a cloud-based platform for executing code. It is inspired by Judge0, a popular code execution API, and leverages AWS services for hosting and backend operations.
- Backend: The backend uses the Judge0 API through RapidAPI for compiling and running user code.
- Frontend: The frontend is hosted on AWS S3, ensuring static content is globally distributed using CloudFront.
- AWS Lambda: Lambda functions act as the intermediary, handling requests between the frontend and the Judge0 API.
The goal is to offer a simple, scalable, and efficient environment where users can execute code on-demand, powered by AWS.
Use any code editor or Integrated Development Environment (IDE) for local development, such as:
To connect to Judge0 via RapidAPI, you need the following credentials:
RAPIDAPI_ENDPOINT
RAPIDAPI_HOST
RAPIDAPI_KEY
These credentials are necessary for authenticating Lambda function requests to the Judge0 API.
Ensure you have an AWS account with access to the following services:
- Lambda: For running backend logic and making API requests.
- S3: To host static frontend files.
- CloudFront: To serve content globally and enhance performance.
- Route 53: For custom domain and SSL certificate configuration.
The requirements.txt
file lists the Python dependencies required by your Lambda function. It is crucial for defining the Lambda Layer, ensuring proper environment setup and dependency management.
- Lambda:
lambda_function.py
- Frontend:
index.html
,style.css
,script.js
- AWS Resources: Choose descriptive names for your AWS resources (e.g.,
code-runner-bucket
,code-runner-distribution
) to enhance clarity and ease of management.
- Keep names simple and precise to ease collaboration and resource management.
- Follow consistent naming patterns for files and resources across your project.
-
Write the backend logic inside
lambda_function.py
. -
Configure environment variables:
RAPIDAPI_ENDPOINT
RAPIDAPI_HOST
RAPIDAPI_KEY
-
Use AWS CloudWatch to monitor and debug your Lambda function. CloudWatch logs provide real-time execution data and error reports, which are invaluable for troubleshooting.
-
Develop the frontend locally using:
index.html
for structure and UIstyle.css
for stylingscript.js
for logic and communication with Lambda
-
Insert your Lambda function URL in the
script.js
file to link the frontend and backend. -
Store all frontend files (HTML, CSS, JS) in one folder for easy deployment.
- Create an S3 bucket and enable static website hosting.
- Upload
index.html
,style.css
, andscript.js
to the bucket. - Configure bucket permissions and policies for public access.
- Verify the Bucket Website Endpoint to ensure your site is working correctly.
- Create a CloudFront Distribution and link it to your S3 bucket.
- CloudFront will act as a Content Delivery Network (CDN), improving speed, security, and global accessibility.
- After deployment, perform CloudFront invalidation to clear cached files and serve the latest version to users.
- Verify that the Distribution Domain Name is active and accessible.
- Register your custom domain using Route 53.
- Map your domain to the CloudFront distribution.
- Set up an SSL certificate to enable HTTPS security for your domain.
- Validate the SSL certificate for secure access.
- Once the domain is linked, your project will be live.
- To push updates:
- Edit the files locally.
- Re-upload updated files to S3.
- Invalidate CloudFront to refresh cached content.
This ensures that your latest updates are available to users immediately.
If new changes aren’t appearing:
- Clear browser cache — Browsers may store an older version of your site.
- Use an incognito window — This ensures you’re not loading a cached version.
- Verify CloudFront invalidation — Ensure that CloudFront cache has been cleared.
- Check CloudWatch logs — Review the backend execution logs for errors or issues.
- AWS Lambda (Backend) → RapidAPI (Judge0 API) → Frontend (S3 + CloudFront) → Domain (Route 53)
These AWS services work together to create a scalable, reliable code execution platform with a globally accessible frontend and a monitored backend.
Happy coding! 😄
For further details on the tools and services mentioned in this guide, refer to the official AWS documentation and the Judge0 API documentation.
References: