Skip to content

Commit 53e77ef

Browse files
authored
Merge pull request #9 from mspitb/release-0.1.0b0
PyArchRules beta-release 0.0.1b0
2 parents 3673968 + 3458e85 commit 53e77ef

File tree

81 files changed

+4681
-744
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+4681
-744
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
| Version | Date | Author | Changes |
66
|---------|------------|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
7+
| 0.1.0b0 | 2026-02-23 | Sergei Mikheev | **Beta release preparations** <br>• Update DSL rules, fix issues <br>• Update mkdocs <br>• Add contributing document |
78
| 0.0.1a2 | 2026-02-19 | Sergei Mikheev | **DSL and linter rules updates**<br>• Update Readme docs |
89
| 0.0.1a1 | 2026-02-18 | Sergei Mikheev | **Code quality and design improvements**<br>• Improve core module design<br>• Add DSL rules<br>• Simplified docstrings across core modules<br>• Add linting features (project tree, dependencies graph) |
910
| 0.0.1a0 | 2026-02-17 | Sergei Mikheev | **Initial alpha release**<br>• CLI commands: `init-project`, `add-service`, `remove-service`, `list-services`<br>• Configuration management via pyproject.toml<br>• Interactive CLI prompts<br>• Service name validation<br>• Support for monorepo/multi-service projects |

CONTRIBUTING.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Contributing
2+
3+
Thank you for your interest in contributing to PyArchRules.
4+
5+
## Before you start
6+
7+
- For bug fixes and small improvements, open a pull request directly.
8+
- For larger changes or new features, open an issue first to discuss the approach.
9+
10+
## Setup
11+
12+
```bash
13+
git clone https://github.com/mspitb/pyarchrules
14+
cd pyarchrules
15+
uv sync --all-extras
16+
```
17+
18+
## Running tests
19+
20+
```bash
21+
make test
22+
```
23+
24+
All tests must pass before a pull request will be reviewed.
25+
26+
## Linting
27+
28+
```bash
29+
make lint # check
30+
make format # auto-fix
31+
```
32+
33+
## Pull request checklist
34+
35+
- [ ] Tests added or updated for the change
36+
- [ ] All tests pass (`make test`)
37+
- [ ] No lint errors (`make lint`)
38+
- [ ] Docstrings updated if public API changed
39+
- [ ] `CHANGELOG.md` updated with a short description under `Unreleased`
40+
41+
## Project structure
42+
43+
```
44+
src/pyarchrules/
45+
cli.py # Typer CLI commands
46+
pyarchrules.py # PyArchRules public class
47+
core/
48+
config.py # pyproject.toml read/write
49+
spec_loader.py # parses TOML into model objects
50+
registries/ # DSLRegistry, LinterRegistry
51+
rules/
52+
dsl/ # Python DSL rule implementations
53+
linter/ # TOML-driven rule implementations
54+
base/ # shared base classes
55+
checks/ # low-level file/import scanners
56+
model/
57+
spec/ # ProjectSpec, ServiceSpec
58+
rules/ # RuleViolation, RuleEvalResult
59+
tests/
60+
cli/ # CLI integration tests
61+
unit/ # unit tests per rule and component
62+
dsl/ # DSL rule unit tests
63+
```
64+
65+
## License
66+
67+
By contributing you agree that your changes will be released under the [MIT License](LICENSE).
68+

Makefile

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,18 @@
22

33
help:
44
@echo "Available commands:"
5-
@echo " make lint - Run code quality checks (black, isort, ruff)"
6-
@echo " make format - Auto-format code with black and isort"
5+
@echo " make lint - Run ruff linter and format check"
6+
@echo " make format - Auto-format code with ruff"
77
@echo " make test - Run all tests"
88
@echo " make clean - Remove build artifacts and cache"
99

1010
lint:
11-
uv run black --check .
12-
uv run isort --check-only .
13-
uv run ruff check .
11+
uv run ruff check src/
12+
uv run ruff format --check src/
1413

1514
format:
16-
uv run black .
17-
uv run isort .
18-
uv run ruff check --fix .
15+
uv run ruff format src/
16+
uv run ruff check --fix src/
1917

2018
test:
2119
uv run pytest tests/
@@ -24,4 +22,3 @@ clean:
2422
rm -rf dist/ build/ *.egg-info src/*.egg-info
2523
find . -type d -name __pycache__ -exec rm -rf {} +
2624
find . -type f -name "*.pyc" -delete
27-

README.md

Lines changed: 47 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4,111 +4,96 @@
44

55
<p align="center">
66
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License: MIT"></a>
7-
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="Python 3.10+"></a>
8-
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/status-alpha%200.0.1a2-orange.svg" alt="Status Alpha"></a>
7+
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.12+-blue.svg" alt="Python 3.12+"></a>
8+
<a href="https://github.com/mspitb/pyarchrules"><img src="https://img.shields.io/badge/status-beta%200.1.0b0-orange.svg" alt="Status: Beta"></a>
99
</p>
1010

11+
**PyArchRules** enforces architecture rules in Python projects:
1112

12-
## Features
13-
14-
- 🏗️ **Structure validation** - enforce directory tree requirements
15-
- 🔗 **Dependency rules** - control module imports (e.g., `api -> domain`)
16-
- 🎯 **DSL & Config** - use Python DSL or TOML configuration
17-
- 🚀 **Zero setup** - works with `pyproject.toml`
18-
- 🔍 **CLI & API** - integrate into CI/CD or use programmatically
13+
- 🏗️ **Folder structure** — require exact directory layouts per service
14+
- 🔗 **Dependency rules** — control which internal packages may import from which
15+
- 🛡️ **Service isolation** — prevent cross-service imports in monorepos
16+
- 🐍 **Python DSL** — write rules in Python inside your test suite
17+
- ⚙️ **Zero extra config** — everything lives in `pyproject.toml`
18+
- 🚀 **CI-ready** — exit code `1` on any violation
1919

2020
## Installation
2121

2222
```bash
2323
pip install pyarchrules
2424
```
2525

26-
## Quick Start
26+
## Quick start
2727

2828
```bash
29-
# Initialize
29+
# 1. Add [tool.pyarchrules] to pyproject.toml
3030
pyarchrules init-project
3131

32-
# Check architecture
32+
# 2. Register a service
33+
pyarchrules add-service backend src/backend
34+
35+
# 3. Run the check
3336
pyarchrules check
3437
```
3538

36-
## Configuration Example
39+
## TOML configuration
3740

3841
```toml
3942
[tool.pyarchrules]
40-
project_name = "myapp"
43+
project_name = "myapp"
44+
description = "Architecture rules for this project"
45+
root = "."
46+
validate_paths = true
47+
isolate_services = true
4148

4249
[tool.pyarchrules.services.backend]
43-
path = "src/backend"
44-
45-
# Enforce directory structure
46-
tree = ["api", "domain", "infra"]
47-
tree_strict = true
48-
49-
# Control dependencies (api can import from domain)
50-
dependencies = ["api -> domain", "domain -> infra"]
50+
path = "src/backend"
51+
tree = ["api", "domain", "infra"]
52+
tree_strict = true
53+
dependencies = ["api -> domain", "domain -> infra", "* -> utils"]
5154
```
5255

53-
## Python API
56+
## Python DSL
5457

5558
```python
59+
# tests/test_architecture.py
5660
from pyarchrules import PyArchRules
5761

58-
rules = PyArchRules()
59-
60-
# DSL validation
61-
rules.for_service("backend") \
62-
.must_contain_folders(["api", "domain"])
63-
64-
result = rules.validate()
62+
def test_architecture():
63+
rules = PyArchRules()
64+
rules.for_service("backend") \
65+
.must_contain_folders(["api", "domain", "infra"], allow_extra=False) \
66+
.no_wildcard_imports() \
67+
.no_circular_imports()
68+
rules.validate()
6569
```
6670

67-
## CLI Commands
71+
## CLI commands
6872

6973
| Command | Description |
7074
|---------|-------------|
71-
| `pyarchrules init-project` | Initialize configuration |
72-
| `pyarchrules check` | Validate architecture |
73-
| `pyarchrules add-service NAME PATH` | Add service |
74-
| `pyarchrules list-services` | List all services |
75+
| `init-project` | Initialise `[tool.pyarchrules]` in `pyproject.toml` |
76+
| `add-service NAME PATH` | Register a service |
77+
| `remove-service NAME` | Remove a service |
78+
| `list-services` | Show all configured services |
79+
| `check` | Validate architecture |
7580

76-
## Use Cases
77-
78-
**Monorepos** - enforce boundaries between services
79-
```toml
80-
[tool.pyarchrules.services.auth]
81-
path = "services/auth"
82-
dependencies = ["auth -> shared"]
83-
```
81+
## Documentation
8482

85-
**Clean Architecture** - validate layer dependencies
86-
```toml
87-
dependencies = [
88-
"api -> application",
89-
"application -> domain"
90-
]
91-
```
83+
Full documentation: <https://mspitb.github.io/pyarchrules>
9284

93-
**Microservices** - ensure consistent structure
94-
```toml
95-
tree = ["api", "domain", "infrastructure"]
96-
tree_strict = true
97-
```
85+
## Contributing
9886

99-
## Development
87+
Contributions are welcome. Please open an issue before submitting a pull request for non-trivial changes.
10088

10189
```bash
102-
uv pip install -e ".[dev]"
90+
git clone https://github.com/mspitb/pyarchrules
91+
cd pyarchrules
92+
uv sync --all-extras
10393
make test
10494
make lint
10595
```
10696

107-
## Status
108-
109-
⚠️ **Alpha** - API may change before 1.0 release
110-
11197
## License
11298

11399
MIT
114-

0 commit comments

Comments
 (0)