A Java 17 CLI library that translates JSON/YAML graph definitions into Mermaid.js diagrams.
- JSON & YAML input — auto-detected from file extension
- ️ Two diagram types via the Strategy pattern:
flowchart— Mermaidflowchart TDwith shaped nodes (start/end, decision, process)sequence— MermaidsequenceDiagramwith participants and messages
- Composite pattern — supports nested node groups rendered as Mermaid
subgraphblocks - 23 JUnit 5 tests covering parsers, composite builder, and both strategies
- GitHub Actions CI — runs on every push/PR
mvn clean package# Flowchart (default)
java -jar target/schem-tool.jar input.json
# Sequence diagram
java -jar target/schem-tool.jar input.json --type sequence
# Custom output file
java -jar target/schem-tool.jar input.yaml --type flowchart --output diagram.mmd{
"nodes": [
{ "id": "start", "label": "Start", "type": "start", "children": [] },
{ "id": "check", "label": "Logged in?", "type": "decision", "children": [] },
{ "id": "login", "label": "Login Page", "type": "process", "children": [] },
{ "id": "end", "label": "End", "type": "end", "children": [] }
],
"edges": [
{ "from": "start", "to": "check", "label": "" },
{ "from": "check", "to": "login", "label": "No" },
{ "from": "check", "to": "end", "label": "Yes" },
{ "from": "login", "to": "end", "label": "" }
]
}The same structure in YAML format (.yaml / .yml extensions are supported).
type |
Mermaid shape | Example |
|---|---|---|
start |
Stadium ([…]) |
A([Start]) |
end |
Stadium ([…]) |
Z([End]) |
decision |
Rhombus {…} |
D{Choice?} |
process |
Rectangle […] |
P[Process] |
Nodes with a non-empty children array are rendered as Mermaid subgraph blocks:
{ "id": "module", "label": "My Module", "type": "process", "children": [
{ "id": "step1", "label": "Step 1", "type": "process", "children": [] },
{ "id": "step2", "label": "Step 2", "type": "process", "children": [] }
]}flowchart TD
start([Start])
check{Is user logged in?}
login[Show Login Page]
end([End])
start --> check
check -->|No| login
check -->|Yes| end
login --> end
sequenceDiagram
participant user as User
participant server as Server
participant db as Database
user->>server: HTTP GET /api
server->>db: SELECT query
db->>server: result set
server->>user: JSON response
org.example
├── Main.java ← Picocli entry point
├── cli/
│ └── LogicPlotCommand.java ← @Command wiring
├── model/
│ ├── GraphDefinition.java ← Root deserialized object
│ ├── NodeDefinition.java ← Node with optional children
│ └── EdgeDefinition.java ← Directed edge with optional label
├── parser/ ← Strategy: input parsing
│ ├── InputParser.java ← Interface
│ ├── JsonInputParser.java
│ ├── YamlInputParser.java
│ └── ParserFactory.java
├── composite/ ← Composite pattern: node tree
│ ├── DiagramComponent.java ← Interface
│ ├── DiagramLeaf.java ← Single node
│ ├── DiagramComposite.java ← Node group / subgraph
│ └── CompositeBuilder.java ← Builds tree from NodeDefinition list
├── strategy/ ← Strategy pattern: diagram generation
│ ├── DiagramStrategy.java ← Interface
│ ├── FlowchartStrategy.java
│ ├── SequenceDiagramStrategy.java
│ ├── DiagramType.java ← Enum (FLOWCHART, SEQUENCE)
│ └── StrategyFactory.java
└── output/
└── MmdFileWriter.java ← Writes .mmd file
mvn testAll 23 tests across 5 test classes:
| Test Class | Tests |
|---|---|
JsonInputParserTest |
4 |
YamlInputParserTest |
3 |
CompositeBuilderTest |
5 |
FlowchartStrategyTest |
5 |
SequenceDiagramStrategyTest |
6 |