Process View
The process view describes concurrency, control flow, and the runtime behavior of the system.
Request Lifecycle
- Client sends request to Backend API.
- Backend validates authentication and role.
- Backend processes request:
- For AI requests: asynchronous call to AI service.
- For code execution: isolated runner process.
- Backend waits for response (non-blocking).
- Backend logs event and returns response.
Concurrency Model
- Backend supports concurrent HTTP requests.
- AI and Code Runner calls are asynchronous.
- Resource limits prevent blocking.
- Database transactions ensure consistency.
AI Algorithm Overview
The AI Suggestion Engine follows this structured workflow:
-
Receive context:
- Problem description
- Student's current code
- Programming language
- Cursor position
-
Generate next-line suggestion using a Large Language Model (LLM).
-
Optionally generate an explanation for the suggestion.
-
If in quiz mode:
- Generate 0–2 plausible distractors.
-
Return a structured JSON response to the backend API.
Example JSON structure:
{
"suggestion": "for i in range(n):",
"distractors": [
"for i in n:",
"while i < n:"
],
"explanation": "This iterates from 0 to n-1."
}
Performance Considerations
To maintain low latency and responsiveness:
- Asynchronous API calls are used.
- Timeout thresholds are enforced.
- Optional caching may be applied for repeated prompts.
- AI calls are isolated from core backend logic.