A modern competitive programming platform built with Next.js frontend and Ballerina backend, featuring real-time code execution, test case validation, and comprehensive contest management.
- Modern UI: Built with Tailwind CSS and shadcn/ui components
- Authentication: Login/signup with JWT token storage
- Role-based Access Control: Admin and user roles with different permissions
- Code Editor: Monaco Editor with syntax highlighting for Python, Java, and Ballerina
- Real-time Code Execution: Execute code against test cases with instant feedback
- Test Case Validation: Automatic comparison of expected vs actual outputs
- Performance Analysis: Time complexity, space complexity, and execution metrics
- Global State Management: React Context for auth and data management
- Responsive Design: Mobile-friendly interface
- RESTful API: Clean API endpoints for authentication and data management
- JWT Authentication: Secure token-based authentication with 7-day expiration
- SQLite Database: Lightweight database with migrations and seeding
- Role-based Access Control: Admin and user role management
- Password Hashing: Secure password storage using SHA-256
- Code Execution Engine: Docker-based secure code execution
- Multi-language Support: Python, Java, and Ballerina execution
- Performance Monitoring: Execution time, memory usage, and complexity analysis
- Secure Containerization: Docker-based isolated execution environment
- Multi-language Support: Python 3, Java 17, Ballerina 2201.12.7
- Resource Limits: Memory (256MB), CPU (1.0 cores), Process (50)
- Network Isolation: No external network access for security
- Real-time Feedback: Instant execution results and error reporting
HACKATHON_PLUS_BALLERINA/
βββ backend-ballerina/ # Ballerina backend
β βββ modules/
β β βββ auth/ # Authentication logic
β β βββ database/ # Database operations
β β βββ jwt/ # JWT token management
β β βββ migrations/ # Database migrations
β β βββ models/ # Data models
β β βββ seeders/ # Database seeding
β βββ main.bal # Main server file
βββ frontend-next/ # Next.js frontend
β βββ src/
β β βββ app/ # App router pages
β β β βββ (auth)/ # Authentication pages
β β β βββ (private)/ # Protected pages
β β β β βββ challenges/ # Challenge management
β β β β βββ contests/ # Contest management
β β β β βββ leaderboard/ # Leaderboards
β β β βββ admin/ # Admin dashboard
β β βββ components/ # Reusable UI components
β β βββ contexts/ # React Context providers
β β βββ lib/ # Utility functions and API
β βββ package.json
βββ code-execution-engine-docker/ # Docker code execution engine
β βββ Dockerfile # Multi-language container
β βββ run-code.sh # Execution script
β βββ README.md # Engine documentation
βββ docker-compose.yml # Docker configuration
- Node.js 18+ and npm
- Ballerina 2201.12.7+
- Docker (required for code execution)
- Git
git clone <repository-url>
cd HACKATHON_PLUS_BALLERINA-
Navigate to backend directory:
cd backend-ballerina -
Install dependencies:
bal build
-
Run database migrations:
bal run -- migrate
-
Seed the database:
bal run -- seed
-
Start the server:
bal run
The backend will start on http://localhost:8080
-
Navigate to code execution directory:
cd code-execution-engine-docker -
Build the Docker image:
docker build -t multi-lang-runner:latest . -
Verify the build:
docker images | grep multi-lang-runner
-
Navigate to frontend directory:
cd frontend-next -
Install dependencies:
npm install --legacy-peer-deps
-
Start the development server:
npm run dev
The frontend will start on http://localhost:3000
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
def inorderTraversal(root):
result = []
def inorder(node):
if node:
inorder(node.left)
result.append(node.val)
inorder(node.right)
inorder(root)
return result
# Test case
root = TreeNode(1, None, TreeNode(2, TreeNode(3)))
result = inorderTraversal(root)
print(result)public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
for (int i = 0; i < 5; i++) {
System.out.println("Count: " + i);
}
}
}import ballerina/io;
public function main() {
io:println("Hello from Ballerina!");
foreach int i in 0..<5 {
io:println(string`Count: ${i}`);
}
}POST /login- User loginPOST /register- User registrationGET /profile- Get user profile (requires JWT)
POST /api/submit- Execute codeGET /api/health- Code execution service healthGET /api/languages- Get supported languages
GET /health- Server health check
# Run migrations
bal run -- migrate
# Rollback last migration
bal run -- migrate:rollback
# Seed database
bal run -- seed
# Fresh database (clear + seed)
bal run -- db:fresh- Username:
admin - Password:
password - Email:
admin@codearena.com
-
Username:
john -
Password:
password -
Email:
john@example.com -
Username:
jane -
Password:
password -
Email:
jane@example.com
- User authentication (login/register)
- JWT token management with 7-day expiration
- Role-based access control (admin/user)
- Global authentication context
- Local storage for JWT tokens
- Database migrations and seeding
- SQLite database with proper schema
- RESTful API endpoints
- Error handling and validation
- Responsive login/signup pages
- Modern UI with Tailwind CSS and shadcn/ui
- API service layer
- Protected routes and navigation
- Multi-language Docker container (Python, Java, Ballerina)
- Secure code execution with resource limits
- Real-time code execution API
- Performance monitoring and analysis
- Test case validation and comparison
- Code complexity analysis
- Contest creation and management
- Challenge management with test cases
- Real-time code execution in contests
- Test case validation and scoring
- Leaderboard functionality
- Admin dashboard
- User management
- Contest and challenge management
- Analytics and monitoring
- Real-time collaboration features
- Advanced analytics and reporting
- Email notifications
- Social features and user profiles
- Advanced contest features (teams, time limits)
- Code plagiarism detection
- Advanced code analysis tools
- Integration with external APIs
- Mobile app development
- Advanced security features
- Container Isolation: Each execution runs in isolated Docker containers
- Resource Limits: Memory (256MB), CPU (1.0 cores), Process (50)
- Network Isolation: No external network access
- Time Limits: 30-second execution timeout
- Read-only Filesystem: Prevents file system attacks
- Non-root User: Code runs as unprivileged user
- JWT Authentication: Secure token-based authentication
- Password Hashing: SHA-256 password hashing
- CORS Protection: Configured CORS policies
- Input Validation: Comprehensive input validation
- SQL Injection Protection: Parameterized queries
- Time Complexity: Automatic detection of algorithm complexity
- Space Complexity: Memory usage analysis
- Pattern Detection: Identifies common coding patterns
- Performance Metrics: Execution time and resource usage
- Docker Optimization: Efficient container management
- Database Optimization: Indexed queries and efficient schema
- Frontend Optimization: Code splitting and lazy loading
- Caching: Strategic caching for better performance
- Framework: Next.js 14 with App Router
- Styling: Tailwind CSS
- UI Components: shadcn/ui
- State Management: React Context
- Icons: Lucide React
- Code Editor: Monaco Editor
- TypeScript: Full type safety
- Language: Ballerina 2201.12.7
- Database: SQLite
- Authentication: JWT
- Password Hashing: SHA-256
- API: RESTful HTTP
- Code Execution: Docker containers
- Containerization: Docker
- Code Execution: Multi-language Docker containers
- Security: Container isolation and resource limits
- Monitoring: Performance metrics and analysis
- Start both backend and frontend servers
- Navigate to
http://localhost:3000 - Login with demo credentials
- Create or join a contest
- Write and execute code
- Verify test case results
# Test Python execution
curl -X POST http://localhost:8080/api/submit \
-H "Content-Type: application/json" \
-d '{"code": "print(\"Hello, World!\")", "language": "python"}'
# Test Java execution
curl -X POST http://localhost:8080/api/submit \
-H "Content-Type: application/json" \
-d '{"code": "public class Main { public static void main(String[] args) { System.out.println(\"Hello, World!\"); } }", "language": "java"}'
# Test Ballerina execution
curl -X POST http://localhost:8080/api/submit \
-H "Content-Type: application/json" \
-d '{"code": "import ballerina/io; public function main() { io:println(\"Hello, World!\"); }", "language": "ballerina"}'- Docker not running: Ensure Docker is installed and running
- Port conflicts: Check if ports 3000 and 8080 are available
- Database errors: Run
bal run -- db:freshto reset database - Code execution fails: Verify Docker image is built correctly
# Check Docker status
docker ps
# Check backend logs
cd backend-ballerina && bal run
# Check frontend logs
cd frontend-next && npm run dev
# Test code execution health
curl http://localhost:8080/api/health- 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
- Use TypeScript for frontend development
- Follow Ballerina coding conventions
- Write comprehensive tests
- Update documentation for new features
- Ensure security best practices
This project is licensed under the MIT License - see the LICENSE file for details.
- Next.js for the frontend framework
- Ballerina for the backend language
- shadcn/ui for UI components
- Monaco Editor for code editing
- Docker for containerization
For support and questions:
- Create an issue in the repository
- Contact the development team
- Check the documentation in each component's README
Built with β€οΈ for competitive programming enthusiasts