# thongken/local architecture

> Architecture diagram of the GitHub repository thongken/local, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thongken/local
- Repository: https://github.com/thongken/local

## Overview

This repository provides two Moodle plugins: Microlearning and PDF Quiz AI. Teachers supply audio, recordings, or PDFs, generate quizzes or lectures, review drafts, and save material into courses; students can reopen saved material and use quiz or lecture study support. The graph also captures browser-side speech processing, private narration generation, and PDF extraction/AI processing. Some PHP routes and service wiring were not excerpted; those connections are omitted or marked unverified rather than inferred from filenames.

Main entry points: [`microlearning/frontend/src/app.js`](https://github.com/thongken/local/blob/main/microlearning/frontend/src/app.js) (Audio and recording UI), [`microlearning/index.php`](https://github.com/thongken/local/blob/main/microlearning/index.php) (Study tools), [`pdfquiz/python_service/server.py`](https://github.com/thongken/local/blob/main/pdfquiz/python_service/server.py) (PDF processing API), [`microlearning/classes/external/create_quiz.php`](https://github.com/thongken/local/blob/main/microlearning/classes/external/create_quiz.php) (Content authoring)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_moodle["Moodle workflows"]
  node_ml_entry["Study tools<br/>[index.php]"]
  node_ml_author["Content authoring<br/>[create_quiz.php]"]
  node_ml_saved[("Saved study items<br/>[save_item.php]")]
  node_ml_student["Study assistant"]
  node_pdf_routes["PDF and lecture workflows<br/>[process_pdf.php]"]
  node_pdf_progress[("Practice progress")]
end

subgraph group_browser["Microlearning browser"]
  node_ml_app["Audio and recording UI<br/>[app.js]"]
  node_ml_audio["Audio capture<br/>[audio.js]"]
  node_ml_pipeline["Speech pipeline<br/>[pipeline.js]"]
  node_ml_workers["Speech workers<br/>[vad.worker.js]"]
  node_ml_quiz["Quiz generation<br/>[gemini.js]"]
  node_ml_lecture["Lecture generation<br/>[lecture.js]"]
  node_ml_validate["Content validation<br/>[validator.js]"]
end

subgraph group_narration["Narration services"]
  node_ml_narration["Narration jobs"]
  node_ml_task["Narration task"]
  node_ml_speech["Speech client<br/>[speech_client.php]"]
  node_ml_engine["Speech engine API<br/>[server.py]"]
  node_ml_synthesis["WAV synthesis<br/>[synthesis.py]"]
end

subgraph group_pdf["PDF Quiz services"]
  node_pdf_client["PDF service client<br/>[pdf_client.php]"]
  node_pdf_service["PDF processing API<br/>[server.py]"]
  node_pdf_parser["PDF extraction<br/>[pdf_parser.py]"]
  node_pdf_vision["Visual analysis<br/>[vision_cv.py]"]
  node_pdf_ai["Quiz and lecture AI<br/>[ai_router.py]"]
end

node_teacher(("Teacher"))
node_student(("Student"))

node_teacher -->|"opens tools"| node_ml_entry
node_student -->|"opens study"| node_ml_entry
node_ml_entry -->|"offers authoring"| node_ml_author
node_ml_entry -->|"offers PDF tools"| node_pdf_routes
node_ml_entry -->|"links study support"| node_ml_student
node_ml_author -.->|"loads browser tool"| node_ml_app
node_ml_app -->|"captures audio"| node_ml_audio
node_ml_app -->|"transcribes recording"| node_ml_pipeline
node_ml_pipeline -->|"dispatches audio"| node_ml_workers
node_ml_app -->|"generates quiz"| node_ml_quiz
node_ml_app -->|"generates lecture"| node_ml_lecture
node_ml_app -->|"validates content"| node_ml_validate
node_ml_app -->|"saves item"| node_ml_saved
node_ml_author -->|"persists draft"| node_ml_saved
node_ml_narration -->|"queues job"| node_ml_task
node_ml_narration -->|"prepares voice"| node_ml_speech
node_ml_task -.->|"processes job"| node_ml_narration
node_ml_speech -.->|"calls speech API"| node_ml_engine
node_ml_engine -->|"synthesizes WAV"| node_ml_synthesis
node_pdf_routes -.->|"requests processing"| node_pdf_client
node_pdf_client -.->|"calls HTTP API"| node_pdf_service
node_pdf_service -->|"extracts pages"| node_pdf_parser
node_pdf_service -->|"analyzes visuals"| node_pdf_vision
node_pdf_service -->|"generates content"| node_pdf_ai
node_pdf_routes -.->|"supports practice"| node_pdf_progress
node_student -->|"practices quizzes"| node_pdf_progress
node_student -->|"reopens saved items"| node_ml_saved

click node_ml_entry "https://github.com/thongken/local/blob/main/microlearning/index.php"
click node_ml_author "https://github.com/thongken/local/blob/main/microlearning/classes/external/create_quiz.php"
click node_ml_saved "https://github.com/thongken/local/blob/main/microlearning/classes/external/save_item.php"
click node_ml_student "https://github.com/thongken/local/blob/main/microlearning/classes/local/study_assistant.php"
click node_ml_app "https://github.com/thongken/local/blob/main/microlearning/frontend/src/app.js"
click node_ml_audio "https://github.com/thongken/local/blob/main/microlearning/frontend/src/audio.js"
click node_ml_pipeline "https://github.com/thongken/local/blob/main/microlearning/frontend/src/pipeline.js"
click node_ml_workers "https://github.com/thongken/local/blob/main/microlearning/frontend/src/vad.worker.js"
click node_ml_quiz "https://github.com/thongken/local/blob/main/microlearning/frontend/src/gemini.js"
click node_ml_lecture "https://github.com/thongken/local/blob/main/microlearning/frontend/src/lecture.js"
click node_ml_validate "https://github.com/thongken/local/blob/main/microlearning/frontend/src/validator.js"
click node_ml_narration "https://github.com/thongken/local/blob/main/microlearning/classes/local/narration_service.php"
click node_ml_task "https://github.com/thongken/local/blob/main/microlearning/classes/task/generate_narration.php"
click node_ml_speech "https://github.com/thongken/local/blob/main/microlearning/classes/local/speech_client.php"
click node_ml_engine "https://github.com/thongken/local/blob/main/microlearning/engine/server.py"
click node_ml_synthesis "https://github.com/thongken/local/blob/main/microlearning/engine/synthesis.py"
click node_pdf_routes "https://github.com/thongken/local/blob/main/pdfquiz/process_pdf.php"
click node_pdf_client "https://github.com/thongken/local/blob/main/pdfquiz/classes/local/pdf_client.php"
click node_pdf_service "https://github.com/thongken/local/blob/main/pdfquiz/python_service/server.py"
click node_pdf_parser "https://github.com/thongken/local/blob/main/pdfquiz/python_service/src/extractors/pdf_parser.py"
click node_pdf_vision "https://github.com/thongken/local/blob/main/pdfquiz/python_service/src/core/vision_cv.py"
click node_pdf_ai "https://github.com/thongken/local/blob/main/pdfquiz/python_service/src/ai_router.py"
click node_pdf_progress "https://github.com/thongken/local/blob/main/pdfquiz/classes/local/practice_progress.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ml_entry,node_ml_author,node_ml_saved,node_ml_student,node_pdf_routes,node_pdf_progress toneBlue
class node_ml_app,node_ml_audio,node_ml_pipeline,node_ml_workers,node_ml_quiz,node_ml_lecture,node_ml_validate toneAmber
class node_ml_narration,node_ml_task,node_ml_speech,node_ml_engine,node_ml_synthesis toneMint
class node_pdf_client,node_pdf_service,node_pdf_parser,node_pdf_vision,node_pdf_ai toneRose
class node_teacher,node_student toneIndigo
```

## Components

### Moodle workflows

- [Study tools](https://github.com/thongken/local/blob/main/microlearning/index.php): `microlearning/index.php`
- [Content authoring](https://github.com/thongken/local/blob/main/microlearning/classes/external/create_quiz.php): `microlearning/classes/external/create_quiz.php`
- [Saved study items](https://github.com/thongken/local/blob/main/microlearning/classes/external/save_item.php): `microlearning/classes/external/save_item.php`
- [Study assistant](https://github.com/thongken/local/blob/main/microlearning/classes/local/study_assistant.php): `microlearning/classes/local/study_assistant.php`
- [PDF and lecture workflows](https://github.com/thongken/local/blob/main/pdfquiz/process_pdf.php): `pdfquiz/process_pdf.php`
- [Practice progress](https://github.com/thongken/local/blob/main/pdfquiz/classes/local/practice_progress.php): `pdfquiz/classes/local/practice_progress.php`

### Microlearning browser

- [Audio and recording UI](https://github.com/thongken/local/blob/main/microlearning/frontend/src/app.js): `microlearning/frontend/src/app.js`
- [Audio capture](https://github.com/thongken/local/blob/main/microlearning/frontend/src/audio.js): `microlearning/frontend/src/audio.js`
- [Speech pipeline](https://github.com/thongken/local/blob/main/microlearning/frontend/src/pipeline.js): `microlearning/frontend/src/pipeline.js`
- [Speech workers](https://github.com/thongken/local/blob/main/microlearning/frontend/src/vad.worker.js): `microlearning/frontend/src/vad.worker.js`
- [Quiz generation](https://github.com/thongken/local/blob/main/microlearning/frontend/src/gemini.js): `microlearning/frontend/src/gemini.js`
- [Lecture generation](https://github.com/thongken/local/blob/main/microlearning/frontend/src/lecture.js): `microlearning/frontend/src/lecture.js`
- [Content validation](https://github.com/thongken/local/blob/main/microlearning/frontend/src/validator.js): `microlearning/frontend/src/validator.js`

### Narration services

- [Narration jobs](https://github.com/thongken/local/blob/main/microlearning/classes/local/narration_service.php): `microlearning/classes/local/narration_service.php`
- [Narration task](https://github.com/thongken/local/blob/main/microlearning/classes/task/generate_narration.php): `microlearning/classes/task/generate_narration.php`
- [Speech client](https://github.com/thongken/local/blob/main/microlearning/classes/local/speech_client.php): `microlearning/classes/local/speech_client.php`
- [Speech engine API](https://github.com/thongken/local/blob/main/microlearning/engine/server.py): `microlearning/engine/server.py`
- [WAV synthesis](https://github.com/thongken/local/blob/main/microlearning/engine/synthesis.py): `microlearning/engine/synthesis.py`

### PDF Quiz services

- [PDF service client](https://github.com/thongken/local/blob/main/pdfquiz/classes/local/pdf_client.php): `pdfquiz/classes/local/pdf_client.php`
- [PDF processing API](https://github.com/thongken/local/blob/main/pdfquiz/python_service/server.py): `pdfquiz/python_service/server.py`
- [PDF extraction](https://github.com/thongken/local/blob/main/pdfquiz/python_service/src/extractors/pdf_parser.py): `pdfquiz/python_service/src/extractors/pdf_parser.py`
- [Visual analysis](https://github.com/thongken/local/blob/main/pdfquiz/python_service/src/core/vision_cv.py): `pdfquiz/python_service/src/core/vision_cv.py`
- [Quiz and lecture AI](https://github.com/thongken/local/blob/main/pdfquiz/python_service/src/ai_router.py): `pdfquiz/python_service/src/ai_router.py`

### Other components

- **Teacher**
- **Student**

## Connections

- Teacher → Study tools: opens tools (evidence: `microlearning/index.php`)
- Student → Study tools: opens study (evidence: `microlearning/index.php`)
- Study tools → Content authoring: offers authoring (evidence: `microlearning/index.php`)
- Study tools → PDF and lecture workflows: offers PDF tools (evidence: `microlearning/index.php`)
- Study tools → Study assistant: links study support (evidence: `microlearning/index.php`)
- Content authoring → Audio and recording UI: loads browser tool
- Audio and recording UI → Audio capture: captures audio (evidence: `microlearning/frontend/src/app.js`)
- Audio and recording UI → Speech pipeline: transcribes recording (evidence: `microlearning/frontend/src/app.js`)
- Speech pipeline → Speech workers: dispatches audio (evidence: `microlearning/frontend/src/pipeline.js`)
- Audio and recording UI → Quiz generation: generates quiz (evidence: `microlearning/frontend/src/app.js`)
- Audio and recording UI → Lecture generation: generates lecture (evidence: `microlearning/frontend/src/app.js`)
- Audio and recording UI → Content validation: validates content (evidence: `microlearning/frontend/src/app.js`)
- Audio and recording UI → Saved study items: saves item (evidence: `microlearning/frontend/src/app.js`)
- Content authoring → Saved study items: persists draft
- Narration jobs → Narration task: queues job (evidence: `microlearning/classes/local/narration_service.php`)
- Narration jobs → Speech client: prepares voice (evidence: `microlearning/classes/local/narration_service.php`)
- Narration task → Narration jobs: processes job (evidence: `microlearning/classes/local/narration_service.php`)
- Speech client → Speech engine API: calls speech API
- Speech engine API → WAV synthesis: synthesizes WAV (evidence: `microlearning/engine/server.py`)
- PDF and lecture workflows → PDF service client: requests processing
- PDF service client → PDF processing API: calls HTTP API
- PDF processing API → PDF extraction: extracts pages (evidence: `pdfquiz/python_service/server.py`)
- PDF processing API → Visual analysis: analyzes visuals (evidence: `pdfquiz/python_service/server.py`)
- PDF processing API → Quiz and lecture AI: generates content (evidence: `pdfquiz/python_service/server.py`)
- PDF and lecture workflows → Practice progress: supports practice
- Student → Practice progress: practices quizzes
- Student → Saved study items: reopens saved items
