Skip to main content

A Python tool for enforcing and visualizing software architecture.

Project description

Pacta

Architecture Testing & Architecture-as-Code

PyPIDocsIssues

PyPI - Version PyPI - Python Version GitHub License


Warning: Experimental. Expect breaking changes.

Pacta enforces architectural rules in your codebase. Define layers, set boundaries, catch violations in CI.

Supported languages:

  • Python
  • Java (coming soon)
  • Go (coming soon)
  • C# (coming soon)
pip install pacta
pacta scan . --model architecture.yml --rules rules.pacta.yml

Why?

Codebases rot. The "clean architecture" you designed becomes spaghetti after a few quarters. Pacta catches violations early — in PRs, not post-mortems.

What it does

  • Static analysis — parses Python AST, builds import graph
  • Layer enforcement — domain can't import from infra, etc.
  • Baseline mode — fail only on new violations, not legacy debt
  • Snapshots — version your architecture like code

Quick example

Define your layers in architecture.yml:

version: 1
system:
  id: myapp
  name: My App

containers:
  backend:
    code:
      roots: [src]
      layers:
        domain:
          patterns: [src/domain/**]
        infra:
          patterns: [src/infra/**]

Add rules in rules.pacta.yml:

rule:
  id: no_domain_to_infra
  name: Domain cannot depend on Infrastructure
  severity: error
  target: dependency
  when:
    all:
      - from.layer == domain
      - to.layer == infra
  action: forbid
  message: Domain layer must not import from Infrastructure

Run it:

$ pacta scan . --model architecture.yml --rules rules.pacta.yml

✗ 2 violations (2 error) [2 new]
   ERROR [no_domain_to_infra] Domain cannot depend on Infrastructure @ src/domain/user.py:3:1
    status: new
    Domain layer must not import from Infrastructure

Baseline workflow

Got legacy violations? Save a baseline and only fail on new ones:

# Save current state
pacta scan . --model architecture.yml --rules rules.pacta.yml --save-ref baseline

# Later, in CI — fail only on new violations
pacta scan . --model architecture.yml --rules rules.pacta.yml --baseline baseline

Docs

License

AGPL-3.0-only. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pacta-0.0.1.tar.gz (179.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pacta-0.0.1-py3-none-any.whl (113.1 kB view details)

Uploaded Python 3

File details

Details for the file pacta-0.0.1.tar.gz.

File metadata

  • Download URL: pacta-0.0.1.tar.gz
  • Upload date:
  • Size: 179.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pacta-0.0.1.tar.gz
Algorithm Hash digest
SHA256 12fb8d1787c0b4bf81868e6634ea4a964e7339f2c690215d75922c1f4c894d67
MD5 df2f5ad2f1eaf757e9b8c34b7ed1c50a
BLAKE2b-256 a96ab8dac56758264de684910de594d8e00f9a7e4b133f7e57462fec00e0d868

See more details on using hashes here.

Provenance

The following attestation bundles were made for pacta-0.0.1.tar.gz:

Publisher: publish.yaml on akhundMurad/pacta

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pacta-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pacta-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 113.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pacta-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 820ce5100afefd87fbca923186a0378718bdf46c50979bd9726df54b58b23111
MD5 3395053e01af0456d9c5c2da127f3204
BLAKE2b-256 508caf5d4312f7c75376b033a1e4937e1026d9db21b90e71ab3346c38e1526e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pacta-0.0.1-py3-none-any.whl:

Publisher: publish.yaml on akhundMurad/pacta

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page