python-project-structure

Generate four-layer Clean Architecture skeletons for Python FastAPI services.

1|Updated Jun 20, 2026
One-click install
npx skills add https://github.com/shafibabar/SDLC-Artifact-Factory --skill python-project-structure-shafibabar
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-project-structure
Source: https://github.com/shafibabar/SDLC-Artifact-Factory/tree/main/skills/python-project-structure
Command: npx skills add https://github.com/shafibabar/SDLC-Artifact-Factory --skill python-project-structure-shafibabar

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires import-linter, mypy, ruff, and includes references (resource) components.

What problem does it solve?

This Skill solves the inconsistency and architectural drift common in Python backend services by enforcing a strict, layered project layout that ensures maintainability and testability.

Core Features & Use Cases

  • Layered Architecture Enforcement: Implements the Dependency Rule using import-linter to ensure domain logic remains isolated from infrastructure concerns.
  • Standardized Skeleton Generation: Provides a consistent src/ package layout, composition root, and port-adapter structure for all FastAPI services.
  • Use Case: When starting a new microservice, use this Skill to generate a structure that guarantees your domain logic is decoupled from FastAPI, SQL, and Kafka, making it fully testable in isolation.

Quick Start

Use the python-project-structure skill to generate a new four-layer service skeleton in the current directory.

Frequently Asked Questions about python-project-structure

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce Clean Architecture in a FastAPI project?

To enforce Clean Architecture in a FastAPI project, use import-linter to define and validate inward-only dependency rules, ensuring domain logic remains isolated from infrastructure concerns like SQL and Kafka.

What is the best way to structure a FastAPI service for testability?

The best way to structure a testable FastAPI service is implementing a four-layer project layout with a composition root and port-adapter structure, decoupling domain models from infrastructure for isolated testing.

How do I prevent architectural drift in Python backend services?

Prevent architectural drift in Python backend services by standardizing the project layout with a strict src/ package structure and applying CI-gated architectural enforcement using import-linter fitness functions.

Can I use typing.Protocol for dependency inversion in FastAPI?

Yes, you can use typing.Protocol for dependency inversion in FastAPI to define structural typing boundaries, ensuring use cases depend on abstract ports rather than concrete infrastructure adapters.

Does import-linter support enforcing architectural boundaries in Python?

Yes, import-linter supports enforcing architectural boundaries in Python by validating that dependencies flow inward across layers, preventing infrastructure and framework code from polluting isolated domain logic.

How do I decouple domain logic from FastAPI and SQL?

Decouple domain logic from FastAPI and SQL by wiring dependencies through a composition root, isolating domain models in an inner layer that only interacts with external systems via defined ports.