Skip to main content

Architecture validation library for Python projects

Project description

PyArchRules Logo

License: MIT Python 3.12+ Status: Beta Documentation

⚠️ Pre-release (beta). APIs may change before the stable 1.0 release.

📚 Full Documentation — Getting Started · Configuration · CLI Reference · Use Cases

PyArchRules enforces architecture rules in Python projects:

  • 🏗️ Folder structure validation per service
  • 🔗 Internal dependency direction control
  • 🛡️ Cross-service import isolation for monorepos
  • 🐍 Python DSL for writing rules inside your test suite
  • ⚙️ Zero extra config — everything in pyproject.toml
  • 🚀 CI-ready — exit code 1 on any violation

Installation

pip install pyarchrules

Quick start

# 1. Add [tool.pyarchrules] to pyproject.toml
pyarchrules init-project

# 2. Register a service
pyarchrules add-service backend src/backend

# 3. Run the check
pyarchrules check

TOML configuration

[tool.pyarchrules]
root             = "."
validate_paths   = true
isolate_services = true

[tool.pyarchrules.services.backend]
path         = "src/backend"
tree         = ["api", "domain", "infra"]
tree_mode    = "strict"
dependencies = ["api -> domain", "domain -> infra", "* -> utils"]

Python DSL

# tests/test_architecture.py
from pyarchrules import PyArchRules

def test_architecture():
    rules = PyArchRules()
    rules.for_service("backend") \
        .must_contain_folders(["api", "domain", "infra"], allow_extra=False) \
        .no_wildcard_imports() \
        .no_circular_imports()
    rules.validate()

CLI commands

Command Description
init-project Initialise [tool.pyarchrules] in pyproject.toml
add-service NAME PATH Register a service
remove-service NAME Remove a service
list-services Show all configured services
check Validate architecture

Contributing

See CONTRIBUTING.md.

License

MIT

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

pyarchrules-0.1.0b1.tar.gz (36.7 kB view details)

Uploaded Source

Built Distribution

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

pyarchrules-0.1.0b1-py3-none-any.whl (60.7 kB view details)

Uploaded Python 3

File details

Details for the file pyarchrules-0.1.0b1.tar.gz.

File metadata

  • Download URL: pyarchrules-0.1.0b1.tar.gz
  • Upload date:
  • Size: 36.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pyarchrules-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 d3017eb73fa7e3367e495efb6391c4e3b63d0f62b07711abd46ec76a0b13d207
MD5 6602a3999211a98329165bf2f587e70e
BLAKE2b-256 b18de0add72e6577402c2953c8baf00ed3a9eadbd59156c3b3d29751d30fb2cc

See more details on using hashes here.

File details

Details for the file pyarchrules-0.1.0b1-py3-none-any.whl.

File metadata

  • Download URL: pyarchrules-0.1.0b1-py3-none-any.whl
  • Upload date:
  • Size: 60.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pyarchrules-0.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 dc56bf050699458207841fbba2e5359f3464d35f470b4229d78d88aeb1522dab
MD5 636e28a490c43a8ddc75d034ec778125
BLAKE2b-256 0ffc03b97c7a12362237f796b5666d243292886e84174bac1eecb29f9157a8c3

See more details on using hashes here.

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