# fragglet/wadgadget architecture

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

- Interactive diagram: https://gitdiagram.com/fragglet/wadgadget
- Repository: https://github.com/fragglet/wadgadget

## Overview

##### Main System Components

a. User Interface Layer
- Ncurses-based TUI components (src/ui/)
- Browser, pager, and dialog subsystems
- Two-pane interface design

b. Core Processing Layer
- File System Handler (src/fs/)
- Conversion Utilities (src/conv/)
- Texture Management (src/textures/)
- Palette Management (src/palette/)

c. File Format Support
- WAD file handling
- Import/Export capabilities
- File system integration

##### Component Relationships

**[User Input] → [UI Layer] → [Core Processing] → [File System]**
- ↑             ↑                   ↓
- ┴───────[Data Flow]─┘

##### Specific Implementation Details

a. UI Components (src/ui/):
- Actions Bar
- Pane
- Text Input
- Title Bar
- Dialog System
- Stack Management

b. File System Handlers (src/fs/):
- Virtual File System (VFS)
- WAD Directory Handler
- Real Directory Handler
- File Set Management

c. Conversion Modules (src/conv/):
- Audio Processing
- Graphic Conversion
- Palette Management
- MUS to MIDI Conversion
- PNG Support

##### Important Architectural Patterns

Highlight:
- The MVC-like pattern used in the browser/pager components
- The plugin-style architecture for different file formats
- The virtual file system abstraction layer

##### Technical Details

- Support for:
- WAD file operations
- File system integration
- Import/export capabilities
- Palette management
- Texture handling

##### Integration Points

Indicate:
- External editor integration
- File system interaction
- Import/export interfaces
- Audio/visual processing capabilities

Key Considerations:
- Two-pane interface as a central architectural feature
- Separation between UI and core processing
- Virtual file system abstraction
- Data flow directions for all major operations
- Relationship between different subsystems

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef fs fill:#2ecc71,stroke:#27ae60,color:white
    classDef conv fill:#e67e22,stroke:#d35400,color:white
    classDef core fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white

    %% UI Layer
    subgraph UILayer["User Interface Layer"]
        UI["Main UI Framework"]
        ActionBar["Actions Bar"]
        Dialog["Dialog System"]
        ListPane["List Pane"]
        TextInput["Text Input"]
        TitleBar["Title Bar"]
    end

    %% Browser System
    subgraph BrowserSystem["Browser System"]
        Browser["Main Browser"]
        DirPane["Directory Pane"]
        ActPane["Actions Pane"]
    end

    %% Pager System
    subgraph PagerSystem["Pager System"]
        Pager["Main Pager"]
        Hexdump["Hexdump View"]
        Help["Help System"]
    end

    %% Core Processing Layer
    subgraph CoreLayer["Core Processing Layer"]
        %% File System Handler
        subgraph FSHandler["File System Handler"]
            VFS["Virtual File System"]
            WADHandler["WAD File Handler"]
            DirHandler["Real Directory Handler"]
            FileSet["File Set Management"]
        end

        %% Conversion Utilities
        subgraph ConvUtils["Conversion Utilities"]
            Audio["Audio Processing"]
            Graphic["Graphic Conversion"]
            ImportExport["Import/Export"]
            MUS2MIDI["MUS to MIDI"]
        end

        %% Texture Management
        subgraph TextureSystem["Texture Management"]
            Textures["Main Texture System"]
            TexConfig["Texture Configuration"]
            PNAMES["PNAMES Management"]
        end

        %% Palette Management
        subgraph PaletteSystem["Palette Management"]
            Palette["Main Palette System"]
            PalActions["Palette Actions"]
            PalFS["Palette File System"]
        end
    end

    %% Relationships
    UI --> Browser
    UI --> Pager
    Browser --> FSHandler
    Pager --> FSHandler
    FSHandler --> ConvUtils
    ConvUtils --> TextureSystem
    ConvUtils --> PaletteSystem

    %% Click events for component mapping
    click UI "https://github.com/fragglet/WadGadget/blob/trunk/src/ui/ui.h"
    click ActionBar "https://github.com/fragglet/WadGadget/blob/trunk/src/ui/actions_bar.h"
    click Dialog "https://github.com/fragglet/WadGadget/blob/trunk/src/ui/dialog.h"
    click ListPane "https://github.com/fragglet/WadGadget/blob/trunk/src/ui/list_pane.h"
    click TextInput "https://github.com/fragglet/WadGadget/blob/trunk/src/ui/text_input.h"
    click TitleBar "https://github.com/fragglet/WadGadget/blob/trunk/src/ui/title_bar.h"
    click Browser "https://github.com/fragglet/WadGadget/blob/trunk/src/browser/browser.h"
    click DirPane "https://github.com/fragglet/WadGadget/blob/trunk/src/browser/directory_pane.h"
    click ActPane "https://github.com/fragglet/WadGadget/blob/trunk/src/browser/actions_pane.h"
    click VFS "https://github.com/fragglet/WadGadget/blob/trunk/src/fs/vfs.h"
    click WADHandler "https://github.com/fragglet/WadGadget/blob/trunk/src/fs/wad_file.h"
    click DirHandler "https://github.com/fragglet/WadGadget/blob/trunk/src/fs/real_dir.c"
    click FileSet "https://github.com/fragglet/WadGadget/blob/trunk/src/fs/file_set.c"
    click Audio "https://github.com/fragglet/WadGadget/blob/trunk/src/conv/audio.h"
    click Graphic "https://github.com/fragglet/WadGadget/blob/trunk/src/conv/graphic.h"
    click ImportExport "https://github.com/fragglet/WadGadget/blob/trunk/src/conv/import.h"
    click MUS2MIDI "https://github.com/fragglet/WadGadget/blob/trunk/src/conv/mus2mid.h"
    click Textures "https://github.com/fragglet/WadGadget/blob/trunk/src/textures/textures.h"
    click TexConfig "https://github.com/fragglet/WadGadget/blob/trunk/src/textures/config.c"
    click PNAMES "https://github.com/fragglet/WadGadget/blob/trunk/src/textures/pnames.c"
    click Palette "https://github.com/fragglet/WadGadget/blob/trunk/src/palette/palette.h"
    click PalActions "https://github.com/fragglet/WadGadget/blob/trunk/src/palette/actions.h"
    click PalFS "https://github.com/fragglet/WadGadget/blob/trunk/src/palette/palfs.h"
    click Pager "https://github.com/fragglet/WadGadget/blob/trunk/src/pager/pager.h"
    click Hexdump "https://github.com/fragglet/WadGadget/blob/trunk/src/pager/hexdump.h"
    click Help "https://github.com/fragglet/WadGadget/blob/trunk/src/pager/help.h"

    %% Style applications
    class UI,ActionBar,Dialog,ListPane,TextInput,TitleBar,Browser,DirPane,ActPane,Pager,Hexdump,Help ui
    class VFS,WADHandler,DirHandler,FileSet fs
    class Audio,Graphic,ImportExport,MUS2MIDI conv
    class Textures,TexConfig,PNAMES,Palette,PalActions,PalFS core
```
