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 codeplus2. 配置数据库
创建数据库:
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 # 或其他大模型 API4. 启动沙箱服务
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"
}⚠️ 注意事项
- API Key:需要配置大模型 API Key(阿里云 DashScope / OpenAI 等)
- 代码沙箱安全:生产环境建议使用 Docker 隔离
- Redis:确保 Redis 服务已启动
📄 License
MIT License
