Skip to content
Lotte Juul Damgaard edited this page Sep 15, 2025 · 4 revisions

Code documentation

cli_interface file

Contains commands to run from the command prompt to analyse and render a project

core folder

In the core folder there are three files:

  1. bt_file.py - a representation of a file in the system, wherefrom Astroid can read the imports of the file (in the function get_imported_modules)
  2. bt_module.py - a representation of a module in the system
  3. bt_graph.py - the whole file tree, where modules are found*, and then their dependencies

*NOTE: Only folders with a file called __init.py__ are counted as a module. Additionally, a root module (also with an init file) is necessary. Sibling folders only do not work.

git_integration folder

The folder contains a single (operational**) file fetch_git.py (which could be just a utils file) that clones a GitHub repository and checkout to a provided branch.

providers folder

Contains two subfolders json and plantuml which (with a lot of duplicated code):

  1. Provides methods to save a created dependency graph to a newly generated file in a local folder, in the respective format (json/puml)
  2. (the save functions calls) a private method for rendering the graph in the respective format

** Currently all folders contain an __init__.py

views folder

view_entity.py

declared classes

EntityState Enum of visual states: CREATED#Green, DELETED#Red, NEUTRAL"" (empty, so you can inject a default color from config).

ViewPackage (a node in the view graph)

  • Built from a BTModule.
  • name: a dotted form of the module’s view path (converts "a/b/c""a.b.c").
  • path: the module’s view path itself (slash-separated), via get_view_package_path_from_bt_package.
  • parent and sub_modules: hierarchy of view packages.
  • view_dependency_list: outgoing edges (ViewDependancy) from this package.
  • state: visual state used when rendering a package.

ViewDependancy (an edge in the view graph)

  • Holds from_package/to_package (view level) and the corresponding from_bt_package/to_bt_package (domain level).
  • On init:
    • dependency_count = from_bt.get_dependency_count(to_bt)
    • edge_files = from_bt.get_file_level_relations(to_bt) (list of (BTFile, BTFile) pairs for traceability)
  • render_pu() / render_json():
    • If not in diff mode (render_diff is empty), they render using the live fields and optional count (driven by ConfigManagerSingleton().show_dependency_count).
    • If in diff mode, they read precomputed fields from render_diff (e.g., color/label/from/to) to display “created/deleted/changed” edges.