This project aims to create sequence diagrams programmatically, using a programming language like Scala or Java or a customized language. So you could save the created sequence as SVG image or fixed-width text.
For example in Scala you could import the dependency in your project:
https://search.maven.org/artifact/com.gnosly/fluent-sequence_2.12/0.1/jar
Write something like:
val moduleA = new FluentActor("moduleA")
val moduleB = new FluentActor("moduleB")
new Sequence("example flow").startWith(
moduleA.call("request", to(moduleB)) ::
moduleB.does("doing the job") ::
moduleB.reply("response", to(moduleA)) ::
Nil
)
and render the sequence to console using
sequence.printToConsole();
_______________
| example flow \
|-------------------------------------------------------
| .---------. .---------. |
| | moduleA | | moduleB | |
| '---------' '---------' |
| | | |
| _|_ _|_ |
| | | request | | |
| | |----------------->| | |
| | | | | |
| | | | |____ |
| | | | | | |
| | | | | | doing the job |
| | | | |<---' |
| | | | | |
| | | response | | |
| | |<-----------------| | |
| |_| |_| |
| | | |
| |
|_______________________________________________________
or to svg using
sequence.printToSvg();
FluentSequence.FluentActor moduleA = new FluentSequence.FluentActor("moduleA", new SEQUENCE_ACTOR_TYPE());
FluentSequence.FluentActor moduleB = new FluentSequence.FluentActor("moduleB", new SEQUENCE_ACTOR_TYPE());
FluentSequence.Sequence sequence = new FluentSequence.Sequence("example flow").startWith(
JavaConverters.asScalaBuffer(asList(
moduleA.call("request", moduleB),
moduleB.does("doing the job"),
moduleB.reply("response", moduleA)
))
);
You can also create your syntax and use this library to render the sequence, like http://sequencediagram.fabriziogiovannetti.com does.
You have to complete these tasks:
- Create your grammar using BSON,JISON or ANTLR
- Encode the sequence following the schema below
- Use this library to render the encoded schema
The encoded sequence is a UTF-8 string that tells what happens in the flow sequentially using one of those elements
encoded element | description |
---|---|
SEQUENCE_STARTED|sequenceName | The sequence sequenceName is started |
DONE|actorAType|actorAName|action | actorAName of type actorAType does the action |
CALLED|actorAType|actorA|action|actorBType|actorB | actorA of type actorAType called the action on actorB of type actorBType |
REPLIED|actorAType|actorA|response|actorBType|actorB | actorA of type actorAType replied with response to actorB of type actorBType |
SEQUENCE_ENDED|sequenceName | The sequence sequenceName is ended |
The possible actorType are
- USER_TYPE
- SEQUENCE_ACTOR_TYPE
A possible example is shown here
SEQUENCE_STARTED|example flow
CALLED|SEQUENCE_ACTOR_TYPE|moduleA|request|SEQUENCE_ACTOR_TYPE|moduleB
DONE|SEQUENCE_ACTOR_TYPE|moduleB|doing the job
REPLIED|SEQUENCE_ACTOR_TYPE|moduleB|response|SEQUENCE_ACTOR_TYPE|moduleA
SEQUENCE_ENDED|example flow
Now you can render the encoded data doing
val encodedSequence = "..."
val svg = new SvgViewer().view(new EventBookReader().read(encodedSequence))
I'd like very much to work with other people. People could improve their competences working together. Working on a open source project is the best way to meet all kind of people around the world. So if you like the project doesn't hesitate to get involved and contact me. Below I give you some info useful to understand how the project is structured and the simple sequence flow.
The project is divided in three different layers
- Core: It contains the domain model. Basically it has got a event store that persist the sequence interactions transformed into events
- API: It contains the DSL used to declare the sequence diagram. It uses the domain model to transform each action into event.
- View: It contains the logic to present the list of sequence events into view.
- Francesco Pellegrini Helping configuring sbt release plugin
GNU General Public License v3.0
See LICENSE to see the full text.