feat: NLP patch insights + standalone demo mode

- dlib/ai/insights.py: pure-Python NLP analysis that correlates accepted
  AI suggestion operations/keywords/sections with submission outcomes
  (pending_review / published = positive, archived = negative)
- Backend: GET /api/v1/insights route + service + Pydantic schema
- Frontend: InsightsPanel component with bar charts for operation impact,
  section impact, and keyword signal lift scores
- Insights tab added to the version panel; compact preview on doc overview
- NEXT_PUBLIC_DEMO=true makes the webapp fully standalone: loads
  DEMO_DOCUMENTS / DEMO_SUBMISSIONS / DEMO_INSIGHTS from demo-data.ts,
  disables all mutating actions, shows a DEMO badge in the top bar
- apps/webapp/public/demo-cv.docx: static dummy CV (Alex Rivera) for demo
- scripts/gen_demo_cv.py: script to regenerate the demo DOCX
- .env.example: document NEXT_PUBLIC_DEMO flag

https://claude.ai/code/session_01LWxu2qrwY6BRjUFXXn7NiM
This commit is contained in:
Claude
2026-04-05 09:34:01 +00:00
parent 0f32d46404
commit 615d1bdb9e
12 changed files with 780 additions and 17 deletions

View File

@@ -0,0 +1,34 @@
from __future__ import annotations
from pydantic import BaseModel
class OperationImpactSchema(BaseModel):
operation: str
total: int
positive: int
rate: float
class KeywordSignalSchema(BaseModel):
keyword: str
positive_count: int
negative_count: int
lift: float
class SectionImpactSchema(BaseModel):
section: str
positive_rate: float
count: int
class InsightsResponse(BaseModel):
total_submissions: int
positive_count: int
positive_rate: float
operation_impact: list[OperationImpactSchema]
top_positive_keywords: list[KeywordSignalSchema]
top_negative_keywords: list[KeywordSignalSchema]
section_impact: list[SectionImpactSchema]
has_data: bool