Skip to content

lightform-oss/c4-modeling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example

See example code here

Model system architecure in code

object PersonalBankingCustomer extends Person("personal customer of the bank")

object EMailSystem extends System("microsoft exchange", external = true)
object MainframeBankingSystem extends System("old", external = true)
object InternetBankingSystem extends System {

  object WebApplication extends Container(
    "Java and Spring MVC", "delivers the static content"
  )

  object SinglePageApplication extends Container("Javascript and Angular")
  object MobileApp extends Container("Xamarin", "subset of web functionality")
  object Database extends Container("Oracle", "user info", true)

  object APIApplication extends Container("Java and Spring MVC") {

    object PasswordResetController extends Component("Spring MVC Rest controller")

    object SignInComponent extends Component(
      "Spring MVC Rest controller", "lets users sign in"
    )

    object AccountsSummaryController extends Component(
      "Spring MVC Rest controller", 
      "gives customers summaries of their accounts"
    )

    object SecurityComponent extends Component(
      "Spring Bean", "functions related to sign in, password change, etc"
    )

    object EMailComponent extends Component(
      "Spring Bean", "sends emails to users"
    )

    object MainframeBankingSystemFacade extends Component(
      "Spring Bean", "facade to mainframe bank system"
    )
  }
}

Create diagrams by describing relationships in the model

render(
  PersonalBankingCustomer-
    "visits website"-->InternetBankingSystem.WebApplication,

  PersonalBankingCustomer-
    "views account balances"-->InternetBankingSystem.SinglePageApplication,

  PersonalBankingCustomer-
    "views account balances"-->InternetBankingSystem.MobileApp,

  InternetBankingSystem.WebApplication-
    "delivers to browser"-->InternetBankingSystem.SinglePageApplication,

  InternetBankingSystem.MobileApp-
    "makes api calls"-->InternetBankingSystem.APIApplication,

  InternetBankingSystem.SinglePageApplication-
    "makes api calls"-->InternetBankingSystem.APIApplication,

  InternetBankingSystem.APIApplication-
    "r/w"-->InternetBankingSystem.Database,

  InternetBankingSystem.APIApplication-
    "sends email using"-->EMailSystem,

  InternetBankingSystem.APIApplication-
    "makes api calls to"-->MainframeBankingSystem
)

Render diagrams using plantUML

$ ./big-bank-plc-containers.sc | java -jar plantuml.jar -pipe > big-bank-plc-containers.png
$ ./big-bank-plc-containers.sc > big-bank-plc-containers.puml

Install

  1. Install ammonite
  2. Download the modeling script wget https://raw.githubusercontent.com/kag0/c4-modeling/main/c4.sc
  3. Reference from your modeling and diagram code
    import $file.^.c4
    import c4._