refactor: migrate to DDD architecture with Dishka DI
Complete architectural refactoring from simple MVC to Clean Architecture/DDD pattern: Domain Layer: - Add entities (Post, BaseEntity) with business logic - Add value objects (Title, Content, Slug) with validation - Add repository interfaces (PostRepository) - Add domain exceptions Application Layer: - Add use cases (CreatePost, GetPost, UpdatePost, DeletePost, ListPosts, PublishPost) - Add DTOs for data transfer - Add TransactionManager interface Infrastructure Layer: - Add SQLAlchemy models and async database connection - Add SQLAlchemyPostRepository implementation - Add Dishka DI container with providers - Add error handlers and middleware Presentation Layer: - Add FastAPI routes with Dishka integration - Add Pydantic schemas - Add dependency injection using FromDishka[T] Other Changes: - Remove old flat structure (api/, common/, core/, modules/) - Add hatchling build system for package scripts - Add blog CLI command - Update AGENTS.md with new architecture docs - All 48 tests passing, mypy clean, ruff clean
This commit is contained in:
@@ -4,11 +4,21 @@ version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.13"
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["app"]
|
||||
dependencies = [
|
||||
"fastapi>=0.136.0",
|
||||
"pydantic>=2.13.2",
|
||||
"pydantic-settings>=2.14.0",
|
||||
"uvicorn>=0.44.0",
|
||||
"sqlalchemy>=2.0.0",
|
||||
"aiosqlite>=0.21.0",
|
||||
"dishka>=1.5.0",
|
||||
]
|
||||
|
||||
[dependency-groups]
|
||||
@@ -35,10 +45,13 @@ types = [
|
||||
"mypy>=1.20.1",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
blog = "app.main:main"
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
asyncio_mode = "auto"
|
||||
asyncio_default_fixture_loop_scope = "function"
|
||||
addopts = "--cov=src --cov-report=term"
|
||||
addopts = "--cov=app --cov-report=term-missing --cov-report=html"
|
||||
pythonpath = "."
|
||||
testpaths = "tests"
|
||||
xfail_strict = true
|
||||
|
||||
Reference in New Issue
Block a user