A tool to model and analyze the design of systems from .class files

Overview

sift

A tool to model and analyze the design of systems from java class files.

Features

  • CLI tool for building, querying and diff-ing "system models" from parsed .class files.
  • System models consist of Entities and are produced by Instrumenter Pipelines.
  • Instrumenter Pipelines provide knowledge about technology stacks for (static) bytecode analysis.
  • Declarative DSL for additional, user-defined pipelines.
  • JSON serialization of pipelines for simpler reuse and sharing.

sift spring-boot axon framework demo

Spring-Boot with Axon Framework instrumenter in action.

CLI options

Usage: sift [OPTIONS] [PATHS]...


Usage: sift [OPTIONS]

  A tool to model and analyze the design of systems from bytecode.

Options:
  -f, --class-dir PATH                        jar or directory with classes
  -l, --list-instrumenters                    print all instrumenters detected on the current classpath
  -i, --instrumenter INSTRUMENTER             the instrumenter pipeline performing the scan
  --profile                                   print execution times and input/output for the executed
                                              pipeline
  -T, --tree-root ENTITY-TYPE                 tree built around requested entity type
  -t, --list-entity-types                     lists entity types defined by instrumenter
  -L, --max-depth INT                         Max display depth of the tree
  -F, --filter REGEX                          filters nodes by label. can occur multiple times
  -S, --filter-context REGEX                  filters nodes by label, while also including sibling nodes.
                                              can occur multiple times
  -e, --exclude REGEX                         excludes nodes when label matches REGEX; can occur multiple
                                              times
  -E, --exclude-type ENTITY-TYPE              excludes entity types from tree; can occur multiple times
  -s, --save FILE_JSON                        save the resulting system model as json; for later use by
                                              --diff or --load
  --load FILE_JSON                            load a previously saved system model
  -d, --diff FILE_JSON                        load a previously saved system model
  -a, --ansi [none|ansi16|ansi256|truecolor]  override automatically detected ANSI support
  --version                                   print version and release date
  --debug                                     prints log/logCount statements from the executed pipeline
  --generate-completion [bash|zsh|fish]
  -h, --help                                  Show this message and exit

Entity and Entity Type

The system model is described by its constituent entities and their relationships. Each entity is uniquely identified by either a class, method, field or parameter element; an element can not be associated with more than one entity.

All entities are mapped to a type. A type represents any notable part of the system, e.g. REST controllers, HTTP endpoints, inbound/outbound messages, RDS etc.

$ sift --instrumenter spring-axon --list-entity-types target/classes
entity types of spring-axon
  1 aggregate
  2 aggregate-ctor
  1 aggregate-member
  6 command
  6 command-handler
  1 controller
 13 endpoint
  7 event
  7 event-handler
  7 event-sourcing-handler
  1 projection
  3 query
  4 query-handler

Instrumenter pipelines

Instrumenter Pipelines provide knowledge about a technology stack and/or project-specific constructs. The pipeline produces the system model from the input classes.

Pipelines are written in a declarative DSL, which provides high-level abstractions for identifying and interrelating entities from class structure or usage.

val controller = Entity.Type("controller")
val endpoint = Entity.Type("endpoint")

instrumenter {
    // iterate over all input classes
    classes {                                                      
        annotatedBy<RestController>() // filter classes 
        entity(controller)            // mark remaining as 'controller'  
        methods {                     // iterate all controller methods
            annotatedBy<Endpoint>()   // filter @Endpoint methods
            entity(endpoint)

            // associate controllers with their endpoints  
            controller["endpoints"] = endpoint
        }
    }
}

Input elements - classes, methods, parameters and fields - are processed in batch, line-by-line.

A Instrumenter Pipeline can be expressed in about 100LOC. Some are notably shorter, e.g. jpa and jdbi. User-defined pipelines may choose to include() multiple existing pipelines, e.g. spring-axon and jpa, to better describe the underlying system while also keeping the resulting pipeline DSL concise.

The execution of an Instrumenter Pipeline can be visualized with --profile:

sift spring-boot axon framework demo

Caveats and limitations

  • no flow analysis making precise entity identification difficult for e.g. dispatcher-like methods dealing with multiple entity types.
You might also like...
Simplify the processing of sealed class/interface

shiirudo Generates DSL to simplify processing branching by when expressions in sealed class/interface. Setup Refer to the KSP quickstart guide to make

🧶 Library to handling files for persistent storage with Google Cloud Storage and Amazon S3-compatible server, made in Kotlin

🧶 Remi Library to handling files for persistent storage with Google Cloud Storage and Amazon S3-compatible server, made in Kotlin! Why is this built?

This library is created to make files uploading and downloading on Aws easier

S3Manager - aws files uploading library This library is created to make files uploading and downloading on Aws easier Features Easy to use Single/mult

Easy app for managing your files without ads, respecting your privacy & security
Easy app for managing your files without ads, respecting your privacy & security

Simple File Manager Can also be used for browsing root files and SD card content. You can easily rename, copy, move, delete and share anything you wis

The source files to the prototype app for the TomTom n.EXT Hackathon

nEXT-Hackathon2021 The source files to the prototype app for the TomTom n.EXT Hackathon. We are team MoTomized from Codam Coding College attempting to

A server which delivers the game cache files to an end-user.

RuneTopic Js5 Server A server which delivers the game cache files to an end-user. Setup Guide You can host a js5 server with Docker or with your local

These files are included in an Android Studio Project for a Magic the Gathering Life Counter app. The app was written in Kotlin.
These files are included in an Android Studio Project for a Magic the Gathering Life Counter app. The app was written in Kotlin.

Magic-Life-Counter These files were created in Android Studio using Kotlin. Usage This app was made to keep track of life totals while playing the tra

Gradle plugin which allows to use typed DSL for generating kubernetes/openshift YAML files

gr8s Gradle plugin which allows using typed DSL for generating kubernetes/openshift YAML files. Based on kuberig Usage import io.github.guai.gr8s.Gene

Kotlin script to prevent invalid conversion errors in projects with many localization files

Localization-Patterns-Checker Kotlin script to prevent invalid conversion errors

Releases(sift-0.4.0)
  • sift-0.4.0(Dec 7, 2022)

    sift-0.4.0 2022-12-07

    New

    Signature Scope: Limited DSL support for exploring generics/type signatures, e.g. Foo inside List<Foo>. Note that entities cannot be registered inside the signature scope. The type argument has to be registered by its raw class, using explodeType() {}.

    Support for method parameter signatures is currently lacking from the DSL.

    sift Self Instrumenter: A new instrumenter has been added that extracts the system model centered around the DSL. This instrumenter allows you to compare the changes to the DSL between releases using the --diff option. Currently, Sift does not have support for resolving Kotlin constructs, so some of the DSL method names may be mangled.

    sift diff 0.4.0 vs 0.3.0

    • DSL.Class: outerScope {} inner classes iterate over their outer classes.
    • DSL.Class: superclassSignature(synthesize=false) {} - parent class signature Foo<Bar>; skips non-generic parents (WIP).
    • DSL.Field: explodeType(synthesize=false) {} iterates class elements of fields.
    • DSL.Field: signature(synthesize=false) {} - generic field signature; skips non-generic fields.
    • DSL.Method: filterName() only inspects the method name; filter() also checks the class name.
    • DSL.Method, DSL.Field, DSL.Parameter: entity property method readName().
    • DSL.Method: returns(synthesize=false) {} signature scope for method return
    • DSL.Signature: explodeType(synthesize=false) {} - class scope of current type arguments.
    • DSL.Signature: filter(Regex) - filters concrete type argument by class name.
    • DSL.Signature: scope {} - local scope, as found elsewhere.
    • DSL.Signature: typeArgument(index) {} - filters nested type argument by position.
    • DSL.Signature: typeArguments {} - iterate nested type arguments.
    • DSL: readName(shorten=true) shortens names of inner classes.
    • Dot entity property dot-shape accepts valid graphviz shapes
    • Entity labels: extract all property values by prefixing the property name with +. E.g. ${+property}.

    Fixes

    • DOT: illegal node ids containing . and $.

    Changes

    • graphviz property dot-id renamed todot-id-as.
    • updated spring-axon grahpviz to use dot-shape.
    Source code(tar.gz)
    Source code(zip)
  • sift-0.3.0(Nov 18, 2022)

    sift-0.3.0 2022-11-18

    Breaking

    • DSL: update used for updating properties on existing entities is renamed to property.
    • DSL: parentScope renamed to outerScope in the name of clarity.

    Fixes

    • introspection of kotlin's noinline lambdas

    Features

    • CLI: --render/-R prints entities in graphviz's DOT language. sift.zsh and sift.sh automatically pipe to graphviz and displays the diagram inline. Note that -R will print the DOT script to stdout. sift-render
    • CLI: --dump-system-model prints all entities and their properties. Primarily useful for debugging.
    • sift.sh, QoL script similar to sift.zsh

    Changes

    • mvn install installs the executable into ~/.local/share/sift/bin. If compiling with -P native-image, the native sift executable is also copied.
    • "backtrack" references are now added to all child entities.
    Source code(tar.gz)
    Source code(zip)
  • sift-0.2.0(Nov 11, 2022)

    Breaking

    • CLI: -f replaces PATHS argument; filter changed to -F

    Features

    • CLI: --version option
    • CLI: --save/-s save the resulting system model as json
    • CLI: --diff compares a previous model with the current state
    • CLI: --load restores a previously saved model instead of instrumenting classes
    Source code(tar.gz)
    Source code(zip)
  • sift-0.1.0(Nov 6, 2022)

Owner
Adrian Papari
Professional Yak Shaver, subservient to computers, featherbrained :hatched_chick: .
Adrian Papari
Use Android Data Binding wih Live Data to glue View Model and Android

Gruop-C Spliff Summary Use Android Data Binding wih Live Data to glue View Model and Android. Asynchronous communications implemented with KotlinX Cor

null 2 Nov 21, 2021
Kotlin Example of how to organize your code using MVC and some patterns seen in class

Kotlin Example of how to organize your code using MVC and some patterns seen in class

José Luis González Sánchez 3 Mar 23, 2022
BindsAdapter is an Android library to help you create and maintain Adapter class easier via ksp( Kotlin Symbol Processing).

BindsAdapter BindsAdapter is an Android library to help you create and maintain Adapter class easier via ksp( Kotlin Symbol Processing). Installation

Jintin 5 Jul 30, 2022
Kotlin & Java class for gRPC client

jvm-minter-grpc-class Kotlin & Java class for gRPC client Use @TODO Разное Добавление git subtree add --prefix node-grpc-gateway https://github.com/Mi

Aleksey Kukhnovets 2 May 26, 2022
Kotlin compiler plugin that allows class delegation to be dynamic like property delegations

kotlin-dynamic-delegation Kotlin compiler plugin that allows class delegation to be dynamic like property delegations. The plugin is working in progre

Him188 14 Sep 8, 2022
A deep learning based mobile application for the multi-class classification of pneumonia into three categories via Chest X-rays

PneumoniaClassifier A deep learning based mobile application for the multi-class classification of pneumonia into three categories via Chest X-rays. W

Timilehin Aregbesola 2 Dec 15, 2021
A simple Kotlin class to use to connect to a MongoDB collection.

mongodb-kotlin A simple Kotlin class to use to connect to a MongoDB collection. Once you have created a MongoDB project, choose Build a Database: Next

null 2 Oct 23, 2022
Minimalistic class proxy creator for Kotlin

reflektion Minimalistic class proxy creator for Kotlin. Reflektion allows you to create an implementation of an interface you provide containing proxy

Subham 6 Nov 11, 2022
Go Outside is an augmented reality app designed for our team's Software Engineering UI/UX class

Go Outside Go Outside is an augmented reality app designed for our team's Software Engineering UI/UX class. This app serves as a PROTOTYPE to demonstr

Kris 4 Jul 28, 2022
PenPath class is designed to be used to draw paths with variable thickness

PenPath class is designed to be used to draw paths with variable thickness. It creates an object of android.graphics.Path and should be drawn with Paint.Style.FILL type paint.

null 2 Jun 5, 2022