Skip to main content

Package for automatic architecture schemas renderers. Includes FastAPI and Litestar integrations

Project description

archdocs

PyPI Python versions CI Pipeline Coverage Lines of code Ruff wemake-python-styleguide

archdocs logo

archdocs is OpenAPI and SwaggerUI, but for architecture. It reads the source code of your fastapi or litestar service and serves a diagram of it: who calls the service, what the service calls itself, where it keeps data and how it is deployed.

  • the code is the schema, so there is no second copy to keep in sync
  • nothing to annotate: no decorators, no magic comments, no meta files. You bind the library to your app once and archdocs finds the rest on its own

Quickstart

Install the package:

uv add archdocs

Bind it to your app.

FastAPI:

import typing

import fastapi

from archdocs.integrations.fastapi import add_architecture_doc_routes
from archdocs.main import SettingsForArchdocs


example_app: typing.Final = fastapi.FastAPI()

add_architecture_doc_routes(
    example_app,
    arch_settings=SettingsForArchdocs(root_dir="src/", service_name="my-service"),
)

Litestar:

import typing

import litestar

from archdocs.integrations.litestar import add_architecture_doc_routes
from archdocs.main import SettingsForArchdocs


example_app: typing.Final = litestar.Litestar()

add_architecture_doc_routes(
    example_app,
    arch_settings=SettingsForArchdocs(root_dir="src/", service_name="my-service"),
)

root_dir is where your sources live, service_name is the label of your service on the diagram. Both integrations take the same arguments and serve the page at route_path, which is /docs/architecture/ until you set another one.

Start the app, open /docs/architecture/ and the schema is already there.

What archdocs finds

  • HTTP endpoints: fastapi and litestar routes
  • Application servers: granian, uvicorn, gunicorn with its worker class, hypercorn, daphne, waitress and the rest of the ASGI/WSGI family, with worker count, port, TLS and HTTP/2
  • HTTP clients: httpx, aiohttp, requests, niquests
  • Databases: SQLAlchemy engines, sync and async, with pool settings and the driver behind the DSN
  • Caches: Redis, plain, Sentinel and Cluster
  • Message brokers: FastStream over RabbitMQ, Kafka, NATS and Redis
  • Task queues: Celery, Taskiq, Arq, RQ, Dramatiq, Huey
  • Kubernetes: ingress hosts and TLS, service type and port, workload kind, replicas, the HPA range and its CPU target, cpu, RAM and GPU requests and limits, ConfigMaps and Secrets as environment or as volumes, volume claims and their size

Kubernetes

Manifests are read straight from your repository. A Helm chart and a plain directory of manifests both work, no helm template run and no extra dependency: templated {{ ... }} values are skipped in favour of what values.yaml says. archdocs looks under root_dir and, if nothing is there, a couple of directories above it, never outside the repository your sources live in. If your layout differs, point it at the right place with kubernetes_dir. A relative path is taken from root_dir, not from the working directory of the process:

add_architecture_doc_routes(
    example_app,
    arch_settings=SettingsForArchdocs(
        root_dir="src/",
        service_name="my-service",
        kubernetes_dir="deploy/my-chart/",
    ),
)

How it looks

Your service sits in the middle of the page, every dependency around it, boxed by the role it plays: inbound API, outbound calls, messaging and tasks, data stores, configuration. The diagram is Mermaid and your own application serves it.

architecture page served by archdocs

That page is tests/showcase, an example service that uses everything from the list above at once. The playground serves it next to the fastapi and litestar examples, so you can click through the same pages yourself:

just playground

It starts on 127.0.0.1:8000 and lists every example it serves.

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

archdocs-1.0.0.tar.gz (34.5 kB view details)

Uploaded Source

Built Distribution

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

archdocs-1.0.0-py3-none-any.whl (35.9 kB view details)

Uploaded Python 3

File details

Details for the file archdocs-1.0.0.tar.gz.

File metadata

  • Download URL: archdocs-1.0.0.tar.gz
  • Upload date:
  • Size: 34.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for archdocs-1.0.0.tar.gz
Algorithm Hash digest
SHA256 733c1d3a7861643856cb9ae911f5696035e75b3ac07af861eea9e9643db5ff71
MD5 e04a61a5c8a1b360dde002a17fe50ed4
BLAKE2b-256 d28ba1e87e23fdfdb11c627a158ff10b7231799d81e0b436a036c1bb6133046c

See more details on using hashes here.

File details

Details for the file archdocs-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: archdocs-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 35.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for archdocs-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 afc40c6f7e0c0e5416bbb560acfebfbb441c07d9825925d818159b62241e3abf
MD5 9def18ed558dae2b47422bec2ae4d619
BLAKE2b-256 f3951c068391040ebcc2cb625833afdb01bee13b11524b9d85da4513323eb245

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