Skip to content

Visualising the layer structure on a CLI command #320

Description

@nazliander

Hi @seddonym 👋

We recently started using import-linter in our team - it's awesome and has made our architecture tests much cleaner!

We'd like to visualise our import layers to share with colleagues in a centralised place (e.g. in our CLI tool).

Would it make sense to add this functionality to import-linter directly? I've already prepared a simple CLI command in a fork.

The idea is to provide a command like:

uv run show-import-layers

Which outputs ASCII art of the layer hierarchy (including the awesome logo!):

╔══╗─────────▶╔╗ ╔╗      ╔╗◀───┐
╚╣╠╝◀─────┐  ╔╝╚╗║║────▶╔╝╚╗   │
 ║║   ╔══╦══╦╩╗╔╝║║  ╔╦═╩╗╔╝╔═╦══╗
 ║║╔══╣╔╗║╔╗║╔╣║ ║║ ╔╬╣╔╗║║ ║│║╔═╝
╔╣╠╣║║║╚╝║╚╝║║║╚╗║╚═╝║║║║║╚╗║═╣║
╚══╩╩╩╣╔═╩══╩╝╚═╝╚═══╩╩╝╚╩═╩╩═╩╝
  └──▶║║                    ▲ 
      ╚╝────────────────────┘


--------------------
Layered architecture
--------------------

        ▲ higher level (can import from layers below)
        │
   ┌────────────────────────────┐
   │            cli             │
   ├────────────────────────────┤
  ↓│            api             │
   ├────────────────────────────┤
  ↓│         contracts          │
   ├────────────────────────────┤
  ↓│       configuration        │
   ├────────────────────────────┤
  ↓│          adapters          │
   ├────────────────────────────┤
  ↓│  application   ║   domain  │
   └────────────────────────────┘
        │
        ▼ lower level (cannot import layers above)

  ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
  Legend:
    ║  independent modules (cannot import each other)

Happy to talk about it in a PR if you're interested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions