python-hexagonal-architecture-template
llms.txt0 starsChanged 5 months agoMITView on GitHub
Production-grade hexagonal-architecture (ports & adapters) FastAPI template where the layer boundaries are enforced in CI by import-linter, not merely drawn in a diagram, and built so AI coding agents can one-shot features and self-verify against one deterministic command. Python 3.13, FastAPI, uv, async SQLAlchemy 2.0 + asyncpg, Alembic, Postgres, pydantic v2, loguru, OpenTelemetry. The Task resource is the canonical vertical slice to copy. The definition of done is uv run poe check (ruff → ty → import-linter → deptry →…
In this repository7 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/architecture.mdcCursor rule
- add-featureSkill
- add-migrationSkill
- check-fixSkill
The file
Files
# FastAPI Hexagonal Template > Production-grade hexagonal-architecture (ports & adapters) FastAPI template where the layer > boundaries are enforced in CI by import-linter, not merely drawn in a diagram, and built so > AI coding agents can one-shot features and self-verify against one deterministic command. Python 3.13, FastAPI, uv, async SQLAlchemy 2.0 + asyncpg, Alembic, Postgres, pydantic v2, loguru, OpenTelemetry. The `Task` resource is the canonical vertical slice to copy. The definition of done is `uv run poe check` (ruff → ty → import-linter → deptry → pip-audit → pytest with coverage and schemathesis), which is deterministic: pinned versions, seeded test order, derandomized fuzzing. Key differentiator: unlike full-stack-fastapi-template (not hexagonal, ORM-coupled), fastapi-best-practices (a guide), and fastapi-clean-example (clean but folder-convention only, unenforced), this template enforces the inward-only dependency rule as a build gate. ## Docs - [Home](index.md): overview and quickstart. - [Architecture](architecture.md): the three layers, the inward-only rule, and CI enforcement. - [Adding a feature](adding-a-feature.md): domain-outward runbook mirroring the Task slice. - [Toolchain](toolchain.md): plain-language map of every tool in the stack and when it runs. - [Validation loop](validation-loop.md): the one command, each tool, and determinism. - [Agent-native](agent-native.md): AGENTS.md, .claude assets, the determinism contract. - [Comparison](comparison.md): versus the popular FastAPI templates, with when-not-to-use. - [FAQ](faq.md): common questions about ports/adapters, uv, Docker, auth, agents. ## Decision records - [ADR-0001](adr/0001-enforce-hexagonal-boundaries-with-import-linter.md): enforce boundaries with import-linter. - [ADR-0002](adr/0002-validation-loop-tool-selection.md): validation-loop tool selection and exclusions. - [ADR-0003](adr/0003-unit-of-work-commit-authority.md): the UnitOfWork is the sole commit authority. - [ADR-0004](adr/0004-utc-timestamps-owned-by-the-domain.md): entities own their UTC timestamps. ## Source - [Repository](https://github.com/MatthiasEg/python-hexagonal-architecture-template)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

