Skip to content
/ archview Public

Create architectural diagrams from Go code.

License

Notifications You must be signed in to change notification settings

storj/archview

Repository files navigation

ArchView

ArchView is a tool for creating and inspecting Go program architecture based on annotations.

Introduction

To start using, add annotations like so:

// architecture: Database
type DB interface {
	Query() string
}

// architecture: Service
type Users struct {
	db       *DB
	comments *Comments
}

// architecture: Service
type Comments struct {
	db    *DB
	users *Users
}

// architecture: Server
type Server struct {
	comments *Comments
	users    *Users
}

// we can create links between interfaces and implementations with idiomatic Go
var _ DB = &PostgresDB{}
var _ DB = (*SqliteDB)(nil)

// architecture: Database Implementation
type PostgresDB struct{}

// architecture: Database Implementation
type SqliteDB struct{}

When we run the tool to output a graphviz dot file:

archview ./... | dot -Tsvg > graph.svg

Basic Diagram

We can also use more complicated tools, by outputting a graphml file:

archview -out example.graphml ./... 

With a tool like yEd we can try different ways of visualizing:

Prettier Diagram

Install

To install archview run:

go install github.com/storj/archview@latest

You'll also need a tool to layout the graph, for example:

  1. GraphViz for dot formats.
  2. yEd for graphml formats.

Running the tool outputs the graph definition:

archview [-format (dot|dot-basic|graphml)] [-out <output file>] [packages]

About

Create architectural diagrams from Go code.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages