# tushartushar/designitejava architecture

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

- Interactive diagram: https://gitdiagram.com/tushartushar/designitejava
- Repository: https://github.com/tushartushar/designitejava

## Overview

##### Project Type and Purpose
- DesigniteJava is a standalone tool (a command-line application) for analyzing Java source code to compute object-oriented metrics and detect a variety of design and implementation smells.
- The tool uses Maven as its build system and relies on the Eclipse IDE for development.
- Its main purpose is static analysis of Java code by processing inputs (source code directories) and producing an output (report files or CSV exports).

##### Main Components
a. Application Entry Point:
- Main class (Designite.java) as the central controller.
b. Argument Parsing:
- A module consisting of the ArgumentParser package which includes classes like CLIArgumentParser.java, InputArgs.java, and RegularArgumentParser.java that are responsible for parsing command-line inputs.
c. Source Code Model:
- The SourceModel package which builds the internal representation of the Java source code. This includes various classes (e.g., SM_Project, SM_Package, SM_Type, SM_Method, SM_Field) representing different Java constructs.
d. Metrics Extraction:
- A dedicated module within the metrics package (e.g., MethodMetricsExtractor, TypeMetricsExtractor, and related classes) that computes metrics such as LOC, CC, NOM, WMC, etc.
e. Smell Detection:
- Comprises two submodules:
- Design Smells – Handled by classes in the smells/designSmells package (e.g., AbstractionSmellDetector, EncapsulationSmellDetector, etc.) with a DesignSmellFacade to orchestrate detection.
- Implementation Smells – Handled by the smells/implementationSmells package, for detecting issues like “Complex Method” or “Magic Number”.
- The support classes in smells/models hold representations (like CodeSmell, DesignCodeSmell) of detected smells.
f. Visitors:
- The visitors package contains classes (such as MethodControlFlowVisitor, InstanceOfVisitor, and others) used to traverse and analyze the Java source model to extract information.
g. Utilities:
- Utility classes under utils (for logging, file management, CSV exports) that support data processing and output generation.
h. Testing Infrastructure:
- Although not part of the core design, include a testing component which reflects unit/integration tests provided under the tests directory to validate analysis and detection logic.

##### Relationships and Data Flow
- A starting point at the “Main Application” (Designite.java), which receives command-line arguments.
- The source model is then processed by several “Visitors” which extract information required by both the “Metrics Extraction” and “Smell Detection” modules.
- Data from the SourceModel is fed into the Metrics Extractors, whose output (metrics values) may be used as input cues for smell detectors.
- The Design and Implementation Smell Detection modules work on the model (or enriched information from visitors) and yield results that are often encapsulated using the smells/models classes.
- Finally, “CSVUtils” and “FileManager” in the utilities module handle exporting and managing outputs (reports).

##### Architectural Patterns & Design Principles
- There’s a separation of concerns: Each main aspect of analysis (parsing, modeling, metric extraction, smell detection) resides in its own package/module.
- The use of visitors for traversing the source model highlights use of the Visitor design pattern.
- The modular approach also allows for easy extension in the future (for new smells or metrics).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Input and Parsing"
        MA["Main Application (Designite.java)"]:::input
        AP["Argument Parsing"]:::input
    end

    subgraph "Model Construction"
        SM["Source Model"]:::model
    end

    subgraph "Analysis and Processing"
        VI["Visitors"]:::analysis
        ME["Metrics Extraction"]:::analysis
        DS["Design Smell Detection"]:::analysis
        IS["Implementation Smell Detection"]:::analysis
    end

    subgraph "Output Management"
        UT["Utilities (CSV & File Management)"]:::output
    end

    subgraph "Quality Assurance"
        TS["Testing"]:::testing
    end

    MA -->|"receivesArgs"| AP
    AP -->|"buildsModel"| SM
    SM -->|"traversedBy"| VI
    VI -->|"extractsMetrics"| ME
    VI -->|"detectsDesignSmells"| DS
    VI -->|"detectsImplSmells"| IS
    ME -->|"exportsMetrics"| UT
    DS -->|"exportsSmells"| UT
    IS -->|"exportsSmells"| UT

    click MA "https://github.com/tushartushar/designitejava/blob/master/src/Designite/Designite.java"
    click AP "https://github.com/tushartushar/designitejava/tree/master/src/Designite/ArgumentParser"
    click SM "https://github.com/tushartushar/designitejava/tree/master/src/Designite/SourceModel"
    click VI "https://github.com/tushartushar/designitejava/tree/master/src/Designite/visitors"
    click ME "https://github.com/tushartushar/designitejava/tree/master/src/Designite/metrics"
    click DS "https://github.com/tushartushar/designitejava/tree/master/src/Designite/smells/designSmells"
    click IS "https://github.com/tushartushar/designitejava/tree/master/src/Designite/smells/implementationSmells"
    click UT "https://github.com/tushartushar/designitejava/tree/master/src/Designite/utils"
    click TS "https://github.com/tushartushar/designitejava/tree/master/tests"

    classDef input fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef model fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef analysis fill:#FFFFE0,stroke:#000,stroke-width:2px;
    classDef output fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef testing fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
