python-architecture

Solid

Python application architecture with functional core, effectful shell, DDD, and data modeling. Use when designing application layers, separating pure business logic from IO, defining domain models, implementing validation, or structuring bounded contexts.

AI & Automation 38 stars 3 forks Updated 5 days ago MIT

Install

View on GitHub

Quality Score: 87/100

Stars 20%
53
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Python Application Architecture Modern Python application architecture following functional core / imperative shell pattern, Domain-Driven Design, and type-safe data modeling. ## Core Principle: Functional Core / Imperative Shell Separate pure business logic from side effects: - **Functional Core**: Pure functions, business logic, no IO - **Imperative Shell**: Coordinates external dependencies, handles side effects See [references/functional-core.md](references/functional-core.md) for detailed patterns and examples. ## Layered Architecture Follow bottom-up dependency flow: ``` Router/Handler → Service → Repository → Entity → Database ``` Each layer depends only on layers below. **Responsibilities:** - **Entity**: Domain models, validation, business rules, data transformations (fromRequest, toRecord, toResponse) - **Repository**: Abstract storage interface, returns domain entities - **Service**: Business workflows, orchestrates entities and repositories - **Router/Handler**: HTTP handling, delegates to services ## Domain Models ### Entity Example ```python from dataclasses import dataclass from uuid import UUID from decimal import Decimal @dataclass class Order: """Entity - has identity and encapsulated behavior""" id: UUID customer_id: UUID total: Decimal status: str def apply_discount(self, rate: Decimal) -> None: """Business rule - encapsulated in entity""" if self.status == "pending": self.total = self.to...

Details

Author
martinffx
Repository
martinffx/atelier
Created
6 months ago
Last Updated
5 days ago
Language
TypeScript
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category