Practitionist / Practitionist/elluminar_web
AI teaching assistant + metered AI wallet & credit top-ups
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1
- Forks
- 0
- Avg merge
- 17h 2m
- Merged PRs (30d)
- 18
Description
Why / Context
PRD §7.2A: a 24/7 AI teaching assistant trained on each course's content is becoming a baseline expectation (Euron's EURI, Graphy's AI Brain). The teardown's STEAL list adds the monetization primitive: metered AI usage as a wallet (daily allowance + paid top-up), which "turns a cost center into an upsell lever instead of an unbounded expense" — exactly how Euron prices its 51-model gateway. We deliberately do NOT expose a raw model picker (teardown SKIP list) — task-specific AI only.
Schema already in place — NO migration required
AiWallet(balanceCredits, dailyAllowance, allowanceRefreshedAt)AiCreditPack+CommerceItemType.AI_CREDIT_PACK— top-ups flow through the normal cart/checkoutAiUsageEvent(feature: AI_TUTOR, model, tokens, credits, costMicrosUsd)AiConversation/AiMessage(course/lesson/project-instance scoped)- Plan entitlements already carry
aiDailyCredits(50/150/300 seeded for Learn/Mentor/Career)
Implementation plan
- RAG indexing pipeline (
src/lib/ai/indexing.ts): chunk course content (lesson articles, video transcripts from Fermion transcription, quiz explanations) → pgvector embeddings (enablevectorextension via an ADDITIVE migration — allowed; no core-table changes) with per-course namespace. - Tutor service (
src/lib/ai/tutor.ts): retrieval + Claude API answer generation grounded in the creator's own content and teaching style; check current model ids/pricing via the claude-api skill at build time. System prompt template per course, editable by the creator in studio. - Wallet service (
src/lib/ai/wallet.ts): daily allowance refresh from plan entitlements (scheduled function), atomic credit deduction per request (tokens → credits formula in PlatformConfig), hard stop at zero with top-up CTA. - Chat UI in the course player sidebar (
AiConversationper lesson context), streaming responses, citation links back to lessons. - Top-up SKUs: seed 2–3
AiCreditPackrows + INRPricerows; checkout fulfillment credits the wallet (OrderItem.aiCreditPackId→ wallet increment + ledger-free, platform SKU). - Creator controls: per-course AI-TA toggle, tone instructions, escalation ("ask in discussions") threshold.
- Guardrails: answer-only-from-course-content mode by default, feedback thumbs on messages, abuse rate limits.
- Cost dashboard (admin): AiUsageEvent rollups by feature/model/tenant vs. wallet revenue.
- Flip
ai-tutorFeatureFlag per-course, then globally.
Acceptance criteria
- Tutor answers cite the specific lesson used for grounding; questions outside course scope get the escalation response
- Credits deduct per message; zero balance blocks with top-up CTA; purchase credits → wallet increments via normal checkout
- Daily allowance refreshes per plan tier; downgrade lowers allowance next refresh
- Every call writes AiUsageEvent with model + token counts + credits
- Creator can disable the tutor per course
Dependencies / sequencing
- MVP M8 (entitlements) and M9 (player) required; Fermion transcription optional-but-recommended for video grounding
- Wallet service is shared by issues #3 and #5 — build the wallet here first
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the planned entry points in src/lib/ai/indexing.ts, src/lib/ai/tutor.ts, and src/lib/ai/wallet.ts, then review the existing AiWallet, AiUsageEvent, entitlements, and checkout schema. Confirm sequencing with M8 and M9 and the claude-api skill. Done means the listed acceptance criteria pass, including grounded citations, credit enforcement, allowance refresh, usage events, and creator disablement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, typescript
- Domain
- ai, backend, databases, frontend, payments
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100