architecture

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package architecture defines the configuration and logic for architecture validation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Layers   []Layer  `yaml:"layers"`
	Settings Settings `yaml:"settings"`
}

Config represents the architecture rules configuration.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig reads the architecture configuration from a YAML file.

func (*Config) AllowSelf

func (c *Config) AllowSelf() bool

AllowSelf returns true if dependencies within the same layer are allowed.

func (*Config) AllowUnknown

func (c *Config) AllowUnknown() bool

AllowUnknown returns true if dependencies to or from unknown layers are allowed.

func (*Config) Allowed

func (c *Config) Allowed(fromLayer, toLayer string) bool

Allowed returns true if a dependency from fromLayer to toLayer is permitted.

func (*Config) DefaultAllowAll

func (c *Config) DefaultAllowAll() bool

DefaultAllowAll returns the default behavior when a layer has no explicit allow rules.

type Layer

type Layer struct {
	Name     string   `yaml:"name"`
	Patterns []string `yaml:"patterns"`
	Allow    []string `yaml:"allow"`
}

Layer defines a logical layer in the application and its allowed dependencies.

type Matcher

type Matcher struct {
	// contains filtered or unexported fields
}

Matcher handles mapping files to architecture layers.

func NewMatcher

func NewMatcher(cfg *Config) *Matcher

NewMatcher creates a new architecture layer matcher.

func (*Matcher) LayerForFile

func (m *Matcher) LayerForFile(path string) (string, bool)

LayerForFile determines which layer a file belongs to based on patterns.

type Settings

type Settings struct {
	AllowUnknown    *bool `yaml:"allow_unknown"`
	AllowSelf       *bool `yaml:"allow_self"`
	DefaultAllowAll *bool `yaml:"default_allow_all"`
}

Settings contains global architecture validation settings.

type Violation

type Violation struct {
	FromID    string
	ToID      string
	FromLayer string
	ToLayer   string
	EdgeType  graph.EdgeType
	FromFile  string
	ToFile    string
	FromLine  int
	ToLine    int
}

Violation represents an architectural rule violation where a dependency exists between layers that is not explicitly allowed.

func FindViolations

func FindViolations(ctx context.Context, store contracts.Store, cfg *Config) ([]Violation, error)

FindViolations scans the store for edges that violate architecture rules.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL