Skip to main content

A Python tool for enforcing and visualizing software architecture.

Project description

Pacta

Architecture Governance & Architecture-as-Code

PyPIDocsIssues

PyPI - Version PyPI - Python Version GitHub License


Warning: Experimental. Expect breaking changes until release 0.1.0

Pacta is an architecture governance tool that helps teams define architectural intent, gain insights through metrics and historical trends, detect architectural drift, and evolve codebases safely without blocking delivery.

pip install pacta

Pacta Demo

Supported languages:

  • Python
  • Java (coming soon)
  • Go (coming soon)
  • C# (coming soon)

Why?

Codebases rot. Architecture degrades through small changes no one tracks. Pacta turns architecture into something measurable, reviewable, and enforceable — catching drift early, not months later.

What it does

  • Static analysis — parses Python AST, builds a system graph
  • Layer enforcement — domain can't import from infra, etc.
  • Snapshots — version your architecture like code
  • Baseline mode — fail only on new violations, not legacy debt
  • History tracking — view architecture evolution over time
  • Trend analysis — track violations, nodes, edges over time with charts

Quick example

This is a minimal example. See the docs for advanced rules, baselines, and history.

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

History tracking

Every scan creates a content-addressed snapshot. Inspect how your architecture evolves over time:

# View timeline
$ pacta history show --last 5

# View trends over time (violations, nodes, edges, coupling)
$ pacta history trends .

Docs

Roadmap (short)

  • Open-source CLI and analysis engine
  • Content-addressed snapshots with history tracking
  • Trend analysis with chart export
  • Architecture visualization (Mermaid, D2)
  • Health metrics (drift score, instability)
  • Optional hosted service (future):
    • 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.3.tar.gz (724.5 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.3-py3-none-any.whl (97.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pacta-0.0.3.tar.gz
  • Upload date:
  • Size: 724.5 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.3.tar.gz
Algorithm Hash digest
SHA256 fe9fc985e52c3925a05dba23d3734a33c31064bd8dd5e4526bcc0d4d21fcf387
MD5 877c356a56f2b55587a051edefc3646f
BLAKE2b-256 6a8c85a14c798129a2cd29059873ef638655fda3376f58ee1e6d68ca592f44c9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pacta-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 97.4 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6cc45df6f9e77c66df7b7452fec6c9ed36b8a3b233d3a5d646998533f7de1687
MD5 61ef866911ceac99578ddcff549bc025
BLAKE2b-256 cc589aacac043115c41474b31763cfdcc926827d8723d9360d5b48871aaf0a96

See more details on using hashes here.

Provenance

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