# staruml/staruml-java architecture

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

- Interactive diagram: https://gitdiagram.com/staruml/staruml-java
- Repository: https://github.com/staruml/staruml-java

## Overview

StarUML’s Java extension generates Java source from UML models and reverse-engineers Java source into UML. The user starts either command in StarUML, selects a model or source folder, and receives generated files or an imported project model. The reverse path parses Java with the bundled Java 7 parser, translates declarations and relationships, then imports the model; documented optional diagram generation is also represented. Source excerpts establish the main calls, but the reverse analyzer’s file-discovery and parser invocation details are incomplete, so those links are shown as unverified.

Main entry points: [`main.js`](https://github.com/staruml/staruml-java/blob/master/main.js) (Java commands), [`code-analyzer.js`](https://github.com/staruml/staruml-java/blob/master/code-analyzer.js) (Java analysis and UML translation), [`code-generator.js`](https://github.com/staruml/staruml-java/blob/master/code-generator.js) (Java source generation), [`grammar/java7.js`](https://github.com/staruml/staruml-java/blob/master/grammar/java7.js) (Java 7 parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_commands["StarUML commands"]
  node_commands["Java commands<br/>[main.js]"]
  node_preferences["Java preferences<br/>[preference.json]"]
  node_model_select["Model selection<br/>[main.js]"]
  node_folder_select["Folder selection<br/>[main.js]"]
end

subgraph group_generation["Java generation"]
  node_generator["Java source generation<br/>[code-generator.js]"]
  node_writer["Code writer<br/>[codegen-utils.js]"]
  node_java_files["Generated Java files"]
end

subgraph group_reverse["Java reverse engineering"]
  node_analyzer["Java analysis and UML translation<br/>[code-analyzer.js]"]
  node_parser["Java 7 parser<br/>[java7.js]"]
  node_java_source["Java source folder"]
end

subgraph group_model["Model integration"]
  node_uml_model[("UML model")]
  node_imported_model[("Imported UML model")]
  node_diagram_generation["Optional UML diagrams<br/>[code-analyzer.js]"]
end

node_user(("StarUML user"))

node_user -->|"invokes"| node_commands
node_commands -->|"reads options"| node_preferences
node_commands -->|"prompts model"| node_model_select
node_commands -->|"prompts folder"| node_folder_select
node_model_select -->|"selects base"| node_uml_model
node_commands -->|"calls generate"| node_generator
node_generator -->|"reads model"| node_uml_model
node_generator -->|"formats output"| node_writer
node_generator -.->|"writes source"| node_java_files
node_commands -->|"calls analyze"| node_analyzer
node_folder_select -->|"selects source"| node_java_source
node_analyzer -.->|"reads source"| node_java_source
node_analyzer -->|"parses Java"| node_parser
node_parser -.->|"returns syntax tree"| node_analyzer
node_analyzer -->|"imports UML"| node_imported_model
node_analyzer -->|"generates diagrams"| node_diagram_generation

click node_commands "https://github.com/staruml/staruml-java/blob/master/main.js"
click node_preferences "https://github.com/staruml/staruml-java/blob/master/preferences/preference.json"
click node_model_select "https://github.com/staruml/staruml-java/blob/master/main.js"
click node_folder_select "https://github.com/staruml/staruml-java/blob/master/main.js"
click node_generator "https://github.com/staruml/staruml-java/blob/master/code-generator.js"
click node_writer "https://github.com/staruml/staruml-java/blob/master/codegen-utils.js"
click node_analyzer "https://github.com/staruml/staruml-java/blob/master/code-analyzer.js"
click node_parser "https://github.com/staruml/staruml-java/blob/master/grammar/java7.js"
click node_diagram_generation "https://github.com/staruml/staruml-java/blob/master/code-analyzer.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_commands,node_preferences,node_model_select,node_folder_select,node_user toneBlue
class node_generator,node_writer,node_java_files toneAmber
class node_analyzer,node_parser,node_java_source toneMint
class node_uml_model,node_imported_model,node_diagram_generation toneRose
```

## Components

### StarUML commands

- [Java commands](https://github.com/staruml/staruml-java/blob/master/main.js): `main.js`
- [Java preferences](https://github.com/staruml/staruml-java/blob/master/preferences/preference.json): `preferences/preference.json`
- [Model selection](https://github.com/staruml/staruml-java/blob/master/main.js): `main.js`
- [Folder selection](https://github.com/staruml/staruml-java/blob/master/main.js): `main.js`

### Java generation

- [Java source generation](https://github.com/staruml/staruml-java/blob/master/code-generator.js): `code-generator.js`
- [Code writer](https://github.com/staruml/staruml-java/blob/master/codegen-utils.js): `codegen-utils.js`
- **Generated Java files**

### Java reverse engineering

- [Java analysis and UML translation](https://github.com/staruml/staruml-java/blob/master/code-analyzer.js): `code-analyzer.js`
- [Java 7 parser](https://github.com/staruml/staruml-java/blob/master/grammar/java7.js): `grammar/java7.js`
- **Java source folder**

### Model integration

- **UML model**
- **Imported UML model**
- [Optional UML diagrams](https://github.com/staruml/staruml-java/blob/master/code-analyzer.js): `code-analyzer.js`

### Other components

- **StarUML user**

## Connections

- StarUML user → Java commands: invokes (evidence: `README.md`)
- Java commands → Java preferences: reads options (evidence: `main.js`)
- Java commands → Model selection: prompts model (evidence: `main.js`)
- Java commands → Folder selection: prompts folder (evidence: `main.js`)
- Model selection → UML model: selects base (evidence: `main.js`)
- Java commands → Java source generation: calls generate (evidence: `main.js`)
- Java source generation → UML model: reads model (evidence: `README.md`)
- Java source generation → Code writer: formats output (evidence: `code-generator.js`)
- Java source generation → Generated Java files: writes source (evidence: `README.md`)
- Java commands → Java analysis and UML translation: calls analyze (evidence: `main.js`)
- Folder selection → Java source folder: selects source (evidence: `README.md`)
- Java analysis and UML translation → Java source folder: reads source (evidence: `README.md`)
- Java analysis and UML translation → Java 7 parser: parses Java (evidence: `code-analyzer.js`)
- Java 7 parser → Java analysis and UML translation: returns syntax tree (evidence: `code-analyzer.js`)
- Java analysis and UML translation → Imported UML model: imports UML (evidence: `code-analyzer.js`)
- Java analysis and UML translation → Optional UML diagrams: generates diagrams (evidence: `code-analyzer.js`)
