Archist is a lightweight bash utility designed to scaffold Clean Architecture directory structures for Python projects in seconds. It organizes your code into layers, making it decoupled, testable, and easy to maintain.
The project is organized into layers following the Archist philosophy:
src/
├── Application/ # Application services and use cases
│ ├── DTO/ # Data Transfer Objects
│ ├── Service/ # Domain-independent services
│ └── UseCase/ # Orchestration of domain logic
├── Domain/ # Enterprise/Business logic (Pure Python)
│ ├── Entity/ # Domain models
│ ├── Exception/ # Domain-specific errors
│ ├── Repository/ # Port definitions (Interfaces)
│ └── ValueObject/ # Immutable data structures
├── Infrastructure/ # External tools and technical details
│ ├── Delivery/ # Entry points (Http/FastAPI, Console)
│ ├── ExternalApi/ # Third-party integrations
│ └── Persistence/ # Database implementations (Adapters)
└── Shared/ # Logic shared across all layers
- Framework Agnostic: The core logic does not depend on external frameworks.
- Dependency Inversion: High-level modules (Domain) do not depend on low-level modules (Infrastructure).
- Environment Configuration: Ready for
.envmanagement usingpython-dotenv. - Modern Python Tooling: Uses
pyproject.tomlfor dependency management andpytestfor testing. - Type Hinting: Encourages the use of Python type hints for better IDE support and error catching.
- Python 3.8 or higher.
- Pip (Python package installer).
You can download the initialization script directly from the repository using curl:
Using curl:
curl -O https://raw.githubusercontent.com/AFelipeTrujillo/py-archist/refs/heads/master/py_archist.shBefore running the script, you must grant it execution permissions:
chmod +x py_archist.shExecute the script in the directory where you want to start your new project:
./py_archist.shpip install .
The entry point of the application is main.py:
python main.py
The project is configured to work with pytest:
pytest
The "heart" of the software. It contains the business rules. It should have no dependencies on any external library or framework.
Orchestrates the flow of data to and from the domain entities. It contains the Use Cases of the system.
This layer contains the implementation of the ports defined in the Domain. It is where the database code, API clients, and the web framework (like FastAPI or Flask) live.
Inspired by the php-archist project.