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

Roadmap (short)

  • Open-source CLI and analysis engine
  • Proprietary hosted service with:
    • Cross-repository insights
    • Historical trend analysis
    • Team-level governance and reporting

License

Apache-2.0. 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.2.tar.gz (170.1 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.2-py3-none-any.whl (87.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pacta-0.0.2.tar.gz
  • Upload date:
  • Size: 170.1 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.2.tar.gz
Algorithm Hash digest
SHA256 db480f1f974ad97a89db826ba87778e341f8779b9487b8f9a725de85ad322189
MD5 52c0b76652ac4b0fb565ea992ee1ad00
BLAKE2b-256 38de5f7917a4afbcd9084e4226c674ce26a55c62d5051253269bd02fc827fcbe

See more details on using hashes here.

Provenance

The following attestation bundles were made for pacta-0.0.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: pacta-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 87.0 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bfcdd48ed1275cbf80ef9229134c6b0050472de50aff221bba1b1660c8a5b762
MD5 1f66dbb2df1346a3137ade8c6a5273c9
BLAKE2b-256 56cfe0fe01752da02a7c98770311019019d3f8370768888132c89529c8508cc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pacta-0.0.2-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