openapi: 3.0.3 info: title: AI-Powered Online Judge Assistant API description: REST API for the AI-POJ backend service version: 1.0.0 contact: name: AI-POJ Team servers: - url: http://localhost:8080 description: Local development components: securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT schemas: ApiResponse: type: object properties: success: { type: boolean } message: { type: string } data: { type: object } error: { type: string } timestamp: { type: string, format: date-time } AuthResponse: type: object properties: token: { type: string } tokenType: { type: string, example: Bearer } userId: { type: integer } username: { type: string } role: { type: string, enum: [ADMIN, USER] } ProblemResponse: type: object properties: id: { type: integer } title: { type: string } description: { type: string } difficultyLabel: { type: string, enum: [EASY, MEDIUM, HARD] } predictedDifficulty: { type: string } timeLimitMs: { type: integer } memoryLimitMb: { type: integer } tags: { type: string } totalSubmissions: { type: integer } acceptedSubmissions:{ type: integer } acceptanceRate: { type: number } SubmissionResponse: type: object properties: id: { type: integer } problemId: { type: integer } language: { type: string } verdict: { type: string } runtimeMs: { type: integer } memoryKb: { type: integer } testCasePassed: { type: integer } testCaseTotal: { type: integer } aiAnalysisStatus:{ type: string } AiAnalysisReport: type: object properties: submissionId: { type: integer } status: { type: string, enum: [PENDING, COMPLETE, FAILED] } bugRiskProbability: { type: number } codeQualityScore: { type: number } complexityScore: { type: number } plagiarismScore: { type: number } isPlagiarismFlagged:{ type: boolean } predictedDifficulty:{ type: string } hints: { type: array, items: { type: string } } security: - bearerAuth: [] paths: # ─── Auth ────────────────────────────────────────────────────── /api/auth/register: post: tags: [Auth] summary: Register new user security: [] requestBody: required: true content: application/json: schema: type: object required: [username, email, password] properties: username: { type: string, minLength: 3 } email: { type: string, format: email } password: { type: string, minLength: 8 } responses: '201': description: Registration successful content: application/json: schema: allOf: - $ref: '#/components/schemas/ApiResponse' - properties: data: { $ref: '#/components/schemas/AuthResponse' } /api/auth/login: post: tags: [Auth] summary: Login and receive JWT security: [] requestBody: required: true content: application/json: schema: type: object required: [username, password] properties: username: { type: string } password: { type: string } responses: '200': description: Login successful — returns JWT token content: application/json: schema: allOf: - $ref: '#/components/schemas/ApiResponse' - properties: data: { $ref: '#/components/schemas/AuthResponse' } '401': description: Invalid credentials # ─── Problems ───────────────────────────────────────────────── /api/problems: get: tags: [Problems] summary: List problems (paginated) security: [] parameters: - name: difficulty in: query schema: { type: string, enum: [EASY, MEDIUM, HARD] } - name: search in: query schema: { type: string } - name: page in: query schema: { type: integer, default: 0 } - name: size in: query schema: { type: integer, default: 20 } responses: '200': { description: Paginated problem list } post: tags: [Problems] summary: Create problem (ADMIN only) responses: '201': { description: Problem created } /api/problems/{id}: get: tags: [Problems] summary: Get problem details with sample test cases security: [] parameters: - name: id in: path required: true schema: { type: integer } responses: '200': { description: Problem details } '404': { description: Problem not found } put: tags: [Problems] summary: Update problem (ADMIN only) responses: { '200': { description: Updated } } delete: tags: [Problems] summary: Soft-delete problem (ADMIN only) responses: { '200': { description: Deleted } } /api/problems/{id}/testcases: post: tags: [Problems] summary: Add test cases to problem (ADMIN only) responses: { '201': { description: Test cases added } } # ─── Submissions ─────────────────────────────────────────────── /api/submissions: post: tags: [Submissions] summary: Submit code for a problem requestBody: required: true content: application/json: schema: type: object required: [problemId, language, sourceCode] properties: problemId: { type: integer } language: { type: string, enum: [JAVA, CPP, PYTHON] } sourceCode: { type: string } responses: '201': { description: Submission accepted, execution started } /api/submissions/{id}: get: tags: [Submissions] summary: Get submission result parameters: - name: id in: path required: true schema: { type: integer } responses: '200': { description: Submission result with AI analysis status } /api/submissions/me: get: tags: [Submissions] summary: Get current user's submissions responses: { '200': { description: Paginated submission list } } /api/submissions/problem/{problemId}: get: tags: [Submissions] summary: Get all submissions for a problem (ADMIN only) responses: { '200': { description: Paginated submission list } } # ─── AI Analysis ─────────────────────────────────────────────── /api/ai/analysis/{submissionId}: get: tags: [AI Analysis] summary: Full AI analysis report for a submission parameters: - name: submissionId in: path required: true schema: { type: integer } responses: '200': description: AI analysis report (status=PENDING if still running) content: application/json: schema: allOf: - $ref: '#/components/schemas/ApiResponse' - properties: data: { $ref: '#/components/schemas/AiAnalysisReport' } /api/ai/plagiarism/{submissionId}: get: tags: [AI Analysis] summary: Plagiarism check result only responses: { '200': { description: Plagiarism score and flag } } /api/ai/hint/{submissionId}: get: tags: [AI Analysis] summary: Smart hints for a failed submission responses: { '200': { description: List of hints } } /api/ai/difficulty/{submissionId}: get: tags: [AI Analysis] summary: Difficulty prediction for the problem responses: { '200': { description: Predicted difficulty with confidence } } # ─── Users ───────────────────────────────────────────────────── /api/users/me: get: tags: [Users] summary: Get current user profile responses: { '200': { description: User profile } } /api/users/{id}/profile: get: tags: [Users] summary: Get a user's public profile responses: { '200': { description: User profile } }