Skip to main content

Architecture validation library for Python projects

Project description

PyArchRules Logo

License: MIT Python 3.10+ Status Beta Documentation

⚠️ This is a pre-release (beta) version. APIs may change before the stable 0.1.0 release.

Documentation

📚 Full Documentation - Getting Started, Configuration, CLI Reference, Use Cases

Features

  • 🏗️ Structure validation - enforce directory tree requirements
  • 🔗 Dependency rules - control module imports (e.g., api -> domain)
  • 🎯 DSL & Config - use Python DSL or TOML configuration
  • 🚀 Zero setup - works with pyproject.toml
  • 🔍 CLI & API - integrate into CI/CD or use programmatically

Installation

pip install pyarchrules

Quick Start

# Initialize
pyarchrules init-project

# Check architecture
pyarchrules check

Configuration Example

[tool.pyarchrules]
project_name = "myapp"

[tool.pyarchrules.services.backend]
path = "src/backend"

# Enforce directory structure
tree = ["api", "domain", "infra"]
tree_strict = true

# Control dependencies (api can import from domain)
dependencies = ["api -> domain", "domain -> infra"]

Python API

from pyarchrules import PyArchRules

rules = PyArchRules()

# DSL validation
rules.for_service("backend") \
    .must_contain_folders(["api", "domain"])

result = rules.validate()

CLI Commands

Command Description
pyarchrules init-project Initialize configuration
pyarchrules check Validate architecture
pyarchrules add-service NAME PATH Add service
pyarchrules list-services List all services

Use Cases

Monorepos - enforce boundaries between services

[tool.pyarchrules.services.auth]
path = "services/auth"
dependencies = ["auth -> shared"]

Clean Architecture - validate layer dependencies

dependencies = [
    "api -> application",
    "application -> domain"
]

Microservices - ensure consistent structure

tree = ["api", "domain", "infrastructure"]
tree_strict = true

Development

uv sync
make test
make lint

Status

⚠️ Pre-release (Beta)0.1.0b0 is a beta release. Core features are functional but the public API may still change before the stable 1.0 release. Not recommended for production use yet.

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.0b0.tar.gz (18.6 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.0b0-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyarchrules-0.1.0b0.tar.gz
  • Upload date:
  • Size: 18.6 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.0b0.tar.gz
Algorithm Hash digest
SHA256 921c32ea674b05e782c4313dd4ce9d530aef39ae00d683405f4c91c0e8abf52d
MD5 c33215604966755a8a2d056948fcd853
BLAKE2b-256 251be889e0c55a337e07c106fdfbe93846312a9189dd1630c0b50576dececf63

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyarchrules-0.1.0b0-py3-none-any.whl
  • Upload date:
  • Size: 25.3 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.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 806379aae138ee53fcf8908c0bc0244e8452edb011c8569e31f761b874e76c2f
MD5 10fc29b7e5c6ff2d2a99ff6a9a2f0f98
BLAKE2b-256 e0c7c54a1d0fe903da79b3d76dedec3ab3f52b0dd3bffa33225d9d032de89671

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