diff --git a/docs/personalization_design.md b/docs/personalization_design.md new file mode 100644 index 0000000..d0f2d99 --- /dev/null +++ b/docs/personalization_design.md @@ -0,0 +1,68 @@ +\# AI-Driven Personalized Learning Path — Design Doc + + + +\## Overview + +This feature dynamically generates a personalized learning path for each user by detecting topic-wise weaknesses based on their performance and activity history. + + + +\## Goals + +\- Detect weak areas using performance analytics. + +\- Recommend weekly personalized goals. + +\- Increase engagement and retention. + +\- Deliver smarter preparation paths via AI. + + + +\## Scope (MVP) + +\- Weakness detection using rule-based scoring. + +\- Weekly roadmap with: + +  - 2–3 weak topics to focus on. + +  - Practice problems \& concept resources. + +  - Progress tracking. + + + +\## Data Schema + +\*\*Events\*\* + +```json + +{ + +  "user\_id": "string", + +  "activity\_type": "quiz|coding|mock", + +  "topic": "arrays|dp|graphs|system-design", + +  "subtopic": "two-pointer", + +  "timestamp": "ISO8601", + +  "accuracy": 0.85, + +  "time\_taken\_seconds": 120, + +  "attempts": 1, + +  "difficulty": "easy|medium|hard", + +  "exercise\_id": "string" + +} + + + diff --git a/services/personalization/app.py b/services/personalization/app.py new file mode 100644 index 0000000..c7195b3 --- /dev/null +++ b/services/personalization/app.py @@ -0,0 +1,69 @@ +--- + +## **2. Backend Starter (FastAPI)** — `services/personalization/app.py` +```python +from fastapi import FastAPI, HTTPException +from pydantic import BaseModel +from typing import List +from datetime import datetime + +app = FastAPI(title="Personalization Service") + +# ---- Schemas ---- +class Event(BaseModel): + user_id: str + activity_type: str + topic: str + subtopic: str + timestamp: datetime + accuracy: float + time_taken_seconds: int + attempts: int + difficulty: str + exercise_id: str + +class Task(BaseModel): + description: str + completed: bool = False + +class WeekPlan(BaseModel): + week_no: int + topics: List[str] + tasks: List[Task] + goal: str + +class Roadmap(BaseModel): + user_id: str + weeks: List[WeekPlan] + +# ---- Mock Database ---- +mock_events = [] +mock_roadmaps = { + "u1": Roadmap( + user_id="u1", + weeks=[ + WeekPlan( + week_no=1, + topics=["arrays", "two-pointer"], + tasks=[ + Task(description="Solve 3 practice problems"), + Task(description="Watch 2 concept videos"), + Task(description="Take revision quiz") + ], + goal="Reach avg_accuracy ≥ 0.75" + ) + ] + ) +} + +# ---- Endpoints ---- +@app.post("/events") +def add_event(event: Event): + mock_events.append(event.dict()) + return {"message": "Event recorded", "total_events": len(mock_events)} + +@app.get("/user/{user_id}/path", response_model=Roadmap) +def get_roadmap(user_id: str): + if user_id not in mock_roadmaps: + raise HTTPException(status_code=404, detail="No roadmap found for this user") + return mock_roadmaps[user_id] \ No newline at end of file