Skip to main content

AI Microservice (learnway-ai-service/)

The LearnWay AI Microservice (learnway-ai-service/) is an isolated, scalable service handling generative AI workloads, student tutoring, onboarding skill assessments, and capstone project code evaluations.

Service Architecture & Pipelines


Core Capabilities

1. Interactive AI Mentor & Lesson Tutor

  • Prompt Types: EXPLAIN, SUMMARIZE, QUIZ_HINT, SIMPLIFY, and CUSTOM.
  • Context Window Injection: The service injects relevant slide content, key definitions, and preceding lesson context into Gemini’s system prompt.
  • Deterministic Caching: Requests for predefined prompt types (EXPLAIN, SUMMARIZE) on identical lesson IDs produce identical cache keys stored in Redis for 24 hours, dramatically cutting LLM API costs.

2. Onboarding Skill Assessment Engine

  • Evaluates new learners across foundational domains (Web3, Programming, Financial Literacy).
  • Dynamically adjusts subsequent question difficulty based on prior answers.
  • Generates a tailored starting level recommendation (BEGINNER, INTERMEDIATE, ADVANCED).

3. Capstone Code & Project Evaluator

  • Analyzes GitHub repositories, Solidity smart contracts, and project submissions against predefined rubrics.
  • Evaluates code style, security best practices (Reentrancy, SafeMath/v0.8 overflow, access control), and test coverage.
  • Returns structured JSON scores, detailed strengths, weaknesses, and actionable code refactoring tips.

Resilience & Rate Limiting

  • Circuit Breaker: Detects Gemini API latency spikes or upstream outages, gracefully failing over or returning cached responses.
  • Rate Limits: Enforces daily per-user quotas (e.g. 20 queries/day for free users, 100 queries/day for Premium users) managed via Redis sliding window counters.
  • Content Safety: Filters prompt injection attacks, malicious code, and inappropriate language before invoking the LLM.