Skip to content

A full-stack online coding platform powered by Spring Cloud microservices and a Vue 3 frontend, offering scalable, secure, and interactive coding challenges.

License

Notifications You must be signed in to change notification settings

Decade-qiu/D-OnlineJudge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

148 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

D-OnlineJudge

Java Spring Boot Spring Cloud Spring Cloud Gateway OpenFeign Alibaba Nacos Redis RabbitMQ Elasticsearch Sentinel MySQL MyBatis-Plus Vue.js TypeScript Element Plus Docker SkyWalking Prometheus License

πŸ“– Overview

D-OnlineJudge is a full-stack online coding and competitive programming platform built with Java Spring Cloud microservices architecture and Vue 3 frontend framework.

It provides a secure, scalable, and feature-rich environment for programming competitions, code submissions, and real-time verdict feedback.

✨ Key Features

  • πŸ—οΈ Microservices Architecture: Spring Cloud-based modular design with independent deployable services, high cohesion, and loose coupling
  • πŸ”’ Secure Sandbox Environment: Docker containerization provides isolated execution environments to prevent malicious code attacks
  • ⚑ Asynchronous Judging: Redis task queues + RabbitMQ event-driven architecture for high-performance, non-blocking code execution
  • πŸ” Enterprise-Grade Authentication: Long-lived and short-lived token mechanism (Access Token + Refresh Token) with Redis-backed session management
  • πŸ“Š Full-Stack Observability: SkyWalking distributed tracing, Prometheus metrics monitoring, and Loki log aggregation for complete system visibility
  • πŸš€ Automated CI/CD Pipeline: GitHub Actions workflow for continuous integration, building, and deployment
  • πŸ” Intelligent Full-Text Search: Elasticsearch with IK Chinese tokenizer for millisecond-level problem search
  • πŸ’Ύ Three-Tier Cache Architecture: Local cache (Caffeine) + distributed cache (Redis) + database, dramatically reducing database load
  • 🌐 Real-Time WebSocket Notifications: Global push system for real-time verdict feedback without page blocking
  • πŸ›‘οΈ Traffic Management: Alibaba Sentinel integration for rate limiting, circuit breaking, and system protection

πŸš€ Quick Start

This guide will help you set up and run D-OnlineJudge locally. Follow the steps below.

Prerequisites

Ensure you have the following software installed:

Software Version Purpose
JDK 17+ Backend compilation and runtime
Maven 3.6+ Project build tool
Docker 20.10+ Containerization
Docker Compose 1.29+ Container orchestration
Git 2.0+ Version control
Node.js 16+ (optional) Frontend development
Pnpm 8+ (optional) Frontend package manager

Step 1: Clone the Repository

git clone https://github.com/yourusername/D-OnlineJudge.git
cd D-OnlineJudge

Step 2: Backend Setup (DOJ-BE)

2.1 Start Core Dependency Services

We provide complete Docker Compose configurations to start all dependencies with a single command:

# Create Docker network
docker network create doj

# Start all core services (MySQL, Redis, RabbitMQ, Nacos, Elasticsearch, etc.)
# For detailed commands, see docs/0.build.md section "2. Deploying Core Dependency Services"

2.2 Configure Nacos

  1. Access Nacos console: http://localhost:8848/nacos (default: nacos/nacos)
  2. Navigate to "Configuration Management" β†’ "Configuration List"
  3. Create the following shared configuration files:
Data ID Description
shared-jdbc.yaml Database and cache connection settings
shared-swagger.yaml API documentation and logging config
shared-jwt.yaml JWT authentication key configuration
shared-rabbitmq.yaml RabbitMQ message queue settings

πŸ’‘ Configuration templates are available in docs/0.build.md section "2.8 Adding Shared Configurations to Nacos".

2.3 Generate JWT Keystore

Execute the following command in DOJ-BE/common/src/main/resources/:

keytool -genkeypair -alias decade -keyalg RSA -keysize 2048 \
  -validity 365 -keypass doj123 -keystore doj.jks -storepass doj123

2.4 Build Backend Project

cd DOJ-BE
mvn clean install

2.5 Start Microservices

Open a separate terminal for each microservice and start them in order:

# 1. Start Gateway Service
java -Dhttp.proxySet=false -Dhttps.proxySet=false \
  -jar gateway-service/target/gateway-service-1.0-SNAPSHOT.jar

# 2. Start User Service
java -Dhttp.proxySet=false -Dhttps.proxySet=false \
  -jar user-service/target/user-service-1.0-SNAPSHOT.jar

# 3. Start Problem Service
java -Dhttp.proxySet=false -Dhttps.proxySet=false \
  -jar problem-service/target/problem-service-1.0-SNAPSHOT.jar

# 4. Start Submission Service
java -Dhttp.proxySet=false -Dhttps.proxySet=false \
  -jar submission-service/target/submission-service-1.0-SNAPSHOT.jar

# 5. Start Sandbox Service
java -Dhttp.proxySet=false -Dhttps.proxySet=false \
  -jar sandbox-service/target/sandbox-service-1.0-SNAPSHOT.jar

🎯 Verify Backend Startup:

  • Check Nacos service list: http://localhost:8848/nacos should show all services in healthy status
  • Access API documentation: http://localhost:8080/doc.html should display all service endpoints

Step 3: Frontend Deployment (DOJ-FE)

Option A: Docker Container Deployment (Recommended for Production)

cd DOJ-FE

# One-click build, package, and start (grant execute permission once)
chmod +x run-docker.sh
./run-docker.sh

# Application will start at http://localhost:8088

This script automatically:

  • βœ… Executes pnpm build to generate static files
  • βœ… Builds Nginx image based on Dockerfile
  • βœ… Stops old container and starts new one
  • βœ… Maps port 8088 β†’ 80

Option B: Local Development Mode

cd DOJ-FE

# Install dependencies
pnpm install

# Start development server with hot reload
pnpm dev

# Access at http://localhost:5173

Step 4: Access the Application

Once all services are running successfully, access them via:

Component URL Description
Frontend Application http://localhost:8088 Online coding competition platform
API Documentation http://localhost:8080/doc.html Knife4j Swagger documentation
Nacos Console http://localhost:8848/nacos Service registry and configuration
SkyWalking UI http://localhost:9999 Distributed tracing (optional)
Grafana Dashboard http://localhost:3000 Metrics monitoring and alerting (optional)
Kibana Logs http://localhost:5601 Log aggregation and analysis (optional)

πŸ“Š Observability

Comprehensive Monitoring System

Pillar Technology Purpose
Traces Apache SkyWalking "What did the request experience?" - Link visualization, performance analysis
Metrics Prometheus + Grafana "How is the system performing?" - Real-time monitoring and alerting
Logs Loki + Promtail "What happened?" - Log aggregation and troubleshooting

Quick Start Observability Stack

# Start SkyWalking
docker-compose -f docker-compose-skywalking.yml up -d
# Access at http://localhost:9999

# Start Prometheus + Grafana + Loki
docker-compose -f docker-compose-monitoring.yml up -d
# Access Grafana at http://localhost:3000 (admin/admin)

For detailed setup, see docs/0.build.md section "4. Building the Observability Platform".


🐳 Docker and Container Orchestration

Start All Services

# Start all backend microservices (dependencies must be started first)
docker-compose -f docker-compose-service.yml up -d

# Start frontend application
cd DOJ-FE && ./run-docker.sh

# View running containers
docker ps

Build Sandbox Environment Images

# Build multi-language code execution environments
docker build -t code-runner-cpp -f docs/Dockerfile.cpp .
docker build -t code-runner-java -f docs/Dockerfile.java .
docker build -t code-runner-python -f docs/Dockerfile.python .

🀝 Contributing

We welcome all forms of contributions!

  1. Fork this repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License. See the LICENSE file for details.


πŸ“ž Contact and Feedback

For questions, suggestions, or feedback, please reach out through:


πŸ™ Acknowledgments

Special thanks to the following open-source projects for their inspiration and support


⭐ If this project helps you, please give it a Star! ⭐

About

A full-stack online coding platform powered by Spring Cloud microservices and a Vue 3 frontend, offering scalable, secure, and interactive coding challenges.

Topics

Resources

License

Stars

Watchers

Forks

Contributors