# glycoinfo/glycanformatconverter architecture

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

- Interactive diagram: https://gitdiagram.com/glycoinfo/glycanformatconverter
- Repository: https://github.com/glycoinfo/glycanformatconverter

## Overview

##### Project Type and Purpose
- This is a Java-based, Maven-packaged core library (GlycanFormatConverter) for converting glycan text representations between multiple formats. It also provides CLI entry points and a companion WURCSFramework module.
- It is not a full-stack web app but an API/library (with a command-line client) that can be embedded in other systems or called via the published REST API or CLI.

##### File-Structure Analysis
- Top-level files: pom.xml (build descriptor), README, CHANGELOG, LICENSE, .gitlab-ci.yml (CI pipeline).
- src/main/java/org/glycoinfo/GlycanFormatconverter:
- Glycan: domain model classes (GlycanGraph, Monosaccharide, Linkage, etc.).
- exec: command-line entry-point classes for each conversion mode (e.g., execConverterWithWURCS).
- io: importer/exporter interfaces and implementations for each format (GlycoCT, IUPAC, JSON, KCF, LinearCode, WURCS).
- util: shared utilities (traversers, validators, analyzers, graph exchangers).
- src/main/java/org/glycoinfo/WURCSFramework: a separate package providing low-level WURCS I/O and utilities.
- src/test: comprehensive unit and integration tests exercising each format converter, exchange path, and validator.

##### Key README Insights
- Java 8+, Maven 3.6+
- Provides both an API library and a CLI client.
- Published to Maven Central and exposed via a REST API.
- Restriction notes and publication reference.

a. Core Domain Layer
– Domain model (org.glycoinfo.GlycanFormatconverter.Glycan).
– Conversion engine that builds or consumes GlycanGraph objects.
b. Adapter Layer (I/O)
– Importers and exporters for each format.
– Implements ExporterInterface/ImporterInterface.
c. Utility Layer
– Validators, analyzers, traversers, comparators, graph exchangers (e.g., GlyContainerToWURCSGraph).
d. CLI Module
– exec package entry points, each class invoking the core + adapter + util layers.
e. WURCSFramework Submodule
– Stand-alone I/O and utility classes supporting WURCS format.
f. Build & Publication
– Maven POM, CI pipeline, deployment to Maven Central, REST API service (external).

##### Relationships & Interactions
- CLI entry classes (exec) depend on the Adapter and Core layers.
- Adapter implementations invoke Core Domain services and may call Utility classes for validation or graph transformations.
- Core Domain may leverage WURCSFramework utilities when performing WURCS-specific conversions.
- Utilities (validators, analyzers) are shared across adapters to enforce format rules.
- Packaging layer (Maven) bundles all modules into a JAR published to Central; client or REST service consumes the JAR.

##### Architectural Patterns & Principles
- Layered architecture: Domain → Adapter → CLI
- Strategy/Factory patterns for selecting importers/exporters by format.
- Visitor pattern in traversers and validators (Visitable/Visitor).
- Separation of concerns: model, I/O, utilities, presentation (CLI).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Domain Layer
    subgraph "Core Domain Layer"
        Domain["Glycan Domain\n(org.glycoinfo.GlycanFormatconverter.Glycan)"]:::domain
    end

    %% Adapter Layer
    subgraph "Adapter Layer (I/O)"
        ExporterInterface["ExporterInterface"]:::adapter
        ImporterInterface["ImporterInterface"]:::adapter
        GlycoCT["GlycoCT Package"]:::adapter
        IUPAC["IUPAC Package"]:::adapter
        JSON["JSON Package"]:::adapter
        KCF["KCF Package"]:::adapter
        LinearCode["LinearCode Package"]:::adapter
        WURCSAdapter["WURCS Importer"]:::adapter
    end

    %% Utility Layer
    subgraph "Utility Layer"
        Util["Util Package\n(validators, traversers,\nvisitors, comparators, analyzers)"]:::util
    end

    %% CLI Module
    subgraph "CLI Module"
        CLI["CLI Entry Points\n(exec package)"]:::cli
    end

    %% WURCSFramework Submodule
    subgraph "WURCSFramework Submodule"
        WFIO["WURCSFramework I/O"]:::adapter
        WFOldUtil["oldUtil Package"]:::util
        WFResidue["residuecontainer Package"]:::util
    end

    %% Build & External Dependencies
    subgraph "Build & External"
        Maven["Maven POM"]:::external
        CI[".gitlab-ci.yml"]:::external
        README["README/CHANGELOG/LICENSE"]:::external
        REST["REST API/Java Consumers"]:::external
    end

    %% Relationships
    CLI -->|"select format"| ImporterInterface
    CLI -->|"select format"| ExporterInterface
    ImporterInterface -->|"imports to GlycanGraph"| Domain
    ExporterInterface -->|"exports from GlycanGraph"| Domain
    ImporterInterface -->|"validate/transform"| Util
    ExporterInterface -->|"validate/transform"| Util
    Domain -->|"WURCS conversion"| WFIO
    Util -->|"support WURCS operations"| WFOldUtil
    Util -->|"support residue operations"| WFResidue
    Maven -->|"builds JAR for"| CLI
    Maven -->|"builds JAR for"| Domain
    Maven -->|"builds JAR for"| ExporterInterface
    Maven -->|"builds JAR for"| ImporterInterface
    Maven -->|"builds JAR for"| Util
    Maven -->|"builds JAR for"| WFIO
    Maven -->|"publishes to"| REST
    CI -->|"triggers"| Maven

    %% Click Events
    click Domain "https://github.com/glycoinfo/glycanformatconverter/tree/master/src/main/java/org/glycoinfo/GlycanFormatconverter/Glycan"
    click ExporterInterface "https://github.com/glycoinfo/glycanformatconverter/blob/master/src/main/java/org/glycoinfo/GlycanFormatconverter/io/ExporterInterface.java"
    click ImporterInterface "https://github.com/glycoinfo/glycanformatconverter/blob/master/src/main/java/org/glycoinfo/GlycanFormatconverter/io/ImporterInterface.java"
    click GlycoCT "https://github.com/glycoinfo/glycanformatconverter/tree/master/src/main/java/org/glycoinfo/GlycanFormatconverter/io/GlycoCT"
    click IUPAC "https://github.com/glycoinfo/glycanformatconverter/tree/master/src/main/java/org/glycoinfo/GlycanFormatconverter/io/IUPAC"
    click JSON "https://github.com/glycoinfo/glycanformatconverter/tree/master/src/main/java/org/glycoinfo/GlycanFormatconverter/io/JSON"
    click KCF "https://github.com/glycoinfo/glycanformatconverter/tree/master/src/main/java/org/glycoinfo/GlycanFormatconverter/io/KCF"
    click LinearCode "https://github.com/glycoinfo/glycanformatconverter/tree/master/src/main/java/org/glycoinfo/GlycanFormatconverter/io/LinearCode"
    click WURCSAdapter "https://github.com/glycoinfo/glycanformatconverter/tree/master/src/main/java/org/glycoinfo/GlycanFormatconverter/io/WURCS"
    click Util "https://github.com/glycoinfo/glycanformatconverter/tree/master/src/main/java/org/glycoinfo/GlycanFormatconverter/util"
    click CLI "https://github.com/glycoinfo/glycanformatconverter/tree/master/src/main/java/org/glycoinfo/GlycanFormatconverter/exec"
    click WFIO "https://github.com/glycoinfo/glycanformatconverter/tree/master/src/main/java/org/glycoinfo/WURCSFramework/io"
    click WFOldUtil "https://github.com/glycoinfo/glycanformatconverter/tree/master/src/main/java/org/glycoinfo/WURCSFramework/util/oldUtil"
    click WFResidue "https://github.com/glycoinfo/glycanformatconverter/tree/master/src/main/java/org/glycoinfo/WURCSFramework/util/residuecontainer"
    click Maven "https://github.com/glycoinfo/glycanformatconverter/blob/master/pom.xml"
    click CI "https://github.com/glycoinfo/glycanformatconverter/blob/master/.gitlab-ci.yml"
    click README "https://github.com/glycoinfo/glycanformatconverter/blob/master/README.md"

    %% Styles
    classDef domain fill:#cce5ff,stroke:#005cbf,color:#004085
    classDef adapter fill:#d4edda,stroke:#155724,color:#155724
    classDef util fill:#fff3cd,stroke:#856404,color:#856404
    classDef cli fill:#ffe5b4,stroke:#cc8400,color:#663c00
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#383d41
```
