Deterministic architecture fact extraction and mapping for Python backends
Project description
archdoc — deterministic architecture documentation for Python
archdoc scans Python source code, extracts syntax-level facts through the
standard-library AST, maps configurable architecture concepts, and writes
stable JSON artifacts for documentation and review tooling.
The project is developed publicly at kevin-kraft/archdoc. The repository also contains the architecture visualization and review application.
Design goals
- deterministic output for an unchanged source tree and configuration
- static analysis without importing or executing the analyzed application
- explicit, project-specific mapping rules instead of hidden inference
- stable source references and identifiers for downstream tooling
- replaceable generated data kept separate from manual review state
archdoc is rule-based. It documents evidence found in source code; it does
not claim to prove runtime behavior or business meaning.
Installation
archdoc requires Python 3.11 or newer.
python -m pip install archdoc
For development directly from the repository:
python -m pip install -e .
Quick start
Create a starter configuration in the project that should be analyzed:
archdoc init
This creates archdoc.yml in the current directory. Existing files are not
overwritten unless --force is supplied:
archdoc init --output config/archdoc.yml
archdoc init --force
Adjust project.name and project.source_root, then run:
archdoc scan -c archdoc.yml
archdoc map -c archdoc.yml
The documented starter configuration is available as
archdoc.example.yml. The same template is included in
the installed Python package, so archdoc init also works after installation
from a wheel.
Configuration
All paths are resolved relative to the configuration file and
project.root. The main sections are:
project: project name, project root, and Python source rootscan: included and excluded file patternsoutput: destinations for raw facts, catalogs, and schemasmapping: rules for services, endpoints, actions, entities, and workersnaming: templates for stable architecture identifiers
Minimal example:
project:
name: example-backend
root: .
source_root: app
scan:
include:
- "**/*.py"
exclude:
- "**/.venv/**"
- "**/migrations/**"
- "**/tests/**"
output:
raw_facts: .archdoc/raw_code_facts.json
catalog_dir: .archdoc/catalog
schema_dir: .archdoc/schemas
Mapping behavior is configurable because naming conventions and project layouts differ between Python backends. The generated template documents the available service, endpoint, entity, worker, and operation-link sections.
Pipeline
Scan
archdoc scan:
- loads and validates the YAML configuration;
- discovers matching Python files in a stable order;
- parses each file with
ast.parse(); - extracts imports, classes, functions, methods, decorators, calls, assignments, and architecture signals;
- writes the raw facts JSON artifact.
Map
archdoc map:
- loads the raw facts;
- maps configured services and their operations;
- maps route-decorated endpoint functions;
- links endpoints to detected service operations;
- maps architecture actions and operation dependencies;
- validates the resulting catalog;
- writes JSON artifacts for downstream consumers.
Export schemas
archdoc export-schemas -c archdoc.yml
This exports JSON Schemas for consumers that need an explicit contract for the generated artifacts.
Detection model
Services are detected through configurable source paths, class suffixes, and method rules. Endpoints are detected through route decorators and configured router paths. Links are inferred from parameters, assignments, object construction, and call shapes.
These rules deliberately favor traceability and reproducibility over opaque semantic guesses. Dynamic dispatch, runtime registration, metaprogramming, and unconventional project layouts may require adjusted configuration or manual review.
Source layout
Important implementation entry points:
- CLI
- configuration models
- configuration loader
- Python scanner
- service mapper
- endpoint mapper
- endpoint-service linker
- catalog validator
- tests
License
Copyright © Kevin Kraft. Licensed under the Apache License 2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file archdoc-0.1.1.tar.gz.
File metadata
- Download URL: archdoc-0.1.1.tar.gz
- Upload date:
- Size: 57.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff6c1284dc4a49d57042a68490ce56e820e94b5ecadc013da026355940b094e8
|
|
| MD5 |
afc669a35d7d5ac7278963eb12bc1c8f
|
|
| BLAKE2b-256 |
4a1e56e501c60d743c36f2f965fa358034421c09720e9d29f964fe5523125db6
|
File details
Details for the file archdoc-0.1.1-py3-none-any.whl.
File metadata
- Download URL: archdoc-0.1.1-py3-none-any.whl
- Upload date:
- Size: 63.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
180d6bdaa5993e638dfc81a060fd4e453916fbe2bf94038b5339f5755e28b396
|
|
| MD5 |
fc4c332d94106c3c46db854e943ed4ef
|
|
| BLAKE2b-256 |
ffe695bd01d5b5026afea1ddf5946ec8564105055940d39cc1792d6df6e8b8ec
|