# ntwo1980/ankimindmap architecture

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

- Interactive diagram: https://gitdiagram.com/ntwo1980/ankimindmap
- Repository: https://github.com/ntwo1980/ankimindmap

## Overview

##### Main Components
- Anki Host Application: The platform where the imported deck adds a new note type named “MindMap Cloze.”
- MindMap Cloze Package: The .apkg file that contains the note type definition and its related templates.
- Markmap Integration: This component adds mind map visualizations to notes by rendering Markdown using the Markmap framework. It is supported via specific Markdown syntax and configurations.
- Configuration/Customization Layer: The YAML settings at the beginning of the note allow users to customize aspects such as width, height, fold behavior, and display options of the mind map.

##### Relationships and Interactions
- The MindMapCloze.apkg file is imported into Anki, which integrates it as a new note type.
- When Anki loads a card of this type, the note uses Markdown processing along with Markmap (as indicated by the Markdown Syntax section) to render the mind map.
- The configuration block (with keys like markmap, width, height, foldExpression, hideAllShowOne) instructs the rendering logic to adjust the layout and behavior of the mind map.
- The rendered mind map is presented on the card front and back (as shown in the screenshots), and the system automatically adjusts large maps to fit the display.

##### Architectural Patterns or Design Principles
- Integration Pattern: The project leverages Anki’s extensibility by adding a new note type via an .apkg import.
- Presentation Separation: There’s a clear separation between the definition of the note type (data/template) and its rendering logic (Markdown and Markmap processing).
- Configurability: The use of a YAML front matter block demonstrates a design that allows dynamic configuration of the view, such as zoom and fold behavior for large mind maps.

##### Relevant Technologies and Their Roles
- Anki: The flashcard application where the custom note type is deployed.
- Markmap (and Markdown): Used to render the mind map visualization dynamically.
- JavaScript Regular Expressions: Utilized in the foldExpression setting to help determine which branches to fold in large mind maps.
- YAML: For configuration declaration within the note.
- The .apkg file format: Represents the portable Anki package containing the note type and related templates.

## Diagram (Mermaid)

```mermaid
flowchart TD
    B["MindMap Cloze Note Type (.apkg)"]:::noteType
    A["Anki Host Application"]:::ankiHost
    C["Markdown Renderer / Markmap Integration"]:::integration
    D["Configuration Settings (YAML)"]:::config
    E["Card View (Rendered Mind Map)"]:::view

    B -->|"imported"| A
    A -->|"loadsNoteType"| C
    C -->|"readsYAML"| D
    C -->|"rendersOutput"| E

    click B "https://github.com/ntwo1980/ankimindmap/blob/main/MindMapCloze.apkg"
    click C "https://github.com/ntwo1980/ankimindmap/blob/main/README.md"
    click D "https://github.com/ntwo1980/ankimindmap/blob/main/README.md"

    classDef anki fill:#B3E5FC,stroke:#0288D1,stroke-width:2px;
    classDef noteType fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef integration fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
    classDef config fill:#FFECB3,stroke:#F57C00,stroke-width:2px;
    classDef view fill:#D1C4E9,stroke:#7E57C2,stroke-width:2px;
```
