An online judge system built with Go + Gin + GORM + MySQL + Redis + Docker, supporting code submission, automatic compilation, execution, and judging.
- ✅ User registration (email verification code)
- ✅ User login (JWT Token authentication)
- ✅ Send verification code (Redis cache, SMTP email)
- ✅ User detail query
- ✅ Leaderboard (sorted by number of solved problems and submissions)
- ✅ Problem list (supports keyword search, category filtering, pagination)
- ✅ Problem detail (includes test cases)
- ✅ Create problem (admin only, supports multiple categories and test cases)
- ✅ Update problem (admin only, transaction ensures consistency)
- ✅ Category list (supports search, pagination)
- ✅ Create category (supports hierarchical structure)
- ✅ Update category
- ✅ Delete category (with safety checks)
- ✅ Code submission (saved to temporary directory)
- ✅ Automatic compilation (Go code)
- ✅ Docker isolated execution (memory limits, timeout control, network isolation)
- ✅ Concurrent testing (goroutines execute multiple test cases concurrently)
- ✅ Accurate judgment:
- Compilation error (status code 5)
- Wrong answer (status code 2)
- Runtime timeout (status code 3)
- Memory limit exceeded (status code 4)
- Accepted (status code 1)
- ✅ JWT Token authentication
- ✅ User permission middleware
- ✅ Admin permission middleware
- Backend Framework: Gin
- ORM: GORM
- Database: MySQL 8.0+
- Cache: Redis
- Containerization: Docker (code execution isolation)
- Authentication: JWT
- API Documentation: Swagger/OpenAPI
- Email Service: SMTP (Gmail)
- Go 1.21+
- MySQL 8.0+
- Redis
- Docker (for running user-submitted code)
git clone <repository-url>
cd GeekCodinggo mod downloadMake sure MySQL and Redis services are running:
# Check MySQL
mysql -u root -p
# Check Redis
redis-cli pingDatabase configuration is in models/init.go, modify as needed.
Build the Docker image for running user code:
./docker-build.shOr build manually:
docker build -t golang-code-runner:latest -f internal/code/Dockerfile .swag initgo run main.goThe application will start at http://localhost:8080.
Open your browser and visit:
http://localhost:8080/swagger/index.html
Issues and Pull Requests are welcome!
Apache 2.0
Bo Li (Frida)
Note: This is an online judge system. Please ensure in production:
- Use strong passwords
- Configure HTTPS
- Limit Docker resource usage
- Regularly clean temporary files
- Monitor system resources