Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .github/readme/zeeguu-api-completeView.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/readme/zeeguu-api-inside-core.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/readme/zeeguu-completeView.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [0.2.9] - 2025-06-23
### Bugfix
- Default view shows top level packages not all the packages in the system

## [0.2.8] - 2025-06-23
### Added Manifest.in
- Fixed package depth functionality that was not working properly (with Sebastian Cloos Hylander)
### Bugfix
- Fixed package depth functionality that was not working properly: when depth is 2 the view should not show nodes at depth 1 or 3! (with Sebastian Cloos Hylander)
119 changes: 47 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ Lastly, ArchLens can display the highlighted differences in the system views whe

To help you get started, this readme includes various options in combination with the setup of a config file.

### ArchLens runs is compatible with 3.9 <= Python version <= 3.12.0
## Compatibility

ArchLens is compatible with projects written in **Python versions greater than 3.9**

## Installation

Expand Down Expand Up @@ -64,105 +66,78 @@ This will create an "archlens.json" file in your root folder, where you can edit

```

Here are two views of the 'zeeguu-api' project that we will be using as examples:

- A complete view of the system

![Zeeguu view](.github/readme/zeeguu-completeView.png)

Hard to grasp? ArchLens agrees with you, which is why this tool exists.
### You can render the views specified in your "archlens.json" file by running the command:
- `archlens render`

- A view of the system where everything except "core" and its sub-packages has been scraped away:
This will generate the diagrams for all the views defined in your configuration file and save them in the location specified in the "saveLocation" field of your configuration.
Since currently you only have one view you will only see the following:

![Zeeguu core view](.github/readme/zeeguu-coreViewxx.png)
![Zeeguu view](https://raw.githubusercontent.com/archlens/ArchLens/master/.github/readme/zeeguu-api-completeView.png)

Here is an edited version of the "archlens.json" file for the 'zeeguu-api' project, which represents the first two views we created earlier, along with comments explaining each field briefly:
## Expanding Packages

The "views" field in the "archlens.json" file allows you to define as many views as you need for your project. Simply add a new object with a unique name for each view you want to create. For example, if you wanted to create a view that showed only the "utils" package in the "api" folder, you could add the following to the "views" field:
If you want to generate another view, in which you want to show the contents of the `core` package for example, you can do it by adding a new view to your definition. E.g.

```json
{
{
"$schema": "https://raw.githubusercontent.com/archlens/ArchLens/master/src/config.schema.json",
"name": "zeeguu", # Name of project
"rootFolder": "zeeguu", # Name of source folder containing the root package (Usually a folder called src)
"name": "",
"rootFolder": "",
"github": {
"url": "https://github.com/zeeguu/api", # Link to project's Github
"branch": "master" # Name of main/master branch of project
"url": "",
"branch": "main"
},
"saveLocation": "./diagrams/", # Location to store generated diagrams
"views": { # Define each view
"completeView": { # Name of first view, you may add more
"packages": [], # Select packages to see in view, if left empty, see entire system view
"ignorePackages": [] # Specify packages not to include in diagram
}, "coreView":{ # Create view containing specific packages
"packages": [
"core" # In this case, we only allow packages starting with the name 'core'
],
"saveLocation": "./diagrams/",
"views": {
"completeView": {
"packages": [],
"ignorePackages": []
},

"inside-core": {
"packages": [
{
"path": "core",
"depth": 1
}
]
}
}

```

### You can render the views specified in your "archlens.json" file by running the command:
- `archlens render`

This will generate the diagrams for all the views defined in your configuration file and save them in the location specified in the "saveLocation" field of your configuration.

## Further Filtering of packages
This will generate another view that shows all the dependencies inside the `core` package

If you find the core view to be too large, you can create a new view that further filters the packages. Instead of giving a path to the package "core", you can limit it further by specifying that you want to see "core" and only its sub-packages that are 1 layer down.

To achieve this, you can create an object instead of a string path for the package, with two fields: "depth" and "path". In the "depth" field, you specify the number of sub-packages you want to include, and in the "path" field, you specify the package to start with.
![Zeeguu view](https://raw.githubusercontent.com/archlens/ArchLens/master/.github/readme/zeeguu-api-inside-core.png)

For example, the following configuration file defines a view for the "core" package and its immediate sub-packages:

![Zeeguu core view](.github/readme/zeeguu-coreViewDepthFiltered.png)
## Filtering of packages

This will create a view that shows only the "core" package and its immediate sub-packages.
The last view we generated above is quite dense. One way to solve this problem is to observe that almost all the packages depend on the `core.model` package. When every node depends on it, drawing all the dependencies has little value. We can filter nodes that are shown in the diagram if we use the `ignorePackages` key in a view definition.

Here is an example of the archlens.json file used to generate the filtered view:
We redefine the view to filter out the `core.mode` package from the view:

```json
{
"$schema": "https://raw.githubusercontent.com/archlens/ArchLens/master/src/config.schema.json",
"name": "zeeguu",
"rootFolder": "zeeguu",
"github": {
"url": "https://github.com/zeeguu/api",
"branch": "master"
},
"saveLocation": "./diagrams/",
"views": {
"coreView":{
"packages": [
#We create an object instead of a path
{
"depth": 1, #We only want 1 layer of sub packages from core
"path": "core" #Just like before, we give the path
}
],
"ignorePackages": []
}
}
}

"inside-core": {
"packages": [
{
"path": "core",
"depth": 1
}
],
"ignorePackages": [
"core.model",
]
},
```

You can combine both strings and objects when defining packages in the packages array in the configuration file. For example, you can include all packages starting with "api/utils" along with packages in the "core" directory up to a depth of 1 using the following syntax:

```json
The resulting view is much more relevant for understanding the architecture of this sytem.

"packages": [
"api/utils",
{
"path": "core",
"depth": 1
}
]
![Zeeguu view](https://raw.githubusercontent.com/archlens/ArchLens/master/.github/readme/zeeguu-api-inside-core-no-model.png)

```

## Arrows
Each arrow in the system diagram represents a dependency between two packages, and the number on the arrow indicates the number of dependencies going in that direction. If you prefer not to see these arrows, you can use the optional "showDependencyCount" setting, which is a boolean. When set to "false", the dependency count will be hidden in all views. Here is an example of how to set this option in your archlens.json file:
Expand Down Expand Up @@ -225,7 +200,7 @@ To render this new view displaying the changes, a new command must be run:

- `archlens render-diff`

![Zeeguu core view](.github/readme/zeeguu-modelViewdiffView.png)
![Zeeguu core view](https://raw.githubusercontent.com/archlens/ArchLens/master/.github/readme/zeeguu-modelViewdiffView.png)

If there are no diffrences, a diagram without diffrences will still be generated.

Expand All @@ -238,7 +213,7 @@ To display the difference views in your pull requests, run the command:

This command generates the necessary files in the .github folder, creating it if it doesn't already exist. Once this is done, you can create a pull request, and the difference view will be visible to the reviewer, as shown in the image below. If there are no diffrences, a diagram without diffrences will still be generated.

![Zeeguu core view](.github/readme/zeeguu-modelViewDiffGithub.png)
![Zeeguu core view](https://raw.githubusercontent.com/archlens/ArchLens/master/.github/readme/zeeguu-modelViewDiffGithub.png)

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name="ArchLens",
version="0.2.8",
version="0.2.9",
description="Designed for visualizing package dependencies and highlighting differences between"
" branches in GitHub pull requests. It offers customization options to tailor package views.",
author="The ArchLens Team",
Expand Down
4 changes: 4 additions & 0 deletions src/views/view_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def path(self):
@property
def parent_path(self):
return get_view_package_path_from_bt_package(self.bt_package.parent_module)

def is_root_package(self) -> bool:
"""Check if this package is a root package (has no parent)"""
return self.parent_path == "."

def setup_dependencies(self, view_package_map: dict[str, "ViewPackage"]):
bt_dependencies = self.bt_package.get_module_dependencies()
Expand Down
12 changes: 9 additions & 3 deletions src/views/view_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,11 @@ def _filter_packages(
filter_path = filter_path.replace("*", "")
view_depth = package_definition_from_config["depth"]

if filter_path == "" and view_package.parent_path == ".":
# TODO: when could this happen?
if filter_path == "" and view_package.is_root_package():
# This happens when config specifies {"path": "", "depth": N}
# to include all root packages up to depth N
filtered_packages_set.add(view_package)

depth_filter_packages = _find_packages_with_depth(
view_package, view_depth - 1, packages_map
)
Expand All @@ -256,7 +258,11 @@ def _filter_packages(
filtered_packages_set.update(depth_filter_packages)

if len(view["packages"]) == 0:
filtered_packages_set = set(packages_map.values())
# If no packages specified, only include root packages (those without a parent)
filtered_packages_set = set(
package for package in packages_map.values()
if package.is_root_package()
)

# ignorePackages

Expand Down