How azula1a89/mindmap works
Based on our analysis of the file tree and the README, we know that this project is a standalone mindmap editor written in C++ with support for both manual and auto layout (with graph routing) and an optional integration with a locally running LLM (via Ollama) for idea generation. The application is Windows-only and uses a combination of third-party libraries (such as imgui for GUI, glfw/glew for graphics, fmt for formatting, inja for template-based output generation, and others for JSON handling, base64 encoding, file dialogs, and image support).
Main Components
• User Interface (UI):
• This component handles canvas interaction (node creation, edge manipulation, zoom/pan, editing), theme switching (dark/light/classic), and managing input events.
• It is implemented with the help of the third-party libraries imgui (with its backends for glfw and OpenGL3), glfw, and glew.
• Core Mindmap Engine:
• The “src” folder contains files like main.cpp, mindmap.cpp, mindmap_state_machine.h, and several components related to graph layout and commands. These together form the core engine, processing user actions, applying state machines, managing undo/redo operations, and coordinating graph layout and editing logic.
• Template and Export Engine:
• The “templates” directory houses various template files (for SVG, HTML, JSON outputs, and even configuration files like imgui.ini). This engine uses inja and json libraries so that the export formats can be customized.
• LLM Integration Module:
• While not a separate folder, the README and references to "LLM" and "Ollama" suggest that part of the system can call an LLM (if run locally) to generate ideas. This functionality is likely integrated in the core logic (perhaps triggered via UI, with configurable prompts using a template system) and uses the httplib for API calls.
• Third-Party Libraries & Build Infrastructure:
• The “thirdparty” directory holds many libraries that provide rendering (imgui, glfw, glew), templating (inja), JSON processing (json), layout (libavoid, libcola, libvpsc), and support utilities (base64, fmt, stb_image, native file dialog).
• The CMakeLists.txt at the top level and within some subdirectories indicate a CMake-based build system.
Relationships and Data Flow
• UI Layer:
• Connects directly with the Mindmap engine – capturing user events (mouse clicks, drags, keyboard shortcuts) and propagating commands.
• Communicates with the rendering libraries (imgui, OpenGL via glfw/glew) to update what the user sees.
• Core Engine:
• Processes commands from the UI.
• Updates the mindmap state (nodes, edges, groups, animations, layout positions) and invokes the auto-layout algorithms (provided partly via libavoid/libcola/libvpsc).
• Orchestrates exporting operations by calling the Template Engine when the user requests an export action.
• May trigger the LLM integration to supply inspiration by formatting an API call via httplib.
• Export/Template Engine:
• Reads template files and uses inja along with the json library to generate final outputs (SVG, HTML) based on the current mindmap state.
• LLM Integration:
• When the user selects a trigger (for example, by right-clicking the “ai.” button), the module prepares an API call to a local Ollama instance, using a configurable prompt (possibly set by templates) and then integrates the returned ideas back into the mindmap.
Architectural Patterns and Design Principles
• Separation of Concerns:
• UI, business logic (mindmap editing), and export processing are well-separated.
• Third-party libraries are encapsulated within their own directories, supporting modular design.
• Event-Driven & Command Patterns:
• The operations like node selection, editing, and undo/redo indicate a command-based pattern.
• Template-Driven Customization:
• The use of an external template engine (via files in the templates directory) allows for customizable export formats.
• Integration with External Services:
• The integration with an LLM via HTTP calls is abstracted and made configurable, showing principles of loosely-coupled design.
Additional Elements
• A Build/Deployment block that indicates the CMake-based build process and that the application is compiled for Windows (MSYS2-UCRT64).
• Notes on how the state machine and command patterns support undo/redo and interactive editing (this might be a sub-component of the Core Engine).