The Code Snippets Web Application is a platform designed to facilitate the submission and display of code snippets. It enables users to submit their code snippets along with relevant details and provides a user-friendly interface to view and manage submissions.
- Submission Form: Allows users to submit code snippets with username, preferred language, stdin, and source code.
- Submission Display: Displays all submitted entries in a tabular format, showcasing username, language, stdin, and submission timestamp.
- Output Retrieval: Utilizes Judge0 API to retrieve the output of code snippets and display it in the submission table.
- Redis Caching: Implements Redis caching to optimize performance by reducing requests to the API for fetching output.
- Pagination: Supports lazy loading pagination to efficiently navigate through submissions.
- Node.js for the backend
- Express.js for handling HTTP requests
- MySQL for the database
- Redis for caching
- Judge0 for code execution
- Next.js for building the user interface
- Tailwind CSS for styling
- Clone the repository:
git clone https://github.com/utsav82/tuf-assignment
- Navigate to the project directory:
cd tuf-assignment
- Install dependencies:
npm install
- Set up environment variables:
- Create a
.env
file. - Define the required environment variables (see below for reference).
- Create a
- Start the backend server:
npm start
. - Access the application at
http://localhost:8080
in your browser.
Field | Type | Description |
---|---|---|
id | INT | Unique identifier |
username | VARCHAR(255) | Username of the user who submitted the snippet |
language | ENUM | Preferred code language |
stdin | TEXT | Standard input (stdin) |
source_code | TEXT | Source code of the snippet |
timestamp | TIMESTAMP | Timestamp of submission |
output | TEXT | Output of the code snippet execution |
RAPIDAPI_KEY
: API key for accessing the Judge0 API.REDIS_URL
: URL for connecting to the Redis cache server.MYSQL_PASSWORD
: Password for MySQL database access.MYSQL_HOST
: Hostname or IP address of the MySQL database server.MYSQL_USER
: Username for MySQL database access.MYSQL_DATABASE
: Name of the MySQL database.MYSQL_PORT
: Port number for the MySQL database server.
Contributions are welcome! Please feel free to open issues or pull requests for any improvements or additional features.
This project is licensed under the MIT License.