Skip to content

feat: Carte mentale interactive avec vérification IA et export PDFfeat: add mindmap PDF export and agent verification - #277

Open
YassineElbaite wants to merge 2 commits into
Open-TutorAi:mainfrom
YassineElbaite:feature/mindmap-interactive
Open

feat: Carte mentale interactive avec vérification IA et export PDFfeat: add mindmap PDF export and agent verification#277
YassineElbaite wants to merge 2 commits into
Open-TutorAi:mainfrom
YassineElbaite:feature/mindmap-interactive

Conversation

@YassineElbaite

Copy link
Copy Markdown

New Feature — Interactive Mind Map

What this contribution adds:

  1. Mind map generation from concepts studied
    during the chat session with the AI tutor

  2. AI Agent Verification — the agent compares
    the student's mind map with the concepts covered
    in the conversation and provides a score + feedback

  3. PDF Export — the student can download
    their mind map as a PDF after validation

Files changed:

  • gateway/http/routers/mindmap.py → Backend API endpoints
  • ui/src/lib/apis/mindmap.ts → Frontend API client
  • ui/src/routes/student/mindmap/[id]/+page.svelte → UI Interface
  • requirements.txt → Added reportlab dependency

How to test:

  1. Start a chat session with the AI tutor on any topic
  2. Navigate to /student/mindmap/[chat_id]
  3. Create a mind map by adding concept nodes
  4. Click "Verify my map" to trigger AI verification
  5. If validated → click "Download PDF" to export

User Story:

As a student, I want a visual and interactive mind map
to be generated from my learning session concepts,
verified by an AI agent, and downloadable as PDF,
so that I can visualize and memorize the course structure.

Screenshots

1. Chat interface — "Carte Mentale" button
Students can launch the mind map feature directly from their tutoring session.
image

2. Mind map editor — initial loading
The interactive canvas loads the session context (nodes, colors, drag & drop tips).
image
3. Suggested concepts from the session
Concepts automatically extracted from the chat are suggested as starting nodes.
image
4. Completed mind map example
Example of a student-built mind map on Object-Oriented Programming (OOP).
image
5. Success overlay — AI verification passed
When the map is validated by the AI agent, the student gets positive feedback and can download the PDF.
image
6. ⚠️ Improvement overlay — missing concepts
If the map is incomplete, the agent suggests adding more concepts, with the option to improve manually or let the agent complete it.
image

Contributors:

Yassine EL BAITE

@Oumaima-elkhoummassi

Oumaima-elkhoummassi commented Jun 30, 2026

Copy link
Copy Markdown

Hi @YassineElbaite

The PR description is well structured (user story, testing steps, screenshots) - that part is solid.

What's missing: there's no documentation file in docs/ for this feature (mind map generation, AI verification, PDF export). Per the project rule, this needs at least a technical doc (endpoints, data models for mind maps) and a user guide, since there's a UI for students.

Could you add these before this is ready for review?

@YassineElbaite

Copy link
Copy Markdown
Author

Hi @Oumaima-elkhoummassi

Thanks for the feedback! I've added both documentation files as requested:

  • docs/mindmap-technical.md — covers the API endpoints (context, verify, export/pdf) and data models (MindMapNode, MindMapEdge)
  • docs/mindmap-user-guide.md — step-by-step guide for students on how to use the mind map feature

Both are pushed now. Ready for review 🙏

@baaki-hicham

Copy link
Copy Markdown

Review — feat: Interactive Mind Map with AI verification and PDF export

Thanks for this contribution — the concept is interesting (mindmap generation from chat sessions + AI verification + PDF export). However, several issues prevent the feature from working at all in its current state.

1. 🔴 Blocking — Duplicate import prevents the page from compiling

ui/src/routes/student/mindmap/[id]/+page.svelte imports the same functions twice:

import { getMindmapContext, verifyMindmap, exportMindmapPDF } from "$lib/apis/mindmap";
import { getMindmapContext, verifyMindmap, exportMindmapPDF } from "$lib/apis/mindmap";

This causes a Vite compilation error:

Identifier 'getMindmapContext' has already been declared

The page cannot load at all — the feature is completely inaccessible even by typing the URL directly.


2. 🔴 Blocking — Duplicate route and duplicate class in mindmap.py

POST /mindmap/export/pdf is declared twice (lines 278 and 328), and class ExportRequest is also declared twice. FastAPI silently uses only the first declaration and ignores the second. The two implementations are different (the second one imports Table and TableStyle for a richer PDF layout) — so the better implementation is being ignored.

@router.post("/export/pdf")  # line 278 — used by FastAPI
async def export_mindmap_pdf(...):  # simple version

@router.post("/export/pdf")  # line 328 — silently ignored
async def export_mindmap_pdf(...):  # richer version with Table/TableStyle

Suggestion: remove the first (simpler) implementation and keep only the second one.


3. 🔴 Blocking — Feature has no entry point in the UI

The mindmap page at /student/mindmap/[chat_id] is not linked from anywhere in the existing interface — no button in the chat, no link in the sidebar, no navigation item. The only way to access it is to type the URL manually with a known chat_id.

Confirmed:

grep -rn "mindmap" ui/src/lib/components/student/ ui/src/routes/student/
# → no results outside the mindmap folder itself

A feature with no entry point has no user value.

Suggestion: add a "Mind Map" button in the chat interface (e.g. in the chat toolbar or sidebar) that navigates to /student/mindmap/[current_chat_id].


4. 🟡 Non-blocking — Design uses hardcoded colors outside the project palette

The component uses custom hex colors not defined in tailwind.config.js:

background: #0b0e1a
background: #141828
background: linear-gradient(135deg, #6366f1, #7c3aed)
color: #818cf8

And 8 node colors hardcoded as JavaScript constants (#6366f1, #22c55e, #f97316, etc.).

Per the frontend charter, colors must come from the gray-* palette defined in tailwind.config.js, or be added via a team design decision. Inline styles also bypass dark mode support.


5. 🟡 Non-blocking — Broad exception handler exposes internal details

except Exception as e:
    raise HTTPException(status_code=500, detail=str(e))

Returning raw exception messages in HTTP responses can expose internal stack traces or library details to end users.

Suggestion: catch specific exceptions (ImportError for reportlab, ValueError for bad input) and return generic messages for unexpected errors.


6. ℹ️ Note — New reportlab dependency

reportlab is added to requirements.txt but not mentioned in the changelog. Since it's a non-trivial dependency (PDF generation library), it should be documented in the PR changelog and MIGRATION.md for existing installations.


Summary

Issues 1–3 are blocking — the feature cannot be used at all in its current state (compilation error, duplicate route, no UI entry point). Please fix these before requesting a re-review. Happy to test again once resolved.
Screenshot from 2026-07-03 20-11-21

@pr-elhajji

Copy link
Copy Markdown
Contributor

Hi, thk for contuning dev.
just the design style is note aligned woth opentutorai style

@YassineElbaite

Copy link
Copy Markdown
Author

@pr-elhajji Thanks! I'll update the design to better match the OpenTutorAI style.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new “Mind Map” learning workflow that lets students build a concept map for a chat session, request AI-based verification/feedback, and export the result as a PDF. This spans a new FastAPI router, a new frontend API client, and a dedicated student UI page, with supporting documentation and a backend PDF dependency.

Changes:

  • Added new backend /api/v1/mindmap/* endpoints for context extraction, verification, and PDF export.
  • Added a frontend API client and a new student mind map editor page.
  • Added initial user/technical docs and introduced reportlab for PDF generation.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
gateway/http/routers/mindmap.py Implements mindmap context extraction, verification, and PDF export endpoints (currently needs cleanup + wiring).
ui/src/lib/apis/mindmap.ts Adds UI fetch wrappers for mindmap context/verify/export endpoints.
ui/src/routes/student/mindmap/[id]/+page.svelte New interactive mind map editor UI with verification overlay and PDF download trigger.
requirements.txt Adds reportlab dependency for backend PDF generation.
docs/mindmap-user-guide.md Adds end-user guidance for the mind map feature.
docs/mindmap-technical.md Adds technical/API documentation for the new endpoints and payloads.

Comment on lines +5 to +6
import { getMindmapContext, verifyMindmap, exportMindmapPDF } from '$lib/apis/mindmap';
import { getMindmapContext, verifyMindmap, exportMindmapPDF } from '$lib/apis/mindmap';
Comment on lines +326 to +334
<input
class="node-input"
bind:value={editValue}
on:blur={finishEdit}
on:keydown={(e) => {
if (e.key === 'Enter' || e.key === 'Escape') finishEdit();
}}
autofocus
/>
Comment on lines +321 to +324
on:dblclick|stopPropagation={() => startEdit(node.id)}
role="button"
tabindex="0"
>
Comment on lines +270 to +271
from fastapi.responses import StreamingResponse
import io
Comment on lines +273 to +277
class ExportRequest(BaseModel):
nodes: List[MindMapNode]
edges: List[MindMapEdge]
title: str = "Carte Mentale"

Comment thread docs/mindmap-technical.md
Comment on lines +54 to +55
| color | string | Node color |
| position | {x, y} | Canvas coordinates |
Comment thread docs/mindmap-technical.md
Comment on lines +57 to +61
### MindMapEdge
| Field | Type | Description |
|---|---|---|
| source | string | Source node ID |
| target | string | Target node ID |

## Tips
- Try to have at least 4 well-connected concepts for validation
- Screenshots: [insert relevant screenshots from your PR here] No newline at end of file
Comment thread docs/mindmap-technical.md
Comment on lines +31 to +38
```json
{
"validated": true/false,
"score": ...,
"covered_concepts": [...],
"missing_concepts": [...],
"feedback": "..."
}
Comment on lines +287 to +290
from reportlab.lib.pagesizes import A4
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib import colors
@Eziane

Eziane commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Salam @YassineElbaite
Thanks for the mind map feature — the concept is solid, especially the AI-verification flow reusing the existing ai/providers/proxy.py helpers instead of a new hand-rolled call. That part's good.

I went through this after @baaki-hicham's review and Copilot's automated pass, both of which are thorough and still fully open — checked the current code and nothing on either list has been addressed yet (the last commit is from before both reviews landed). Please work through baaki-hicham's 3 blockers (duplicate frontend import, duplicate export_mindmap_pdf/ExportRequest, no entry point in the chat UI) and Copilot's 14 inline comments first — I won't re-list those here.

Two things on top of that, not previously flagged:

The mindmap router isn't registered anywhere. Checked gateway/http/routers/__init__.py and gateway/http/app.py — no reference to mindmap in either. It's not just "needs cleanup," there is currently no /api/v1/mindmap/* route at all in the running app. Every call in ui/src/lib/apis/mindmap.ts 404s, and tests/test_contract_coverage.py will fail on this branch since it scans that exact file and won't find the paths in the OpenAPI schema. Small fix (add it to the router tuple + include_router(..., prefix="/api/v1") like every other domain) but it blocks testing anything else end-to-end until it's in.

Zero i18n in the new page. ui/src/routes/student/mindmap/[id]/+page.svelte — grepped for i18n, no hits anywhere in the ~890 lines. Every string is hardcoded French ('Ajoutez au moins 2 noeuds avant de verifier !', 'Bonne carte mentale !', etc.). The app ships en-US/ar-MA locales too, so right now this feature is French-only no matter what language the student has selected, with no $i18n.t() calls to hook translations into later.

Also worth a mention: reportlab is only in requirements.txt, not requirements-ci.txt. It's a lazy import inside the function so it won't break test collection like a top-level import would, but once tests get added for /export/pdf (there are none right now), they'll fail under CI's dependency set unless it's added there too.

Given how much is still open, probably worth doing a full pass against baaki-hicham's and Copilot's comments plus the two above before requesting another review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants