Mind Maps Generation Module¶
Status: Canonical Reference
Scope: Mind map generation tools in tools/mindmaps/
Last Updated: December 28, 2025 20:39:00
Created: December 10, 2025 14:57:12
This module generates interactive mind maps from NeetCode ontology and problem metadata.
Overview¶
The mind maps module provides: - 9 different mind map types visualizing different aspects of the problem space - Markdown output compatible with VS Code markmap extension - HTML output for GitHub Pages deployment - Configurable GitHub repository links
Module Structure¶
tools/mindmaps/
βββ core/ # Core module (mind map generation logic)
β βββ __init__.py # Module exports
β βββ config.py # Configuration, constants, paths
β βββ toml_parser.py # TOML parsing utilities
β βββ data.py # ProblemData class
β βββ loader.py # OntologyData and data loading
β βββ helpers.py # Helper functions (frontmatter, formatting)
β βββ html.py # HTML generation logic
β βββ templates.py # HTML/CSS templates
β βββ generators/ # Mind map generator functions
β βββ __init__.py
β βββ pattern.py # Pattern hierarchy generator
β βββ family.py # Family derivation generator
β βββ algorithm.py # Algorithm/data structure usage
β βββ company.py # Company coverage
β βββ roadmap.py # Learning roadmaps
β βββ relations.py # Problem relations network
β βββ variants.py # Solution variants
β βββ difficulty.py # Difficulty Γ Topics matrix
βββ ai-markmap-agent/ # AI-powered mindmap agent
βββ ai_mindmap/ # AI mindmap module
βββ hooks/ # Git hooks
βββ prompts/ # AI prompts
βββ shared/ # Shared utilities
βββ tests/ # Tests
βββ generate_mindmaps.py # Rule-based generator (entry)
βββ generate_mindmaps_ai.py # AI generator (entry)
βββ html_meta_description_generator.py # SEO meta generator
Core Components¶
Configuration (config.py)¶
Manages configuration for mind map generation: - GitHub repository URL and branch - Output directories - Mind map type definitions - Difficulty icons
Key Functions: - load_config() - Load configuration from file/env/defaults - get_config() - Get singleton config instance
TOML Parser (toml_parser.py)¶
Simple TOML parser for ontology files: - Handles arrays of tables [[array]] - Supports nested tables [table] - Parses strings, arrays, booleans, integers
Key Functions: - parse_toml_simple(content) - Parse TOML content - parse_toml_value(value) - Parse individual TOML values
Data Structures (data.py)¶
ProblemData - Represents a problem with metadata: - Properties: display_name, difficulty_icon - Methods: solution_link(), markdown_link(), leetcode_link()
Data Loading (loader.py)¶
OntologyData - Container for all ontology data: - API kernels, patterns, algorithms, data structures - Topics, difficulties, companies, roadmaps
Functions: - load_ontology() - Load all ontology files - load_problems() - Load problem metadata from TOML files
Helpers (helpers.py)¶
Utility functions: - markmap_frontmatter(title, color_freeze_level) - Generate YAML frontmatter - format_problem_entry(prob, show_complexity) - Format problem entry
HTML Generation (html.py)¶
HTML output generation: - generate_html_mindmap(title, markdown, use_autoloader) - Generate HTML file - markdown_to_html_content(markdown) - Extract content without frontmatter - setup_pages_directory(pages_dir) - Create directory structure
Templates (templates.py)¶
HTML templates and CSS: - HTML_TEMPLATE_MANUAL - Manual markmap initialization - HTML_TEMPLATE_AUTOLOADER - Using markmap-autoloader - INDEX_HTML_TEMPLATE - Index page template - STYLE_CSS - CSS stylesheet - CARD_TEMPLATE - Mind map card template
Generators (generators/)¶
Each generator function takes (ontology: OntologyData, problems: dict[str, ProblemData]) and returns a markdown string.
Available Generators:
- pattern.py -
generate_pattern_hierarchy() - API Kernel β Patterns β Problems hierarchy
-
Shows how kernels are instantiated as patterns and used in problems
-
family.py -
generate_family_derivation() - Base templates and derived variants
-
Shows problem families with base/variant relationships
-
algorithm.py -
generate_algorithm_usage(),generate_data_structure() - Algorithms/Data structures β Problems mapping
-
Shows which algorithms/data structures are used in which problems
-
company.py -
generate_company_coverage() - Companies β Problems mapping
-
Shows problems frequently asked by companies
-
roadmap.py -
generate_roadmap_paths() - Learning roadmap structures
-
Shows curated problem sequences for different learning goals
-
relations.py -
generate_problem_relations() - Related problems network
-
Shows how problems are connected to each other
-
variants.py -
generate_solution_variants() - Problems with multiple solution approaches
-
Shows different solution strategies for the same problem
-
difficulty.py -
generate_difficulty_topics() - Difficulty Γ Topics matrix
- Shows topics organized by difficulty level
Usage Examples¶
Basic Usage¶
from mindmaps.core import (
load_ontology,
load_problems,
GENERATORS,
)
# Load data
ontology = load_ontology()
problems = load_problems()
# Generate a specific mind map
content = GENERATORS["pattern_hierarchy"](ontology, problems)
print(content)
Generate HTML¶
from mindmaps.core import generate_html_mindmap
markdown = "# Test Map\n\n## Section"
html = generate_html_mindmap("Test Title", markdown, use_autoloader=False)
Custom Configuration¶
from mindmaps.core import get_config, MindmapsConfig
import os
# Override via environment variables
os.environ["GITHUB_REPO_URL"] = "https://github.com/user/repo"
os.environ["GITHUB_BRANCH"] = "main"
config = get_config()
print(config.github_repo_url)
Mind Map Types¶
| Type | Description | Generator |
|---|---|---|
pattern_hierarchy | API Kernels β Patterns β Problems | pattern.py |
family_derivation | Base templates β Variants | family.py |
algorithm_usage | Algorithms β Problems | algorithm.py |
data_structure | Data Structures β Problems | algorithm.py |
company_coverage | Companies β Problems | company.py |
roadmap_paths | Learning Roadmaps | roadmap.py |
problem_relations | Related Problems Network | relations.py |
solution_variants | Multiple Solutions | variants.py |
difficulty_topics | Difficulty Γ Topics Matrix | difficulty.py |
Configuration File¶
Create tools/mindmaps/generate_mindmaps.toml:
Output Format¶
Markdown Output¶
Each mind map is a Markdown file with YAML frontmatter:
---
title: Pattern Hierarchy - API Kernels β Patterns β Problems
markmap:
colorFreezeLevel: 2
maxWidth: 400
---
# Pattern Hierarchy
## API Kernel Name
*Description*
### Pattern Name
*Pattern description*
- π‘ [LeetCode 3 - Problem Name](link)
HTML Output¶
HTML files include: - Full markmap library integration - Custom toolbar (Fit View, Expand All, Collapse All) - Responsive design - GitHub Pages ready
Testing¶
The module is tested in .dev/tests/test_generate_mindmaps.py:
Test coverage includes: - TOML parsing - Data loading - All 9 generator functions - HTML generation - Configuration loading - Edge cases
Development¶
Adding a New Generator¶
- Create a new file in
core/generators/(e.g.,custom.py) - Implement generator function:
- Add to
core/generators/__init__.py: - Add to
MINDMAP_TYPESincore/config.py - Add tests in
.dev/tests/test_generate_mindmaps.py
Module Size Guidelines¶
- Each file should be < 100 lines (except templates)
- Each generator function should be < 80 lines
- Keep functions focused and single-purpose
See Also¶
- Main Tools README - Overview of all tools
- AI Markmap Agent - AI-powered mind map generation
- CLI Usage - Command-line interface
- Test Suite - Test coverage