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.1.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.1-py3-none-any.whl (35.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: archdocs-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 64bb7dc271c89373fe42a6f0766a6b0b60ecb951410659db65696569034f087d
MD5 76deff0f63e36d9f1a8f0f83e34cc7d3
BLAKE2b-256 4b5110cf606363fe2ed7238d5c84a5f5b7eb9f3d2e4c61728ff5236e4125c676

See more details on using hashes here.

File details

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

File metadata

  • Download URL: archdocs-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 312a49ee5e82ea57336ad5706d54da91ad4af240f64dab0befedef555d59071c
MD5 e9343ecf3b2bf36872974f5d842cdf76
BLAKE2b-256 93d74cfa079bd82c2f540826d214c218bf283a4174f281cf77cdd939fc70fa3d

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