Skip to content

JimmYCHUU/pme-persona-mentor-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Persona Mentor Engine (PME)

An AI-powered mentoring platform that creates personalised learning experiences through 40+ pre-built mentor personas, a 5-level Socratic ladder, experience-triggered memory, and proof-of-mastery certification.

Tests Python React TypeScript


Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  React 19   β”‚    β”‚  FastAPI Backend                                             β”‚
β”‚  Vite       │◄──►│  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  Zustand    β”‚    β”‚  β”‚  LangGraph Pipeline (ARCH-3)                            β”‚  β”‚
β”‚  globals.cssβ”‚    β”‚  β”‚  memory β†’ etm β†’ socratic β†’ persona β†’ guardian β†’ END     β”‚  β”‚
β”‚             β”‚    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚             β”‚    β”‚  BackgroundTasks: mastery_node β†’ cert_node                    β”‚
β”‚             β”‚    β”‚  LLMService: OpenRouter β†’ Fallback Chain β†’ Ollama            β”‚
β”‚             β”‚    β”‚  ChromaDB: vault + fingerprint collections                   β”‚
β”‚             β”‚    β”‚  SQLite: mastery_ledger + mastery_certificates               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Non-Negotiable Rules

  • ARCH-1: socratic_node (WHAT) and persona_node (HOW) always separate
  • ARCH-2: mastery_node and cert_node run ONLY as BackgroundTasks
  • ARCH-3: Pipeline order fixed: memory β†’ etm β†’ socratic β†’ persona β†’ guardian β†’ END
  • ARCH-4: All LLM calls through LLMService singleton only
  • ARCH-5: Every endpoint returns {"success": bool, "data": any, "error": str | null}

Features

πŸŽ“ 40 Pre-Built Mentor Personas

8 categories Γ— 5 mentors each: Cybersecurity, Business, Programming, AI/ML, Finance, Design, Fitness, Psychology. Each with unique voice, teaching style, and embedded knowledge base.

🧠 5-Level Socratic Ladder

Level Behavior
0 Neutral β€” provide information
1 Gentle probing β€” "What do you think?"
2 Guided discovery β€” "What if we changed X?"
3 Challenge β€” "Can you explain WHY?"
4 Corrective β€” "Let's reconsider..."

⚑ Experience-Triggered Memory (ETM)

VS Code extension sends workspace events (terminal errors, file saves). ETM extracts teaching concepts and connects mentoring to the student's real code.

πŸ“Š Mastery Tracking

Concepts encountered β†’ attempted β†’ struggling or mastered. Configurable score thresholds. Proof-of-mastery certificates generated when thresholds are met.

πŸ›‘οΈ Content Guardian

Regex-based safety filter with educational context awareness. Blocks harmful content while preserving legitimate security education (pentesting, CTF, etc.).

πŸ”„ Rate Limit Mitigation

SHA256-keyed response cache (24h TTL) + 3-tier fallback chain: OpenRouter primary β†’ free model fallback β†’ local Ollama.

Quick Start

Prerequisites

  • Python 3.12+
  • Node.js 18+
  • (Optional) Ollama for local LLM fallback

Backend

cd backend
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env  # Add your OpenRouter API key
uvicorn main:app --reload --port 8000

Frontend

cd frontend
npm install
npm run dev  # β†’ http://localhost:5173

Tests

cd backend
python -m pytest tests/ -v  # β†’ 73 passing

Directory Structure

pme/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ api/           # FastAPI routers (chat, persona, session, mastery, gallery, workspace)
β”‚   β”œβ”€β”€ core/          # Config, database, utils
β”‚   β”œβ”€β”€ graph/         # LangGraph pipeline
β”‚   β”‚   β”œβ”€β”€ nodes/     # memory, etm, socratic, persona, guardian, mastery, cert
β”‚   β”‚   β”œβ”€β”€ state.py   # PMEState TypedDict
β”‚   β”‚   └── orchestrator.py
β”‚   β”œβ”€β”€ models/        # SQLAlchemy models + Pydantic schemas
β”‚   β”œβ”€β”€ rag/           # vault.py, fingerprint.py, retriever.py
β”‚   β”œβ”€β”€ services/      # llm_service, persona_service, session_service, mastery_service
β”‚   β”œβ”€β”€ data/mentors/  # 40 mentor profiles (8 categories Γ— 5)
β”‚   └── tests/         # 73 tests
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ api/       # Axios client
β”‚   β”‚   β”œβ”€β”€ components/ # React components (gallery, chat, layout, session, mastery)
β”‚   β”‚   β”œβ”€β”€ hooks/     # useChat, useMastery, useSession
β”‚   β”‚   β”œβ”€β”€ store/     # Zustand stores
β”‚   β”‚   β”œβ”€β”€ styles/    # globals.css design system
β”‚   β”‚   └── pages/     # SessionPage, DashboardPage, MentorsPage, SettingsPage
β”‚   └── package.json
└── vscode-extension/  # VS Code extension for workspace events

Environment Variables

Variable Description Default
OPENROUTER_API_KEY OpenRouter API key (required)
PERSONA_MODEL Primary LLM for mentor voice nvidia/llama-3.3-nemotron-super-49b-v1:free
REASONING_MODEL LLM for Socratic assessment nvidia/llama-3.3-nemotron-super-49b-v1:free
FALLBACK_MODEL_1 First fallback model meta-llama/llama-3.3-70b-instruct:free
FALLBACK_MODEL_2 Second fallback model mistralai/mistral-7b-instruct:free
OLLAMA_BASE_URL Local Ollama URL http://localhost:11434
DEVIATION_THRESHOLD Score for misconception detection 0.65
MASTERY_CERT_THRESHOLD Score needed for certification 0.8

License

MIT

About

🧠 Persona Mentor Engine (PME) β€” A private, local-first AI workspace that clones the intellectual DNA of any real-world expert, trains you Socratically, tracks mastery across sessions, and issues in-character certifications via OpenRouter + LangGraph

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors