# citiususc/jflap-lib architecture

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

- Interactive diagram: https://gitdiagram.com/citiususc/jflap-lib
- Repository: https://github.com/citiususc/jflap-lib

## Overview

##### Project type and purpose
- This is an open‐source Java library (jflaplib‐core) plus a command‐line application (jflaplib‐cli) that exposes JFLAP 7.0’s formal‐languages functionality as a reusable API and as CLI commands. It uses Maven and is published via JitPack.

##### File structure
- Top level: two Maven modules plus root pom.xml
- jflaplib‐cli: minimal CLI driver (CommandLine.java, IO.java) with its own pom.xml.
- Key patterns: package‐by‐feature, layered dependencies (file → domain → services → GUI/CLI), factory patterns (SimulatorFactory, CodecRegistry), Maven multi‐module.

##### README for additional insights
- jflaplib‐core: “full JFLAP 7.0 code adapted to be used as a library” with logging facade (SLF4J).
- jflaplib‐cli: “command line tool” with commands such as run, equivalent, regular that invoke core API.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "jflaplib-cli (Module)" 
        direction TB
        CLI_CommandLine["CommandLine"]:::module
        CLI_IO["IO"]:::module
    end

    subgraph "jflaplib-core (Module)" 
        direction TB

        subgraph "Infrastructure (File I/O / Codecs)"
            direction TB
            Codec["Codec"]:::infra
            CodecRegistry["CodecRegistry"]:::infra
            XMLCodec["XMLCodec"]:::infra
            JFLAP3Codec["JFLAP3Codec"]:::infra
            LenoreSystemsCodec["LenoreSystemsCodec"]:::infra
            SerializedCodec["SerializedCodec"]:::infra
        end

        subgraph "Domain Model"
            direction TB
            Automata["Automata"]:::domain
            Grammar["Grammar"]:::domain
            LSystem["LSystem"]:::domain
            PDA["PDA"]:::domain
            Turing["Turing"]:::domain
            Regular["RegularExpression"]:::domain
        end

        subgraph "Services & Factories"
            direction TB
            SimulatorFactory["SimulatorFactory"]:::service
            NondetDetectorFactory["NondeterminismDetectorFactory"]:::service
            LambdaCheckerFactory["LambdaCheckerFactory"]:::service
            FSAToRegConverter["FSAToRegularExpressionConverter"]:::service
            GrammarToAutoConverter["GrammarToAutomatonConverter"]:::service
            PDAToCFGConverter["PDAToCFGConverter"]:::service
            TuringToGrammarConverter["TuringToGrammarConverter"]:::service
            ContextFreePumping["ContextFreePumpingLemma"]:::service
            RegularPumping["RegularPumpingLemma"]:::service
        end

        subgraph "GUI Components (Swing)"
            direction TB
            GUI_Main["Main"]:::gui
            GUI_Actions["Actions"]:::gui
            GUI_Editors["Editors"]:::gui
            GUI_Environments["Environments"]:::gui
            GUI_SimPanels["Simulator Panels"]:::gui
            GUI_GrammarParse["Grammar Parse Panes"]:::gui
            GUI_LSystemUI["L-system UI"]:::gui
            GUI_RegUI["Regular UI"]:::gui
            GUI_PumpingUI["Pumping Lemma UI"]:::gui
        end

        subgraph "Resources"
            direction TB
            DOCS["DOCS"]:::resource
            ICON["ICON"]:::resource
            MEDIA["MEDIA"]:::resource
        end
    end

    subgraph "Build & Distribution"
        direction TB
        RootPOM["pom.xml (root)"]:::external
        CorePOM["jflaplib-core/pom.xml"]:::external
        CLIPOM["jflaplib-cli/pom.xml"]:::external
    end

    subgraph "External Dependencies"
        direction TB
        SLF4J["SLF4J"]:::external
        MavenDep["Maven"]:::external
        JitPack["JitPack"]:::external
    end

    %% Data flow
    CLI_CommandLine -->|"decode .jff/.xml"| CodecRegistry
    CodecRegistry -->|"provides codec"| XMLCodec
    CodecRegistry --> JFLAP3Codec
    CodecRegistry --> LenoreSystemsCodec
    CodecRegistry --> SerializedCodec
    XMLCodec --> Automata
    Automata --> SimulatorFactory
    Grammar --> GrammarToAutoConverter
    LSystem --> SimulatorFactory
    PDA --> PDAToCFGConverter
    Turing --> TuringToGrammarConverter
    Regular --> FSAToRegConverter
    SimulatorFactory --> ContextFreePumping
    SimulatorFactory --> RegularPumping
    ContextFreePumping --> CLI_CommandLine
    RegularPumping --> CLI_CommandLine
    FSAToRegConverter --> CLI_CommandLine
    GrammarToAutoConverter --> CLI_CommandLine
    PDAToCFGConverter --> CLI_CommandLine
    TuringToGrammarConverter --> CLI_CommandLine

    CLI_CommandLine --> CLI_IO
    CLI_IO -->|"output/log"| SLF4J
    CLI_CommandLine --> SLF4J
    CodecRegistry --> SLF4J
    SimulatorFactory --> SLF4J

    %% Build relations
    RootPOM --> CorePOM
    RootPOM --> CLIPOM

    %% Click events
    click CLI_CommandLine "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-cli/src/main/java/es/usc/citius/jflap/cli/CommandLine.java"
    click CLI_IO "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-cli/src/main/java/es/usc/citius/jflap/cli/IO.java"
    click Codec "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-core/src/main/java/edu/duke/cs/jflap/file/Codec.java"
    click CodecRegistry "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-core/src/main/java/edu/duke/cs/jflap/file/CodecRegistry.java"
    click XMLCodec "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-core/src/main/java/edu/duke/cs/jflap/file/XMLCodec.java"
    click JFLAP3Codec "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-core/src/main/java/edu/duke/cs/jflap/file/JFLAP3Codec.java"
    click LenoreSystemsCodec "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-core/src/main/java/edu/duke/cs/jflap/file/LenoreSystemsCodec.java"
    click SerializedCodec "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-core/src/main/java/edu/duke/cs/jflap/file/SerializedCodec.java"
    click SimulatorFactory "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-core/src/main/java/edu/duke/cs/jflap/automata/SimulatorFactory.java"
    click NondetDetectorFactory "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-core/src/main/java/edu/duke/cs/jflap/automata/NondeterminismDetectorFactory.java"
    click LambdaCheckerFactory "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-core/src/main/java/edu/duke/cs/jflap/automata/LambdaCheckerFactory.java"
    click FSAToRegConverter "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-core/src/main/java/edu/duke/cs/jflap/automata/fsa/FSAToRegularExpressionConverter.java"
    click GrammarToAutoConverter "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-core/src/main/java/edu/duke/cs/jflap/grammar/GrammarToAutomatonConverter.java"
    click PDAToCFGConverter "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-core/src/main/java/edu/duke/cs/jflap/automata/pda/PDAToCFGConverter.java"
    click TuringToGrammarConverter "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-core/src/main/java/edu/duke/cs/jflap/automata/turing/TuringToGrammarConverter.java"
    click ContextFreePumping "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-core/src/main/java/edu/duke/cs/jflap/pumping/ContextFreePumpingLemma.java"
    click RegularPumping "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-core/src/main/java/edu/duke/cs/jflap/pumping/RegularPumpingLemma.java"
    click GUI_Main "https://github.com/citiususc/jflap-lib/blob/master/jflaplib-core/src/main/java/edu/duke/cs/jflap/gui/Main.java"

    classDef module fill:#b3d9ff,stroke:#333,stroke-width:1px
    classDef infra fill:#ffd9b3,stroke:#333,stroke-width:1px
    classDef domain fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef service fill:#fff2cc,stroke:#333,stroke-width:1px
    classDef gui fill:#ffccff,stroke:#333,stroke-width:1px
    classDef resource fill:#ccccff,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
    classDef external fill:#e6e6e6,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
