Skip to main content

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 root
  • scan: included and excluded file patterns
  • output: destinations for raw facts, catalogs, and schemas
  • mapping: rules for services, endpoints, actions, entities, and workers
  • naming: 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:

  1. loads and validates the YAML configuration;
  2. discovers matching Python files in a stable order;
  3. parses each file with ast.parse();
  4. extracts imports, classes, functions, methods, decorators, calls, assignments, and architecture signals;
  5. writes the raw facts JSON artifact.

Map

archdoc map:

  1. loads the raw facts;
  2. maps configured services and their operations;
  3. maps route-decorated endpoint functions;
  4. links endpoints to detected service operations;
  5. maps architecture actions and operation dependencies;
  6. validates the resulting catalog;
  7. 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:

License

Copyright © Kevin Kraft. Licensed under the Apache License 2.0.

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

archdoc-0.1.1.tar.gz (57.8 kB view details)

Uploaded Source

Built Distribution

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

archdoc-0.1.1-py3-none-any.whl (63.7 kB view details)

Uploaded Python 3

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

Hashes for archdoc-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ff6c1284dc4a49d57042a68490ce56e820e94b5ecadc013da026355940b094e8
MD5 afc669a35d7d5ac7278963eb12bc1c8f
BLAKE2b-256 4a1e56e501c60d743c36f2f965fa358034421c09720e9d29f964fe5523125db6

See more details on using hashes here.

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

Hashes for archdoc-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 180d6bdaa5993e638dfc81a060fd4e453916fbe2bf94038b5339f5755e28b396
MD5 fc4c332d94106c3c46db854e943ed4ef
BLAKE2b-256 ffe695bd01d5b5026afea1ddf5946ec8564105055940d39cc1792d6df6e8b8ec

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