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

Uploaded Python 3

File details

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

File metadata

  • Download URL: archdocs-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 786d0d10e360ef5ca8a6a45bc040e87ba40da134283ed764fb0a483de69012b1
MD5 badfee0459e82529ebc3f0021ab184fb
BLAKE2b-256 d8ede8695feb1855ea6a32d5c553ec97d7ced91611e771bb1a86528fbdd83f9c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: archdocs-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 441fa6ebf1c46423f307ab32bf7ca63784eb41498baa22376e92dfae9a677e5d
MD5 9d1ef2cb47a60e61d65797d3de72565b
BLAKE2b-256 b3eea976b3a9a88d87ad703b8c2819fcbe98637769947b405f2ce532a3ac5e7f

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