Skip to content

Commit

Permalink
Add UML diagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
djvelimir committed Jul 15, 2023
1 parent fd47f3f commit cca5a7a
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
# demo-kotlin-cli

## Use Case Diagram

![Class Diagram](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.githubusercontent.com/djvelimir/demo-kotlin-cli/main/diagrams/UseCase.puml)

## Sequence Diagram

![Class Diagram](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.githubusercontent.com/djvelimir/demo-kotlin-cli/main/diagrams/Sequence.puml)

## Class Diagram

![Class Diagram](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.githubusercontent.com/djvelimir/demo-kotlin-cli/main/diagrams/Class.puml)
73 changes: 73 additions & 0 deletions diagrams/Class.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
@startuml Class
interface ArgumentValidator {
+ validate(args: String[]): boolean
}

class ArgumentValidatorImpl {
}

interface ArgumentProcessor {
+ process(args: String[])
}

class ArgumentProcessorImpl {
- argumentValidator: ArgumentValidator
- passwordGenerator: PasswordGenerator
- terminal: Terminal
}

interface Terminal {
+ show(message: String)
}

class TerminalImpl {
}

interface PasswordGenerator {
+ generate(): String
}

class PasswordGeneratorImpl {
- passwordLength: int
- randomCharacterGenerator: RandomCharacterGenerator
- stringShuffler: StringShuffler
}

interface RandomCharacterGenerator {
+ generateUppercaseCharacter(): char
+ generateLowercaseCharacter(): char
+ generateDigitCharacter(): char
+ generateSpecialCharacter(): char
+ generateAllowedCharacter(): char
}

class RandomCharacterGeneratorImpl {
- uppercaseCharacters: String
- lowercaseCharacters: String
- digitCharacters: String
- specialCharacters: String
- allowedCharacters: String
- random: Random
}

interface StringShuffler {
+ shuffle(characters: String): String
}

class StringShufflerImpl {
}

ArgumentValidator <|-- ArgumentValidatorImpl
ArgumentProcessor <|-- ArgumentProcessorImpl
Terminal <|-- TerminalImpl
PasswordGenerator <|-- PasswordGeneratorImpl
RandomCharacterGenerator <|-- RandomCharacterGeneratorImpl
StringShuffler <|-- StringShufflerImpl

ArgumentProcessorImpl *--l ArgumentValidator
ArgumentProcessorImpl *--d PasswordGenerator
ArgumentProcessorImpl *--r Terminal

PasswordGeneratorImpl *--l RandomCharacterGenerator
PasswordGeneratorImpl *--r StringShuffler
@enduml
85 changes: 85 additions & 0 deletions diagrams/Sequence.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
@startuml Sequence
participant Main as app
participant ArgumentProcessorImpl as argumentProcessor
participant ArgumentValidatorImpl as argumentValidator
participant PasswordGeneratorImpl as passwordGenerator
participant RandomCharacterGeneratorImpl as randomCharacterGenerator
participant StringShufflerImpl as stringShuffler
participant TerminalImpl as terminal

activate app

app -> argumentProcessor: process(args)
activate argumentProcessor

argumentProcessor -> argumentValidator: validate(args)
activate argumentValidator
argumentProcessor <-- argumentValidator: return are arguments valid
deactivate argumentValidator

alt#Gold #LightBlue Arguments are valid
argumentProcessor -> passwordGenerator: generate()
activate passwordGenerator

passwordGenerator -> randomCharacterGenerator: generateUppercaseCharacter()
activate randomCharacterGenerator

randomCharacterGenerator -> passwordGenerator: return uppercase character
deactivate randomCharacterGenerator
passwordGenerator -> passwordGenerator: append character

passwordGenerator -> randomCharacterGenerator: generateLowercaseCharacter()
activate randomCharacterGenerator

randomCharacterGenerator -> passwordGenerator: return lowercase character
deactivate randomCharacterGenerator
passwordGenerator -> passwordGenerator: append character

passwordGenerator -> randomCharacterGenerator: generateDigitCharacter()
activate randomCharacterGenerator

randomCharacterGenerator -> passwordGenerator: return digit character
deactivate randomCharacterGenerator
passwordGenerator -> passwordGenerator: append character

passwordGenerator -> randomCharacterGenerator: generateSpecialCharacter()
activate randomCharacterGenerator

randomCharacterGenerator -> passwordGenerator: return special character
deactivate randomCharacterGenerator
passwordGenerator -> passwordGenerator: append character

loop passwordLength - 4 times
passwordGenerator -> randomCharacterGenerator: generateAllowedCharacter()
activate randomCharacterGenerator

randomCharacterGenerator -> passwordGenerator: return character
deactivate randomCharacterGenerator
passwordGenerator -> passwordGenerator: append character
end

passwordGenerator -> stringShuffler: shuffle(characters)
activate stringShuffler

stringShuffler -> passwordGenerator: return shuffled characters
deactivate stringShuffler

argumentProcessor <-- passwordGenerator: return generated password
deactivate passwordGenerator

argumentProcessor -> terminal: show(password)
activate terminal
argumentProcessor <-- terminal
deactivate terminal

else #Pink Arguments are not valid
argumentProcessor -> terminal: show(usage)
activate terminal
argumentProcessor <-- terminal
deactivate terminal
end

app <-- argumentProcessor
deactivate argumentProcessor

@enduml
9 changes: 9 additions & 0 deletions diagrams/UseCase.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@startuml UseCase
actor "User" as user

rectangle demo-kotlin-cli {
usecase "Generate Password" as generatePassword
}

user -> generatePassword
@enduml

0 comments on commit cca5a7a

Please sign in to comment.