Skip to content

Graphfity is a Gradle Plugin which creates a dependency node diagram graph about your internal modules dependencies, specially useful if you are developing a multi-module application

License

Notifications You must be signed in to change notification settings

ivancarras/graphfity

Repository files navigation


Graphfity creates a dependency nodes diagram graph about your internal modules dependencies, specially useful if you are developing a multi-module application

View Demo Β· Report Bug Β· Request Feature



Table of Contents

  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact

About The Project

product-image

As a software engineer, you should know how difficult is to maintain a project without a previous initial good architecture. The project scales, new libraries, new features, new dependencies between the internal modules are added...

The purpose of this plugin is help to visualize all the project dependencies between the internal modules, as the projects grows, having of this way a main screenshot of all the features, libraries, core modules, components, or whatever kind of module you want to analise in your project.

Built With

  • Graphviz Graph visualization software
  • Kotlin-DSL An alternative to the traditional Groovy DSL using a modern language as Kotlin
  • Kotlin The natural Java evolution, a modern, concise and save programming language

Getting Started

Prerequisites

Graphviz setup full guide: https://graphviz.org/download/

Mac 🍏

Option #1
sudo port install graphviz
Option #2
brew install graphviz

Windows

Option #1
winget install graphviz
Option #2
choco install graphviz

Linux 🐧

Option #1
sudo apt install graphviz
Option #2
sudo yum install graphviz
Option #3
sudo apt install graphviz

Installation

Groovy DSL

root build.gradle

// Using the plugins DSL
plugins {
    id "com.github.ivancarras.graphfity" version "1.1.0"
}
// Using legacy plugin application
buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "com.github.ivancarras:graphfity-plugin:1.1.0"
    }
}
apply plugin: com.github.ivancarras.graphfity.plugin.main.GraphfityPlugin

Kotlin DSL

root build.gradle.kts

// Using the plugins DSL
plugins {
  id("com.github.ivancarras.graphfity") version "1.1.0"
}
// Using legacy plugin application
buildscript {
  repositories {
    maven {
      url = uri("https://plugins.gradle.org/m2/")
    }
  }
  dependencies {
    classpath("com.github.ivancarras:graphfity-plugin:1.1.0")
  }
}

apply(plugin = "com.github.ivancarras.graphfity")

Plugin configuration

The plugin admits 3 configuration properties:

  • nodeTypesPath (mandatory): this is the path for your json node types configuration file (explanation below)
  • projectRootName (optional): start point from the task draws the dependencies, the default value is the ":app" module
  • graphImagePath (optional): path where your graph image will be placed

NodeTypes.json

This is the file used to establish the different nodeTypes of your project a perfect example could be a project divided into:

  • App
  • Features
  • Components
  • Libraries
  • Core

nodeTypes.json

[
  {
    "name": "App",
    "regex": "^:app$", 
    "isEnabled": true, 
    "shape": "box3d",
    "fillColor": "#BAFFC9"
  },
  {
    "name": "Feature",
    "regex": "^.*feature.*$",
    "isEnabled": true,
    "shape": "tab",
    "fillColor": "#E6F98A"
  },
  {
    "name": "Component",
    "regex": "^.*component.*$",
    "isEnabled": true ,
    "shape": "component",
    "fillColor": "#8AD8F9"
  },
  {
    "name": "Libraries",
    "regex": "^.*libraries.*$",
    "isEnabled": true,
    "shape": "cylinder",
    "fillColor": "#FFACFA"
  },
  {
    "name": "Core",
    "regex": "^.*core.*$",
    "isEnabled": true,
    "shape": "hexagon",
    "fillColor": "#D5625A"
  }
]

Node explanation

{
    "name": "App", //Node name
    "regex": "^:app$", //This regex corresponds to the modules which will be draw as this node type
    "isEnabled": true, //Enable o disable the visualization of this node
    "shape": "box3d", // Graphviz node shape you can choose another one using: https://graphviz.org/doc/info/shapes.html
    "fillColor": "#BAFFC9"//Hexadecimal color for these nodes
}

Copy this initial configuration file in an accessible path in your project. (the root path is perfect)

Now is time to configure the plugin:

Groovy DSL

root build.gradle.kts

graphfityExtension {
  nodeTypesPath = "<nodesTypes.json>" //(mandatory) Examples: graphfityConfig/nodesTypes.json establish the route to your nodeTypes.json
  projectRootName = "<projectNameToAnalise>" //(optional) Examples: ":app", ":feature:wishlist"... is up to you
  graphImagePath = "<graphsFolder>" //(optional)the folder where will be placed your graph.png image
}

Kotlin DSL

root build.gradle.kts

configure<GraphfityPluginExtension> {
  nodeTypesPath.set("<nodesTypes.json>") //(mandatory) Examples: graphfityConfig/nodesTypes.json establish the route to your nodeTypes.json
  projectRootName.set("<projectNameToAnalise>") //(optional) Examples: ":app", ":feature:wishlist"... is up to you
  graphImagePath.set("<graphsFolder>") //(optional)the folder where will be placed your graph.png image
}

Usage

When your configuration is done now you can execute:

Mac 🍏 & Linux 🐧

./gradlew graphfity

Windows πŸͺŸ

gradle graphfity

The graph is going to be generated in the respective graphImagePath defined in the configuration

Roadmap

See the open issues for a list of proposed features (and known issues)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the Apache License. See LICENSE for more information.

Contact

LinkedIn

ivan.carrasco.dev@gmail.com