# mickeynp/combobulate architecture

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

- Interactive diagram: https://gitdiagram.com/mickeynp/combobulate
- Repository: https://github.com/mickeynp/combobulate

## Overview

##### Main Components and Architecture

a. Core Components:
- Language Support Modules (combobulate-*.el files)
- Navigation Engine (combobulate-navigation.el)
- Manipulation Engine (combobulate-manipulation.el)
- Query System (combobulate-query.el)
- Interface Layer (combobulate-interface.el)
- System (combobulate-display.el)

b. Language-Specific Components:
- Grammar Definitions (build/*.json files)
- Language Modules:
- Python (combobulate-python.el)
- JavaScript/TypeScript (combobulate-js-ts.el)
- HTML (combobulate-html.el)
- CSS (combobulate-css.el)
- And others...

##### Component Relationships

**[Tree-Sitter Core] <---> [Combobulate Core] <---> [Language Modules]**
- ^

- [User Interface]
- ^

- [Emacs Editor Integration]

##### Data Flow

**[Source Code] -> [Tree-Sitter Parser] -> [Syntax Tree] -> [Combobulate Navigation/Editing] -> [Buffer Modifications]**

##### Key Design Elements

Important architectural patterns:

a. Extension System:
- How language modules plug into the core system
- Demonstrate grammar definition integration
- Query system interaction

b. Command System:
- Navigation commands
- Editing commands
- Envelope (templating) system
- Multiple cursor support

##### Component Details

- Name
- Primary responsibility
- Key interfaces
- Dependencies

##### Integration Points

Integration with:
- Emacs editor
- Tree-sitter library
- Major modes
- Minor mode system

##### The user interface components

Use a hierarchical layout with:
- Core components at the center
- Language modules arranged around the core
- External dependencies at the edges
- Clear separation of concerns between layers

This architecture emphasizes Combobulate's design philosophy of extensibility, language independence, and integration with existing Emacs features while maintaining a shallow learning curve for users.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph External["External Dependencies"]
        TS["Tree-Sitter Library"]:::external
        Emacs["Emacs Editor"]:::external
    end

    subgraph Core["Core System"]
        Nav["Navigation Engine"]:::core
        Manip["Manipulation Engine"]:::core
        Query["Query System"]:::core
        Interface["Interface Layer"]:::core
        Display["Display System"]:::core
        Cursor["Cursor Support"]:::core
        Envelope["Envelope System"]:::core
        Debug["Debug System"]:::core
        Setup["Setup System"]:::core
    end

    subgraph Lang["Language Modules"]
        Python["Python Support"]:::lang
        JSTS["JavaScript/TypeScript"]:::lang
        HTML["HTML Support"]:::lang
        CSS["CSS Support"]:::lang
        Go["Go Support"]:::lang
        YAML["YAML Support"]:::lang
        JSON["JSON Support"]:::lang
        TOML["TOML Support"]:::lang
    end

    subgraph Grammar["Grammar Definitions"]
        PyGrammar["Python Grammar"]:::grammar
        JSGrammar["JavaScript Grammar"]:::grammar
        TSGrammar["TypeScript Grammar"]:::grammar
        HTMLGrammar["HTML Grammar"]:::grammar
        CSSGrammar["CSS Grammar"]:::grammar
        GoGrammar["Go Grammar"]:::grammar
        YAMLGrammar["YAML Grammar"]:::grammar
        JSONGrammar["JSON Grammar"]:::grammar
        TOMLGrammar["TOML Grammar"]:::grammar
    end

    Emacs --> Interface
    TS --> Query
    Interface --> Nav
    Interface --> Manip
    Interface --> Display
    Query --> Nav
    Query --> Manip
    Nav --> Lang
    Manip --> Lang
    Lang --> Grammar
    Cursor --> Manip
    Envelope --> Manip
    Debug --> Core
    Setup --> Core

    %% Click events for component mapping
    click Nav "https://github.com/mickeynp/combobulate/blob/master/combobulate-navigation.el"
    click Manip "https://github.com/mickeynp/combobulate/blob/master/combobulate-manipulation.el"
    click Query "https://github.com/mickeynp/combobulate/blob/master/combobulate-query.el"
    click Interface "https://github.com/mickeynp/combobulate/blob/master/combobulate-interface.el"
    click Display "https://github.com/mickeynp/combobulate/blob/master/combobulate-display.el"
    click Cursor "https://github.com/mickeynp/combobulate/blob/master/combobulate-cursor.el"
    click Envelope "https://github.com/mickeynp/combobulate/blob/master/combobulate-envelope.el"
    click Debug "https://github.com/mickeynp/combobulate/blob/master/combobulate-debug.el"
    click Setup "https://github.com/mickeynp/combobulate/blob/master/combobulate-setup.el"

    click Python "https://github.com/mickeynp/combobulate/blob/master/combobulate-python.el"
    click JSTS "https://github.com/mickeynp/combobulate/blob/master/combobulate-js-ts.el"
    click HTML "https://github.com/mickeynp/combobulate/blob/master/combobulate-html.el"
    click CSS "https://github.com/mickeynp/combobulate/blob/master/combobulate-css.el"
    click Go "https://github.com/mickeynp/combobulate/blob/master/combobulate-go.el"
    click YAML "https://github.com/mickeynp/combobulate/blob/master/combobulate-yaml.el"
    click JSON "https://github.com/mickeynp/combobulate/blob/master/combobulate-json.el"
    click TOML "https://github.com/mickeynp/combobulate/blob/master/combobulate-toml.el"

    click PyGrammar "https://github.com/mickeynp/combobulate/blob/master/build/python-grammar.json"
    click JSGrammar "https://github.com/mickeynp/combobulate/blob/master/build/javascript-grammar.json"
    click TSGrammar "https://github.com/mickeynp/combobulate/blob/master/build/typescript-grammar.json"
    click HTMLGrammar "https://github.com/mickeynp/combobulate/blob/master/build/html-grammar.json"
    click CSSGrammar "https://github.com/mickeynp/combobulate/blob/master/build/css-grammar.json"
    click GoGrammar "https://github.com/mickeynp/combobulate/blob/master/build/go-grammar.json"
    click YAMLGrammar "https://github.com/mickeynp/combobulate/blob/master/build/yaml-grammar.json"
    click JSONGrammar "https://github.com/mickeynp/combobulate/blob/master/build/json-grammar.json"
    click TOMLGrammar "https://github.com/mickeynp/combobulate/blob/master/build/toml-grammar.json"

    classDef external fill:#FFE873
    classDef core fill:#7CB9E8
    classDef lang fill:#90EE90
    classDef grammar fill:#F4C430

    %% Legend
    subgraph Legend
        L1["External Dependencies"]:::external
        L2["Core Components"]:::core
        L3["Language Modules"]:::lang
        L4["Grammar Definitions"]:::grammar
    end
```
