@pixelcraft-tw/spec 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +195 -0
  3. package/dist/bin/pxs.d.ts +2 -0
  4. package/dist/bin/pxs.js +5 -0
  5. package/dist/bin/pxs.js.map +1 -0
  6. package/dist/src/backends/claude.d.ts +9 -0
  7. package/dist/src/backends/claude.js +80 -0
  8. package/dist/src/backends/claude.js.map +1 -0
  9. package/dist/src/backends/codex.d.ts +9 -0
  10. package/dist/src/backends/codex.js +72 -0
  11. package/dist/src/backends/codex.js.map +1 -0
  12. package/dist/src/backends/factory.d.ts +2 -0
  13. package/dist/src/backends/factory.js +14 -0
  14. package/dist/src/backends/factory.js.map +1 -0
  15. package/dist/src/backends/interface.d.ts +15 -0
  16. package/dist/src/backends/interface.js +2 -0
  17. package/dist/src/backends/interface.js.map +1 -0
  18. package/dist/src/cli.d.ts +2 -0
  19. package/dist/src/cli.js +94 -0
  20. package/dist/src/cli.js.map +1 -0
  21. package/dist/src/commands/clarify.d.ts +5 -0
  22. package/dist/src/commands/clarify.js +46 -0
  23. package/dist/src/commands/clarify.js.map +1 -0
  24. package/dist/src/commands/diff.d.ts +1 -0
  25. package/dist/src/commands/diff.js +81 -0
  26. package/dist/src/commands/diff.js.map +1 -0
  27. package/dist/src/commands/implement.d.ts +9 -0
  28. package/dist/src/commands/implement.js +247 -0
  29. package/dist/src/commands/implement.js.map +1 -0
  30. package/dist/src/commands/init.d.ts +6 -0
  31. package/dist/src/commands/init.js +183 -0
  32. package/dist/src/commands/init.js.map +1 -0
  33. package/dist/src/commands/new.d.ts +5 -0
  34. package/dist/src/commands/new.js +186 -0
  35. package/dist/src/commands/new.js.map +1 -0
  36. package/dist/src/commands/refine.d.ts +8 -0
  37. package/dist/src/commands/refine.js +158 -0
  38. package/dist/src/commands/refine.js.map +1 -0
  39. package/dist/src/commands/reset.d.ts +3 -0
  40. package/dist/src/commands/reset.js +44 -0
  41. package/dist/src/commands/reset.js.map +1 -0
  42. package/dist/src/commands/review.d.ts +4 -0
  43. package/dist/src/commands/review.js +70 -0
  44. package/dist/src/commands/review.js.map +1 -0
  45. package/dist/src/commands/status.d.ts +1 -0
  46. package/dist/src/commands/status.js +53 -0
  47. package/dist/src/commands/status.js.map +1 -0
  48. package/dist/src/discovery/project.d.ts +7 -0
  49. package/dist/src/discovery/project.js +135 -0
  50. package/dist/src/discovery/project.js.map +1 -0
  51. package/dist/src/git/operations.d.ts +10 -0
  52. package/dist/src/git/operations.js +56 -0
  53. package/dist/src/git/operations.js.map +1 -0
  54. package/dist/src/parsers/arguments.d.ts +18 -0
  55. package/dist/src/parsers/arguments.js +43 -0
  56. package/dist/src/parsers/arguments.js.map +1 -0
  57. package/dist/src/parsers/plan.d.ts +23 -0
  58. package/dist/src/parsers/plan.js +117 -0
  59. package/dist/src/parsers/plan.js.map +1 -0
  60. package/dist/src/parsers/spec.d.ts +10 -0
  61. package/dist/src/parsers/spec.js +46 -0
  62. package/dist/src/parsers/spec.js.map +1 -0
  63. package/dist/src/state/manager.d.ts +24 -0
  64. package/dist/src/state/manager.js +103 -0
  65. package/dist/src/state/manager.js.map +1 -0
  66. package/dist/src/state/types.d.ts +48 -0
  67. package/dist/src/state/types.js +20 -0
  68. package/dist/src/state/types.js.map +1 -0
  69. package/dist/src/utils/display.d.ts +7 -0
  70. package/dist/src/utils/display.js +42 -0
  71. package/dist/src/utils/display.js.map +1 -0
  72. package/dist/src/utils/prompt.d.ts +15 -0
  73. package/dist/src/utils/prompt.js +139 -0
  74. package/dist/src/utils/prompt.js.map +1 -0
  75. package/package.json +52 -0
  76. package/templates/agents-md-snippet.md +20 -0
  77. package/templates/architectures/clean/csharp-aspnet.md +56 -0
  78. package/templates/architectures/clean/dart-flutter.md +73 -0
  79. package/templates/architectures/clean/go-gin.md +50 -0
  80. package/templates/architectures/clean/go-std.md +49 -0
  81. package/templates/architectures/clean/kotlin-android.md +70 -0
  82. package/templates/architectures/clean/python-fastapi.md +49 -0
  83. package/templates/architectures/clean/swift-ios.md +69 -0
  84. package/templates/architectures/clean/typescript-express.md +60 -0
  85. package/templates/architectures/clean/typescript-nestjs.md +61 -0
  86. package/templates/architectures/ddd/csharp-aspnet.md +55 -0
  87. package/templates/architectures/ddd/go-gin.md +53 -0
  88. package/templates/architectures/ddd/python-fastapi.md +52 -0
  89. package/templates/architectures/ddd/typescript-nestjs.md +62 -0
  90. package/templates/architectures/hexagonal/csharp-aspnet.md +45 -0
  91. package/templates/architectures/hexagonal/go-gin.md +47 -0
  92. package/templates/architectures/hexagonal/python-fastapi.md +43 -0
  93. package/templates/architectures/hexagonal/typescript-nestjs.md +44 -0
  94. package/templates/architectures/layered/csharp-aspnet.md +45 -0
  95. package/templates/architectures/layered/go-gin.md +41 -0
  96. package/templates/architectures/layered/python-fastapi.md +42 -0
  97. package/templates/architectures/layered/typescript-nestjs.md +48 -0
  98. package/templates/architectures/modular/csharp-aspnet.md +45 -0
  99. package/templates/architectures/modular/dart-flutter.md +64 -0
  100. package/templates/architectures/modular/go-gin.md +47 -0
  101. package/templates/architectures/modular/kotlin-android.md +68 -0
  102. package/templates/architectures/modular/python-fastapi.md +45 -0
  103. package/templates/architectures/modular/swift-ios.md +55 -0
  104. package/templates/architectures/modular/typescript-nestjs.md +48 -0
  105. package/templates/architectures/mvvm/dart-flutter.md +69 -0
  106. package/templates/architectures/mvvm/kotlin-android.md +79 -0
  107. package/templates/architectures/mvvm/swift-ios.md +66 -0
  108. package/templates/claude-commands/sf.clarify.md +18 -0
  109. package/templates/claude-commands/sf.implement.md +80 -0
  110. package/templates/claude-commands/sf.new.md +22 -0
  111. package/templates/claude-commands/sf.refine.md +47 -0
  112. package/templates/claude-commands/sf.review.md +17 -0
  113. package/templates/claude-commands/sf.status.md +12 -0
  114. package/templates/workflow/config.yaml +17 -0
  115. package/templates/workflow/prompts/clarify.md +39 -0
  116. package/templates/workflow/prompts/final-review.md +30 -0
  117. package/templates/workflow/prompts/implement-tdd.md +35 -0
  118. package/templates/workflow/prompts/implement.md +43 -0
  119. package/templates/workflow/prompts/refine.md +52 -0
  120. package/templates/workflow/prompts/review.md +33 -0
  121. package/templates/workflow/prompts/test.md +14 -0
  122. package/templates/workflow/templates/spec-template.md +13 -0
@@ -0,0 +1,49 @@
1
+ # Architecture: Clean Architecture (Python + FastAPI)
2
+
3
+ ## Directory Structure
4
+ ```
5
+ src/
6
+ ├── domain/
7
+ │ ├── entities/order.py
8
+ │ ├── value_objects/money.py
9
+ │ ├── errors.py
10
+ │ └── ports/order_repository.py # Abstract base classes
11
+ ├── application/
12
+ │ ├── use_cases/create_order.py
13
+ │ └── dtos/order_dto.py
14
+ ├── infrastructure/
15
+ │ ├── repositories/order_repository.py
16
+ │ ├── database/
17
+ │ │ ├── connection.py
18
+ │ │ └── models/order_model.py # SQLAlchemy models
19
+ │ └── config.py
20
+ ├── interface/
21
+ │ ├── routers/order_router.py
22
+ │ ├── dependencies.py # FastAPI dependency injection
23
+ │ └── middleware/
24
+ │ └── error_handler.py
25
+ └── main.py # FastAPI app setup
26
+ ```
27
+
28
+ ## Dependency Rule
29
+ - domain → depends on nothing outside, pure Python classes and ABCs
30
+ - application → depends only on domain; use cases call externals via ports (ABCs)
31
+ - infrastructure → implements domain ports
32
+ - interface → depends on application; FastAPI routers + dependencies
33
+
34
+ ## Conventions
35
+ - Ports defined as Abstract Base Classes (ABC) in domain/ports/
36
+ - FastAPI dependency injection for wiring infrastructure to use cases
37
+ - Pydantic models for DTOs and request/response validation
38
+ - SQLAlchemy 2.0 style for ORM (if used)
39
+
40
+ ## File Naming
41
+ - snake_case: create_order.py
42
+ - Test files: test_create_order.py
43
+ - One class per file or closely related classes grouped
44
+
45
+ ## Testing
46
+ - domain: pure unit tests (pytest)
47
+ - application: mock ports (pytest-mock)
48
+ - infrastructure: integration tests (testcontainers)
49
+ - interface: HTTP tests (httpx + TestClient)
@@ -0,0 +1,69 @@
1
+ # Architecture: Clean Architecture (iOS / SwiftUI)
2
+
3
+ ## Layer-Based Structure
4
+ iOS app organized into Domain, Application, Infrastructure, and Presentation groups following Clean Architecture principles.
5
+
6
+ ## Directory Structure
7
+ ```
8
+ Sources/
9
+ ├── Domain/
10
+ │ ├── Entities/Order.swift
11
+ │ ├── ValueObjects/Money.swift
12
+ │ └── Errors/DomainError.swift
13
+ ├── Application/
14
+ │ ├── UseCases/CreateOrderUseCase.swift
15
+ │ ├── Ports/
16
+ │ │ ├── OrderRepositoryPort.swift
17
+ │ │ └── PaymentGatewayPort.swift
18
+ │ └── DTOs/CreateOrderDTO.swift
19
+ ├── Infrastructure/
20
+ │ ├── Repositories/OrderRepository.swift
21
+ │ ├── Services/PaymentGateway.swift
22
+ │ ├── Networking/APIClient.swift
23
+ │ └── Persistence/
24
+ │ └── SwiftDataModels.swift
25
+ ├── Presentation/
26
+ │ ├── Views/OrderView.swift
27
+ │ ├── ViewModels/OrderViewModel.swift
28
+ │ ├── Navigation/AppRouter.swift
29
+ │ └── Components/OrderCard.swift
30
+ └── App.swift
31
+ Tests/
32
+ ├── DomainTests/
33
+ ├── ApplicationTests/
34
+ ├── InfrastructureTests/
35
+ └── PresentationTests/
36
+ ```
37
+
38
+ ## Dependency Rule
39
+ - Domain → depends on nothing outside, pure Swift types
40
+ - Application → depends only on Domain; use cases call externals via protocol ports
41
+ - Infrastructure → implements Application ports (protocols)
42
+ - Presentation → depends on Application; SwiftUI views + @Observable ViewModels
43
+
44
+ ## Recommended Dependencies
45
+ - State Management: @Observable (Observation framework, built-in)
46
+ - Networking: URLSession (built-in)
47
+ - Navigation: NavigationStack (SwiftUI native)
48
+ - Local Storage: SwiftData
49
+ - DI: Factory pattern or manual injection
50
+
51
+ ## Conventions
52
+ - Use Cases are structs/classes with a `execute()` method
53
+ - ViewModels use @Observable macro, observed by SwiftUI views
54
+ - Protocols define port boundaries between layers
55
+ - Errors modeled as enums conforming to Error protocol
56
+
57
+ ## File Naming
58
+ - PascalCase: CreateOrderUseCase.swift
59
+ - Entity: *.swift under Entities/
60
+ - Port: *Port.swift (protocol)
61
+ - Repository: *Repository.swift
62
+ - ViewModel: *ViewModel.swift
63
+ - View: *View.swift
64
+
65
+ ## Testing
66
+ - Domain: pure unit tests, XCTest
67
+ - Application: mock ports with protocol conformance
68
+ - Infrastructure: integration tests
69
+ - Presentation: ViewInspector or snapshot tests
@@ -0,0 +1,60 @@
1
+ # Architecture: Clean Architecture (TypeScript + Express)
2
+
3
+ ## Layer-Based Structure
4
+ Express uses a layer-based approach with Clean Architecture principles separating concerns into distinct directories.
5
+
6
+ ## Directory Structure
7
+ ```
8
+ src/
9
+ ├── domain/
10
+ │ ├── entities/order.entity.ts
11
+ │ ├── value-objects/money.vo.ts
12
+ │ └── errors/domain.error.ts
13
+ ├── application/
14
+ │ ├── use-cases/create-order.use-case.ts
15
+ │ ├── ports/
16
+ │ │ ├── order.repository.port.ts
17
+ │ │ └── payment.gateway.port.ts
18
+ │ └── dtos/create-order.dto.ts
19
+ ├── infrastructure/
20
+ │ ├── repositories/order.repository.ts
21
+ │ ├── services/payment.gateway.ts
22
+ │ ├── database/
23
+ │ │ ├── connection.ts
24
+ │ │ └── migrations/
25
+ │ └── config/env.ts
26
+ ├── interface/
27
+ │ ├── routes/order.routes.ts
28
+ │ ├── controllers/order.controller.ts
29
+ │ ├── middleware/
30
+ │ │ ├── auth.middleware.ts
31
+ │ │ └── error-handler.middleware.ts
32
+ │ └── validators/order.validator.ts
33
+ └── app.ts # Express app setup
34
+ ```
35
+
36
+ ## Dependency Rule
37
+ - domain → depends on nothing outside, pure TypeScript classes
38
+ - application → depends only on domain; use cases call externals via port interfaces
39
+ - infrastructure → implements application ports
40
+ - interface → depends on application; Express routes + controllers
41
+
42
+ ## Conventions
43
+ - Dependency injection via constructor parameters or a simple DI container
44
+ - Use Cases are single-purpose classes with an `execute()` method
45
+ - Controllers handle HTTP concerns (req/res), delegate to Use Cases
46
+ - Error handling via centralized error-handler middleware
47
+
48
+ ## File Naming
49
+ - kebab-case: create-order.use-case.ts
50
+ - Entity: *.entity.ts
51
+ - Value Object: *.vo.ts
52
+ - DTO: *.dto.ts
53
+ - Port: *.port.ts
54
+ - Repository: *.repository.ts
55
+
56
+ ## Testing
57
+ - domain: pure unit tests, no mocks
58
+ - application: mock ports
59
+ - infrastructure: integration tests
60
+ - interface: supertest HTTP tests
@@ -0,0 +1,61 @@
1
+ # Architecture: Clean Architecture (NestJS)
2
+
3
+ ## Module-Based Structure
4
+ NestJS uses Module as its core organizational unit. Each feature gets its own Module, with Clean Architecture layers inside each Module.
5
+
6
+ ## Directory Structure
7
+ ```
8
+ src/
9
+ ├── auth/ # AuthModule
10
+ │ ├── auth.module.ts
11
+ │ ├── domain/
12
+ │ │ └── entities/user.entity.ts
13
+ │ ├── application/
14
+ │ │ ├── use-cases/login.use-case.ts
15
+ │ │ └── ports/auth.repository.port.ts
16
+ │ ├── infrastructure/
17
+ │ │ └── repositories/auth.repository.ts
18
+ │ └── interface/
19
+ │ ├── controllers/auth.controller.ts
20
+ │ └── dtos/login.dto.ts
21
+ ├── order/ # OrderModule
22
+ │ ├── order.module.ts
23
+ │ ├── domain/
24
+ │ ├── application/
25
+ │ ├── infrastructure/
26
+ │ └── interface/
27
+ ├── shared/ # SharedModule (cross-module shared)
28
+ │ ├── shared.module.ts
29
+ │ ├── guards/
30
+ │ ├── interceptors/
31
+ │ ├── filters/
32
+ │ └── decorators/
33
+ └── app.module.ts # Root module
34
+ ```
35
+
36
+ ## Dependency Rule
37
+ - domain → depends on nothing outside, pure TypeScript classes
38
+ - application → depends only on domain; use cases call externals via ports (interfaces)
39
+ - infrastructure → implements application ports, injected into NestJS DI container
40
+ - interface → depends on application; NestJS Controllers + DTOs
41
+
42
+ ## NestJS Conventions
43
+ - Each Module registers providers, controllers, imports, exports in *.module.ts
44
+ - Use Cases inject Port interfaces, receive Infrastructure implementations via NestJS DI
45
+ - Cross-Module dependencies managed through exports + imports
46
+ - Shared Module contains global guards, interceptors, filters, decorators
47
+
48
+ ## File Naming
49
+ - kebab-case: create-order.use-case.ts
50
+ - Entity: *.entity.ts
51
+ - DTO: *.dto.ts
52
+ - Controller: *.controller.ts
53
+ - Repository: *.repository.ts
54
+ - Port: *.port.ts
55
+ - Module: *.module.ts
56
+
57
+ ## Testing
58
+ - domain: pure unit tests, no mocks
59
+ - application: mock ports (using NestJS Testing module)
60
+ - infrastructure: integration tests
61
+ - interface: E2E tests (using supertest)
@@ -0,0 +1,55 @@
1
+ # Architecture: Domain-Driven Design (C# + ASP.NET Core)
2
+
3
+ ## Project Structure
4
+ ```
5
+ src/
6
+ ├── Order.Domain/
7
+ │ ├── Aggregates/OrderAggregate.cs
8
+ │ ├── Entities/OrderItem.cs
9
+ │ ├── ValueObjects/Money.cs
10
+ │ ├── Events/OrderCreatedEvent.cs
11
+ │ ├── Repositories/IOrderRepository.cs
12
+ │ └── Services/PricingService.cs
13
+ ├── Order.Application/
14
+ │ ├── Commands/CreateOrder/
15
+ │ │ ├── CreateOrderCommand.cs
16
+ │ │ └── CreateOrderHandler.cs
17
+ │ ├── Queries/GetOrder/
18
+ │ │ ├── GetOrderQuery.cs
19
+ │ │ └── GetOrderHandler.cs
20
+ │ └── DependencyInjection.cs
21
+ ├── Order.Infrastructure/
22
+ │ ├── Persistence/
23
+ │ │ ├── OrderRepository.cs
24
+ │ │ └── OrderConfiguration.cs
25
+ │ └── EventHandlers/OrderCreatedHandler.cs
26
+ ├── Order.WebApi/
27
+ │ ├── Controllers/OrderController.cs
28
+ │ └── Program.cs
29
+ └── SharedKernel/
30
+ ├── AggregateRoot.cs
31
+ ├── DomainEvent.cs
32
+ └── ValueObject.cs
33
+ ```
34
+
35
+ ## Dependency Rule
36
+ - Domain → depends on nothing, pure C# classes
37
+ - Application → depends on Domain, uses MediatR for CQRS
38
+ - Infrastructure → implements Domain interfaces
39
+ - WebApi → depends on Application
40
+
41
+ ## DDD Conventions
42
+ - Aggregate roots enforce invariants
43
+ - MediatR for Command/Query separation
44
+ - Domain Events via MediatR notifications
45
+ - Value Objects implement Equals/GetHashCode
46
+
47
+ ## File Naming
48
+ - PascalCase: OrderAggregate.cs
49
+ - Folder-per-feature in Application
50
+
51
+ ## Testing
52
+ - Domain: test aggregate invariants (xUnit)
53
+ - Application: mock repositories (NSubstitute)
54
+ - Infrastructure: integration tests
55
+ - WebApi: E2E tests (WebApplicationFactory)
@@ -0,0 +1,53 @@
1
+ # Architecture: Domain-Driven Design (Go + Gin)
2
+
3
+ ## Directory Structure
4
+ ```
5
+ internal/
6
+ ├── order/ # Order Bounded Context
7
+ │ ├── domain/
8
+ │ │ ├── aggregate/order.go # Aggregate root
9
+ │ │ ├── entity/order_item.go
10
+ │ │ ├── valueobject/money.go
11
+ │ │ ├── event/order_created.go
12
+ │ │ ├── repository/order.go # Interface
13
+ │ │ └── service/pricing.go # Domain service
14
+ │ ├── application/
15
+ │ │ ├── command/create_order.go
16
+ │ │ ├── query/get_order.go
17
+ │ │ └── handler/create_order_handler.go
18
+ │ ├── infrastructure/
19
+ │ │ ├── postgres/order_repo.go
20
+ │ │ └── event/publisher.go
21
+ │ └── handler/
22
+ │ └── http/order_handler.go
23
+ ├── payment/ # Payment Bounded Context
24
+ │ └── ...
25
+ ├── shared/
26
+ │ ├── domain/
27
+ │ │ └── base_aggregate.go
28
+ │ └── infrastructure/
29
+ │ └── event_bus.go
30
+ └── pkg/
31
+ ```
32
+
33
+ ## Dependency Rule
34
+ - Aggregate roots are the only entry points to modify domain state
35
+ - Domain events for cross-context communication
36
+ - Application layer uses CQRS pattern
37
+ - Infrastructure implements domain repository interfaces
38
+
39
+ ## DDD Conventions
40
+ - Aggregates enforce invariants; modifications through aggregate methods
41
+ - Value Objects are immutable (unexported fields + constructor)
42
+ - Domain Events published after state changes
43
+ - Anti-corruption layers between bounded contexts
44
+
45
+ ## File Naming
46
+ - snake_case: create_order.go
47
+ - One aggregate per package
48
+
49
+ ## Testing
50
+ - domain: pure unit tests, test aggregate invariants
51
+ - application: mock repositories
52
+ - infrastructure: integration tests
53
+ - handler: HTTP tests
@@ -0,0 +1,52 @@
1
+ # Architecture: Domain-Driven Design (Python + FastAPI)
2
+
3
+ ## Directory Structure
4
+ ```
5
+ src/
6
+ ├── order/ # Order Bounded Context
7
+ │ ├── domain/
8
+ │ │ ├── aggregates/order.py # Aggregate root
9
+ │ │ ├── entities/order_item.py
10
+ │ │ ├── value_objects/money.py
11
+ │ │ ├── events/order_created.py
12
+ │ │ ├── repositories/order_repository.py # ABC
13
+ │ │ └── services/pricing_service.py
14
+ │ ├── application/
15
+ │ │ ├── commands/create_order.py
16
+ │ │ ├── queries/get_order.py
17
+ │ │ └── handlers/create_order_handler.py
18
+ │ ├── infrastructure/
19
+ │ │ ├── repositories/order_sqlalchemy_repo.py
20
+ │ │ └── event_handlers/order_created_handler.py
21
+ │ └── interface/
22
+ │ ├── routers/order_router.py
23
+ │ └── dtos/create_order_dto.py
24
+ ├── payment/
25
+ │ └── ...
26
+ ├── shared/
27
+ │ ├── domain/base_aggregate.py
28
+ │ └── infrastructure/event_bus.py
29
+ └── main.py
30
+ ```
31
+
32
+ ## Dependency Rule
33
+ - Aggregate roots are the only entry points to modify domain state
34
+ - Domain events for cross-context communication
35
+ - Application layer uses CQRS pattern
36
+ - Infrastructure implements domain repository ABCs
37
+
38
+ ## DDD Conventions
39
+ - Aggregates enforce invariants via methods
40
+ - Value Objects use frozen dataclasses
41
+ - Domain Events as dataclass records
42
+ - Anti-corruption layers between bounded contexts
43
+
44
+ ## File Naming
45
+ - snake_case: create_order.py
46
+ - Test files: test_create_order.py
47
+
48
+ ## Testing
49
+ - domain: pure unit tests (pytest)
50
+ - application: mock repositories
51
+ - infrastructure: integration tests
52
+ - interface: HTTP tests (httpx)
@@ -0,0 +1,62 @@
1
+ # Architecture: Domain-Driven Design (NestJS)
2
+
3
+ ## Bounded Context Structure
4
+ Each bounded context is a NestJS module with DDD tactical patterns.
5
+
6
+ ## Directory Structure
7
+ ```
8
+ src/
9
+ ├── order/ # Order Bounded Context
10
+ │ ├── order.module.ts
11
+ │ ├── domain/
12
+ │ │ ├── aggregates/order.aggregate.ts
13
+ │ │ ├── entities/order-item.entity.ts
14
+ │ │ ├── value-objects/money.vo.ts
15
+ │ │ ├── events/order-created.event.ts
16
+ │ │ ├── repositories/order.repository.ts # Interface
17
+ │ │ └── services/pricing.domain-service.ts
18
+ │ ├── application/
19
+ │ │ ├── commands/create-order.command.ts
20
+ │ │ ├── queries/get-order.query.ts
21
+ │ │ └── handlers/create-order.handler.ts
22
+ │ ├── infrastructure/
23
+ │ │ ├── repositories/order.typeorm-repository.ts
24
+ │ │ └── event-handlers/order-created.handler.ts
25
+ │ └── interface/
26
+ │ ├── controllers/order.controller.ts
27
+ │ └── dtos/create-order.dto.ts
28
+ ├── payment/ # Payment Bounded Context
29
+ │ └── ...
30
+ ├── shared/
31
+ │ ├── domain/
32
+ │ │ └── base-aggregate.ts
33
+ │ └── infrastructure/
34
+ │ └── event-bus.ts
35
+ └── app.module.ts
36
+ ```
37
+
38
+ ## Dependency Rule
39
+ - Aggregate roots are the only entry points to modify domain state
40
+ - Domain events for cross-context communication
41
+ - Application layer uses CQRS (Commands + Queries)
42
+ - Infrastructure implements domain repository interfaces
43
+
44
+ ## DDD Conventions
45
+ - Aggregates enforce invariants; entity modifications go through aggregate methods
46
+ - Value Objects are immutable
47
+ - Domain Events published after state changes
48
+ - Anti-corruption layers between bounded contexts
49
+ - Ubiquitous language reflected in class and method names
50
+
51
+ ## File Naming
52
+ - kebab-case: create-order.command.ts
53
+ - Aggregate: *.aggregate.ts
54
+ - Value Object: *.vo.ts
55
+ - Domain Event: *.event.ts
56
+ - Domain Service: *.domain-service.ts
57
+
58
+ ## Testing
59
+ - domain: pure unit tests, test aggregate invariants
60
+ - application: mock repositories, verify events
61
+ - infrastructure: integration tests
62
+ - interface: E2E tests
@@ -0,0 +1,45 @@
1
+ # Architecture: Hexagonal / Ports & Adapters (C# + ASP.NET Core)
2
+
3
+ ## Project Structure
4
+ ```
5
+ src/
6
+ ├── Core/
7
+ │ ├── Domain/
8
+ │ │ ├── Entities/Order.cs
9
+ │ │ └── ValueObjects/Money.cs
10
+ │ └── Ports/
11
+ │ ├── Inbound/ICreateOrderUseCase.cs
12
+ │ └── Outbound/IOrderRepository.cs
13
+ ├── Application/
14
+ │ └── Services/OrderService.cs # Implements inbound ports
15
+ ├── Adapters/
16
+ │ ├── Inbound/
17
+ │ │ └── WebApi/
18
+ │ │ ├── Controllers/OrderController.cs
19
+ │ │ └── Program.cs
20
+ │ └── Outbound/
21
+ │ ├── Persistence/
22
+ │ │ ├── OrderRepository.cs
23
+ │ │ └── ApplicationDbContext.cs
24
+ │ └── Messaging/EventPublisher.cs
25
+ ```
26
+
27
+ ## Dependency Rule
28
+ - Core → depends on nothing, pure C# interfaces and classes
29
+ - Application → implements inbound ports, depends only on Core
30
+ - Adapters → implement outbound ports or call inbound ports
31
+
32
+ ## Conventions
33
+ - Inbound ports = use case interfaces
34
+ - Outbound ports = infrastructure interfaces
35
+ - DI registration wires adapters to ports in Program.cs
36
+ - EF Core in outbound persistence adapter
37
+
38
+ ## File Naming
39
+ - PascalCase: OrderService.cs
40
+ - One class per file
41
+
42
+ ## Testing
43
+ - Core: pure unit tests (xUnit)
44
+ - Application: mock outbound ports (NSubstitute)
45
+ - Adapters: integration tests (WebApplicationFactory)
@@ -0,0 +1,47 @@
1
+ # Architecture: Hexagonal / Ports & Adapters (Go + Gin)
2
+
3
+ ## Directory Structure
4
+ ```
5
+ internal/
6
+ ├── core/
7
+ │ ├── domain/
8
+ │ │ ├── order.go # Entities, Value Objects
9
+ │ │ └── errors.go # Domain errors
10
+ │ └── ports/
11
+ │ ├── inbound.go # Driving port interfaces
12
+ │ └── outbound.go # Driven port interfaces
13
+ ├── application/
14
+ │ └── order_service.go # Implements inbound ports
15
+ ├── adapters/
16
+ │ ├── inbound/
17
+ │ │ └── http/
18
+ │ │ ├── order_handler.go # Gin handler
19
+ │ │ ├── middleware/
20
+ │ │ └── router.go
21
+ │ └── outbound/
22
+ │ ├── postgres/
23
+ │ │ └── order_repo.go
24
+ │ └── redis/
25
+ │ └── cache.go
26
+ └── pkg/
27
+ ```
28
+
29
+ ## Dependency Rule
30
+ - core → depends on nothing, pure Go types and interfaces
31
+ - application → implements inbound ports, depends only on core
32
+ - adapters → implement outbound ports or call inbound ports
33
+
34
+ ## Conventions
35
+ - Ports defined as Go interfaces in core/ports/
36
+ - Adapters implement port interfaces
37
+ - Dependency injection via constructor functions
38
+ - Context passed throughout
39
+
40
+ ## File Naming
41
+ - snake_case: order_service.go
42
+ - Test files: order_service_test.go
43
+
44
+ ## Testing
45
+ - core: pure unit tests
46
+ - application: mock outbound ports
47
+ - adapters: integration tests per adapter
@@ -0,0 +1,43 @@
1
+ # Architecture: Hexagonal / Ports & Adapters (Python + FastAPI)
2
+
3
+ ## Directory Structure
4
+ ```
5
+ src/
6
+ ├── core/
7
+ │ ├── domain/
8
+ │ │ ├── entities/order.py
9
+ │ │ └── errors.py
10
+ │ └── ports/
11
+ │ ├── inbound/create_order_port.py # ABC interfaces
12
+ │ └── outbound/order_repository.py # ABC interfaces
13
+ ├── application/
14
+ │ └── services/order_service.py # Implements inbound ports
15
+ ├── adapters/
16
+ │ ├── inbound/
17
+ │ │ └── http/
18
+ │ │ ├── order_router.py
19
+ │ │ └── dependencies.py
20
+ │ └── outbound/
21
+ │ ├── persistence/order_repository.py
22
+ │ └── messaging/event_publisher.py
23
+ └── main.py
24
+ ```
25
+
26
+ ## Dependency Rule
27
+ - core → depends on nothing, pure Python ABCs and dataclasses
28
+ - application → implements inbound ports, depends only on core
29
+ - adapters → implement outbound ports or call inbound ports
30
+
31
+ ## Conventions
32
+ - Ports defined as Abstract Base Classes in core/ports/
33
+ - FastAPI dependency injection wires adapters to ports
34
+ - Pydantic for DTOs at adapter boundary
35
+
36
+ ## File Naming
37
+ - snake_case: order_service.py
38
+ - Test files: test_order_service.py
39
+
40
+ ## Testing
41
+ - core: pure unit tests (pytest)
42
+ - application: mock outbound ports
43
+ - adapters: integration tests per adapter
@@ -0,0 +1,44 @@
1
+ # Architecture: Hexagonal / Ports & Adapters (NestJS)
2
+
3
+ ## Directory Structure
4
+ ```
5
+ src/
6
+ ├── core/
7
+ │ ├── domain/
8
+ │ │ ├── entities/order.entity.ts
9
+ │ │ └── value-objects/money.vo.ts
10
+ │ └── ports/
11
+ │ ├── inbound/create-order.port.ts # Driving ports (use case interfaces)
12
+ │ └── outbound/order.repository.port.ts # Driven ports
13
+ ├── application/
14
+ │ └── services/order.service.ts # Implements inbound ports
15
+ ├── adapters/
16
+ │ ├── inbound/
17
+ │ │ ├── http/order.controller.ts # REST adapter
18
+ │ │ └── grpc/order.grpc.ts # gRPC adapter
19
+ │ └── outbound/
20
+ │ ├── persistence/order.repository.ts # DB adapter
21
+ │ └── messaging/event.publisher.ts # Message queue adapter
22
+ └── app.module.ts
23
+ ```
24
+
25
+ ## Dependency Rule
26
+ - core (domain + ports) → depends on nothing, defines all interfaces
27
+ - application → implements inbound ports, depends on core only
28
+ - adapters → implement outbound ports or call inbound ports
29
+
30
+ ## Conventions
31
+ - Inbound ports = use case interfaces (what the app can do)
32
+ - Outbound ports = infrastructure interfaces (what the app needs)
33
+ - Adapters are interchangeable (swap DB, swap transport)
34
+ - NestJS modules wire adapters to ports via DI
35
+
36
+ ## File Naming
37
+ - kebab-case: create-order.port.ts
38
+ - Port: *.port.ts
39
+ - Adapter suffix indicates type: *.controller.ts, *.repository.ts
40
+
41
+ ## Testing
42
+ - core: pure unit tests
43
+ - application: mock outbound ports
44
+ - adapters: integration tests per adapter