archview

Layer classification

How functions are mapped to layers and modules.

archview assigns each function a layer and a module from its import path — by convention, no annotations required.

Default keywords

A path segment (or a suffix of one) matching these keywords sets the layer:

LayerKeywords
controllercontroller(s), handler(s), delivery, rest, transport, grpc, graphql, web
serviceservice(s), usecase(s), interactor(s), application, logic
repositoryrepository, repo(s), store(s), dao, persistence, gateway, postgres, mysql, mongo, sqlite

Matching is case-insensitive and works as a whole segment or a suffix: user_service → layer service, module user.

Module resolution

The module is the first non-generic segment before the layer. Structural container dirs are skipped, so the module resolves to the bounded-context name:

internal/user/controller          → layer controller, module user
catalog/adapter/rest              → layer controller, module catalog
catalog/adapter/postgres          → layer repository, module catalog

Skipped container segments include: internal, app, pkg, cmd, modules, features, components, domain, adapter(s), port(s), inbound, outbound, infra(structure).

Module grouping

The module (the swimlane a node sits in) is the bounded-context name:

  • Feature-first (user/service, user/repository) → the segment before the layer keyword: user.
  • Layer-first (core/user, handlers/user, interface/user) → the segment after it: user.

Either way, related layers line up under one feature lane.

Extending

Add your own keywords without losing the defaults:

av, _ := archview.New(archview.Options{
	Classify: &classify.Config{
		Extra: map[string][]string{
			graph.LayerRepository: {"clickhouse", "elastic"},
		},
	},
})

On this page