# pascalh/astview architecture

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

- Interactive diagram: https://gitdiagram.com/pascalh/astview
- Repository: https://github.com/pascalh/astview

## Overview

##### Main Components

a) GUI Layer (src/gui/)
- Main window interface
- Menu system
- Source code editor
- Tree visualization component

b) Core Layer (src/core/)
- Language parsers
- AST data structures
- Source location handling

c) Language-Specific Components
- Haskell parser
- Python parser
- Extensible language support system

##### Key Architectural Elements

**┌─────────────────────────────────────────┐**
- GUI Layer                 │
- ┌─────────────┐  ┌──────────────────┐ │
- Editor    │  │  Tree Viewer     │ │
- ┘  └──────────────────┘ │
- ┤
- Core Layer                │
- ┌─────────────┐  ┌──────────────────┐ │
- AST Manager │  │ Language Parsers  │ │
- ┘  └──────────────────┘ │
- ┤
- Language-Specific Layer         │
- ┌─────────────┐  ┌──────────────────┐ │
- Haskell   │  │      Python      │ │
- ┘  └──────────────────┘ │
- ┘

##### Component Interactions

- User input → Editor
- Editor → AST Manager (for parsing)
- AST Manager → Language Parsers
- Language Parsers → Tree Viewer
- Tree Viewer → Source Location Handler (for navigation)

##### Special Features to Highlight

- File extension detection system
- Source location navigation
- Flattening functionality
- Menu system

##### Technical Details

Annotations showing:
- GTK for GUI (evident from GtkActions.hs)
- Stack/Cabal build system
- Test framework integration

##### Design Patterns to Emphasize

Following architectural patterns:
- Layered architecture (GUI/Core/Language)
- Plugin system for language support
- Model-View separation (AST data vs. visualization)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph GUI["GUI Layer"]
        MainWindow["Main Window Interface"]
        MenuSystem["Menu System"]
        Editor["Source Code Editor"]
        TreeViewer["Tree Visualization"]
        GUIActions["GUI Actions"]
        GUITypes["GUI Types"]
        GUIInit["GUI Initialization"]
    end

    subgraph Core["Core Layer"]
        ASTManager["AST Manager"]
        ParserInfra["Parser Infrastructure"]
        LangSupport["Language Support"]
        SrcLocHandler["Source Location Handler"]
        DataTree["AST Data Structures"]
    end

    subgraph Lang["Language-Specific Layer"]
        HaskellParser["Haskell Parser"]
        HaskellCore["Haskell Core"]
        PythonParser["Python Parser"]
    end

    subgraph Config["Configuration"]
        MenuConfig["Menu Configuration"]
        AppConfig["Application Configuration"]
    end

    subgraph Tests["Test Suite"]
        DataTreeTests["Data Tree Tests"]
        SrcLocTests["Source Location Tests"]
        CursorTests["Cursor Location Tests"]
    end

    %% Interactions
    Editor --> ASTManager
    ASTManager --> ParserInfra
    ParserInfra --> TreeViewer
    TreeViewer --> SrcLocHandler
    MenuSystem --> GUIActions
    GUIActions --> ASTManager
    GUIInit --> MainWindow
    MainWindow --> TreeViewer
    ParserInfra --> HaskellParser
    ParserInfra --> PythonParser
    HaskellParser --> HaskellCore
    MenuConfig --> MenuSystem
    AppConfig --> GUIInit
    DataTree --> ASTManager
    LangSupport --> ParserInfra

    %% Click events for component mapping
    click MainWindow "https://github.com/pascalh/Astview/blob/master/src/gui/Language/Astview/Gui/GtkActions.hs"
    click MenuSystem "https://github.com/pascalh/Astview/blob/master/src/gui/Language/Astview/Gui/Menu.hs"
    click GUIActions "https://github.com/pascalh/Astview/blob/master/src/gui/Language/Astview/Gui/Actions.hs"
    click GUITypes "https://github.com/pascalh/Astview/blob/master/src/gui/Language/Astview/Gui/Types.hs"
    click GUIInit "https://github.com/pascalh/Astview/blob/master/src/gui/Language/Astview/Gui/Init.hs"
    click DataTree "https://github.com/pascalh/Astview/blob/master/src/core/Language/Astview/DataTree.hs"
    click ParserInfra "https://github.com/pascalh/Astview/blob/master/src/core/Language/Astview/Language.hs"
    click LangSupport "https://github.com/pascalh/Astview/blob/master/src/core/Language/Astview/Languages.hs"
    click SrcLocHandler "https://github.com/pascalh/Astview/blob/master/src/core/Language/Astview/SmallestSrcLocContainingCursor.hs"
    click HaskellParser "https://github.com/pascalh/Astview/blob/master/src/core/Language/Astview/Languages/Haskell.hs"
    click HaskellCore "https://github.com/pascalh/Astview/blob/master/src/core/Language/Astview/Languages/HaskellCore.hs"
    click PythonParser "https://github.com/pascalh/Astview/blob/master/src/core/Language/Astview/Languages/Python.hs"
    click MenuConfig "https://github.com/pascalh/Astview/blob/master/data/menu.xml"
    click AppConfig "https://github.com/pascalh/Astview/blob/master/data/astview.xml"
    click DataTreeTests "https://github.com/pascalh/Astview/blob/master/test/DataTree.hs"
    click SrcLocTests "https://github.com/pascalh/Astview/blob/master/test/SourceLocation.hs"
    click CursorTests "https://github.com/pascalh/Astview/blob/master/test/SmallestSrcLocContainingCursor.hs"

    %% Styling
    classDef gui fill:#a8d1f0
    classDef core fill:#90EE90
    classDef lang fill:#FFB347
    classDef config fill:#D3D3D3
    classDef test fill:#E6E6FA

    class MainWindow,MenuSystem,Editor,TreeViewer,GUIActions,GUITypes,GUIInit gui
    class ASTManager,ParserInfra,LangSupport,SrcLocHandler,DataTree core
    class HaskellParser,HaskellCore,PythonParser lang
    class MenuConfig,AppConfig config
    class DataTreeTests,SrcLocTests,CursorTests test
```
