AI智能判题系统

基于大模型的在线编程判题平台,提供AI智能判题、代码沙箱安全执行、流式输出反馈等功能,适用于在线编程学习和竞赛场景。

  • by liyunmiao427
  • Java
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 liyunmiao427/Codeplus

使用说明

CodePlus - AI 智能判题系统

基于 Spring Boot + Vue3 + Spring AI 的在线编程判题平台。

🚀 功能特性

  • AI 智能判题:基于大模型分析代码正确性,给出详细反馈
  • 代码沙箱:安全隔离执行用户代码(支持 Java)
  • MCP 工具集成:通过 MCP 协议调用代码沙箱
  • 流式输出:SSE 实时返回判题分析过程
  • 题目管理:支持题目的增删改查
  • 评论系统:两级评论结构,支持回复

📁 项目结构

codeplus/
├── hou/codeplus/          # 后端主项目 (Spring Boot)
├── sandboxtool/           # 代码沙箱 MCP 服务
└── qian/                  # 前端项目 (Vue3)

🛠️ 技术栈

后端

  • Spring Boot 3.x
  • Spring AI 1.0.0-SNAPSHOT
  • MyBatis-Plus
  • MySQL 8.0
  • Redis

前端

  • Vue 3
  • Vite
  • Axios

其他

  • MCP (Model Context Protocol)
  • SSE (Server-Sent Events)

📋 环境要求

  • JDK 17+
  • Node.js 18+
  • MySQL 8.0+
  • Redis 6.0+
  • Maven 3.8+

🚀 快速开始

1. 克隆项目

git clone https://github.com/你的用户名/codeplus.git
cd codeplus

2. 配置数据库

创建数据库:

CREATE DATABASE codeplus DEFAULT CHARACTER SET utf8mb4;

导入表结构(如果有 SQL 文件)或让 JPA 自动建表。

3. 修改配置

编辑 hou/codeplus/src/main/resources/application.yml:

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/codeplus
    username: 你的用户名
    password: 你的密码
  
  ai:
    dashscope:
      api-key: 你的阿里云API Key  # 或其他大模型 API

4. 启动沙箱服务

cd sandboxtool/sandboxtool
mvn spring-boot:run

沙箱默认端口:8123

5. 启动后端主服务

cd hou/codeplus
mvn spring-boot:run

后端默认端口:8080

6. 启动前端

cd qian
npm install
npm run dev

前端默认端口:5173

7. 访问

打开浏览器访问:http://localhost:5173

📝 API 接口

判题接口

POST /api/judge/submit
Content-Type: application/json

{
    "problemId": 1,
    "code": "public class Main { ... }",
    "language": "java"
}

返回:SSE 流式数据

运行接口

POST /api/judge/run
Content-Type: application/json

{
    "problemId": 1,
    "code": "public class Main { ... }",
    "language": "java",
    "testInput": "1 2"
}

⚠️ 注意事项

  1. API Key:需要配置大模型 API Key(阿里云 DashScope / OpenAI 等)
  2. 代码沙箱安全:生产环境建议使用 Docker 隔离
  3. Redis:确保 Redis 服务已启动

📄 License

MIT License