@pixel613/spec 1.0.1
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.
- package/LICENSE +21 -0
- package/README.md +174 -0
- package/dist/bin/pxs.d.ts +2 -0
- package/dist/bin/pxs.js +5 -0
- package/dist/bin/pxs.js.map +1 -0
- package/dist/src/backends/claude.d.ts +9 -0
- package/dist/src/backends/claude.js +80 -0
- package/dist/src/backends/claude.js.map +1 -0
- package/dist/src/backends/codex.d.ts +9 -0
- package/dist/src/backends/codex.js +72 -0
- package/dist/src/backends/codex.js.map +1 -0
- package/dist/src/backends/factory.d.ts +2 -0
- package/dist/src/backends/factory.js +14 -0
- package/dist/src/backends/factory.js.map +1 -0
- package/dist/src/backends/interface.d.ts +15 -0
- package/dist/src/backends/interface.js +2 -0
- package/dist/src/backends/interface.js.map +1 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +79 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/commands/clarify.d.ts +5 -0
- package/dist/src/commands/clarify.js +46 -0
- package/dist/src/commands/clarify.js.map +1 -0
- package/dist/src/commands/implement.d.ts +9 -0
- package/dist/src/commands/implement.js +244 -0
- package/dist/src/commands/implement.js.map +1 -0
- package/dist/src/commands/init.d.ts +6 -0
- package/dist/src/commands/init.js +177 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/new.d.ts +5 -0
- package/dist/src/commands/new.js +143 -0
- package/dist/src/commands/new.js.map +1 -0
- package/dist/src/commands/refine.d.ts +8 -0
- package/dist/src/commands/refine.js +158 -0
- package/dist/src/commands/refine.js.map +1 -0
- package/dist/src/commands/review.d.ts +4 -0
- package/dist/src/commands/review.js +70 -0
- package/dist/src/commands/review.js.map +1 -0
- package/dist/src/commands/status.d.ts +1 -0
- package/dist/src/commands/status.js +53 -0
- package/dist/src/commands/status.js.map +1 -0
- package/dist/src/discovery/project.d.ts +7 -0
- package/dist/src/discovery/project.js +90 -0
- package/dist/src/discovery/project.js.map +1 -0
- package/dist/src/git/operations.d.ts +10 -0
- package/dist/src/git/operations.js +56 -0
- package/dist/src/git/operations.js.map +1 -0
- package/dist/src/parsers/arguments.d.ts +18 -0
- package/dist/src/parsers/arguments.js +43 -0
- package/dist/src/parsers/arguments.js.map +1 -0
- package/dist/src/parsers/plan.d.ts +23 -0
- package/dist/src/parsers/plan.js +117 -0
- package/dist/src/parsers/plan.js.map +1 -0
- package/dist/src/parsers/spec.d.ts +10 -0
- package/dist/src/parsers/spec.js +46 -0
- package/dist/src/parsers/spec.js.map +1 -0
- package/dist/src/state/manager.d.ts +24 -0
- package/dist/src/state/manager.js +103 -0
- package/dist/src/state/manager.js.map +1 -0
- package/dist/src/state/types.d.ts +47 -0
- package/dist/src/state/types.js +21 -0
- package/dist/src/state/types.js.map +1 -0
- package/dist/src/utils/display.d.ts +7 -0
- package/dist/src/utils/display.js +42 -0
- package/dist/src/utils/display.js.map +1 -0
- package/dist/src/utils/prompt.d.ts +31 -0
- package/dist/src/utils/prompt.js +81 -0
- package/dist/src/utils/prompt.js.map +1 -0
- package/package.json +52 -0
- package/templates/agents-md-snippet.md +20 -0
- package/templates/architectures/clean/csharp-aspnet.md +56 -0
- package/templates/architectures/clean/go-gin.md +50 -0
- package/templates/architectures/clean/go-std.md +49 -0
- package/templates/architectures/clean/python-fastapi.md +49 -0
- package/templates/architectures/clean/typescript-express.md +60 -0
- package/templates/architectures/clean/typescript-nestjs.md +61 -0
- package/templates/architectures/ddd/csharp-aspnet.md +55 -0
- package/templates/architectures/ddd/go-gin.md +53 -0
- package/templates/architectures/ddd/python-fastapi.md +52 -0
- package/templates/architectures/ddd/typescript-nestjs.md +62 -0
- package/templates/architectures/hexagonal/csharp-aspnet.md +45 -0
- package/templates/architectures/hexagonal/go-gin.md +47 -0
- package/templates/architectures/hexagonal/python-fastapi.md +43 -0
- package/templates/architectures/hexagonal/typescript-nestjs.md +44 -0
- package/templates/architectures/layered/csharp-aspnet.md +45 -0
- package/templates/architectures/layered/go-gin.md +41 -0
- package/templates/architectures/layered/python-fastapi.md +42 -0
- package/templates/architectures/layered/typescript-nestjs.md +48 -0
- package/templates/architectures/modular/csharp-aspnet.md +45 -0
- package/templates/architectures/modular/go-gin.md +47 -0
- package/templates/architectures/modular/python-fastapi.md +45 -0
- package/templates/architectures/modular/typescript-nestjs.md +48 -0
- package/templates/claude-commands/sf.clarify.md +18 -0
- package/templates/claude-commands/sf.implement.md +79 -0
- package/templates/claude-commands/sf.new.md +22 -0
- package/templates/claude-commands/sf.refine.md +47 -0
- package/templates/claude-commands/sf.review.md +17 -0
- package/templates/claude-commands/sf.status.md +12 -0
- package/templates/workflow/config.yaml +17 -0
- package/templates/workflow/prompts/clarify.md +39 -0
- package/templates/workflow/prompts/final-review.md +30 -0
- package/templates/workflow/prompts/implement-tdd.md +35 -0
- package/templates/workflow/prompts/implement.md +43 -0
- package/templates/workflow/prompts/refine.md +52 -0
- package/templates/workflow/prompts/review.md +34 -0
- package/templates/workflow/prompts/test.md +14 -0
- package/templates/workflow/templates/spec-template.md +13 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Architecture: Clean Architecture (C# + ASP.NET Core)
|
|
2
|
+
|
|
3
|
+
## Project Structure
|
|
4
|
+
```
|
|
5
|
+
src/
|
|
6
|
+
├── Domain/
|
|
7
|
+
│ ├── Entities/Order.cs
|
|
8
|
+
│ ├── ValueObjects/Money.cs
|
|
9
|
+
│ ├── Events/OrderCreatedEvent.cs
|
|
10
|
+
│ ├── Errors/DomainException.cs
|
|
11
|
+
│ └── Interfaces/IOrderRepository.cs
|
|
12
|
+
├── Application/
|
|
13
|
+
│ ├── UseCases/CreateOrder/
|
|
14
|
+
│ │ ├── CreateOrderCommand.cs
|
|
15
|
+
│ │ ├── CreateOrderHandler.cs
|
|
16
|
+
│ │ └── CreateOrderValidator.cs
|
|
17
|
+
│ ├── Common/
|
|
18
|
+
│ │ └── Behaviors/ValidationBehavior.cs
|
|
19
|
+
│ └── DependencyInjection.cs
|
|
20
|
+
├── Infrastructure/
|
|
21
|
+
│ ├── Persistence/
|
|
22
|
+
│ │ ├── ApplicationDbContext.cs
|
|
23
|
+
│ │ ├── Repositories/OrderRepository.cs
|
|
24
|
+
│ │ └── Configurations/OrderConfiguration.cs
|
|
25
|
+
│ ├── Services/
|
|
26
|
+
│ │ └── PaymentGateway.cs
|
|
27
|
+
│ └── DependencyInjection.cs
|
|
28
|
+
└── WebApi/
|
|
29
|
+
├── Controllers/OrderController.cs
|
|
30
|
+
├── Middleware/ExceptionHandlerMiddleware.cs
|
|
31
|
+
├── Filters/
|
|
32
|
+
└── Program.cs
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Dependency Rule
|
|
36
|
+
- Domain → depends on nothing outside, pure C# classes
|
|
37
|
+
- Application → depends only on Domain; uses MediatR for CQRS
|
|
38
|
+
- Infrastructure → implements Domain interfaces, EF Core DbContext
|
|
39
|
+
- WebApi → depends on Application; ASP.NET Controllers + minimal APIs
|
|
40
|
+
|
|
41
|
+
## Conventions
|
|
42
|
+
- MediatR for Command/Query handling
|
|
43
|
+
- FluentValidation for input validation
|
|
44
|
+
- EF Core with Fluent API configuration (no data annotations on Domain)
|
|
45
|
+
- DI registration in each layer's DependencyInjection.cs
|
|
46
|
+
|
|
47
|
+
## File Naming
|
|
48
|
+
- PascalCase: CreateOrderCommand.cs
|
|
49
|
+
- One class per file
|
|
50
|
+
- Folder-per-feature in Application (e.g., UseCases/CreateOrder/)
|
|
51
|
+
|
|
52
|
+
## Testing
|
|
53
|
+
- Domain: pure unit tests (xUnit)
|
|
54
|
+
- Application: mock repositories (NSubstitute/Moq)
|
|
55
|
+
- Infrastructure: integration tests (WebApplicationFactory, TestContainers)
|
|
56
|
+
- WebApi: E2E tests (WebApplicationFactory)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Architecture: Clean Architecture (Go + Gin)
|
|
2
|
+
|
|
3
|
+
## Directory Structure
|
|
4
|
+
```
|
|
5
|
+
internal/
|
|
6
|
+
├── domain/
|
|
7
|
+
│ ├── entity/order.go # Entities, Value Objects
|
|
8
|
+
│ └── event/order_created.go # Domain Events
|
|
9
|
+
├── usecase/
|
|
10
|
+
│ ├── create_order.go # Use Cases (one file per use case)
|
|
11
|
+
│ └── interfaces.go # Port interfaces
|
|
12
|
+
├── infrastructure/
|
|
13
|
+
│ ├── postgres/
|
|
14
|
+
│ │ └── order_repo.go # Repository implementation
|
|
15
|
+
│ ├── redis/
|
|
16
|
+
│ │ └── cache.go # Cache implementation (if any)
|
|
17
|
+
│ └── config/
|
|
18
|
+
│ └── env.go # Environment configuration
|
|
19
|
+
├── handler/
|
|
20
|
+
│ └── http/
|
|
21
|
+
│ ├── order_handler.go # Gin handler
|
|
22
|
+
│ ├── middleware/
|
|
23
|
+
│ │ └── auth.go # Middleware
|
|
24
|
+
│ └── router.go # Route definitions
|
|
25
|
+
└── pkg/ # Cross-project reusable packages
|
|
26
|
+
└── logger/
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Dependency Rule
|
|
30
|
+
- domain → depends on nothing outside, pure Go structs and interfaces
|
|
31
|
+
- usecase → depends only on domain; calls infrastructure through interfaces
|
|
32
|
+
- infrastructure → implements usecase interfaces
|
|
33
|
+
- handler → depends on usecase; handles HTTP layer
|
|
34
|
+
|
|
35
|
+
## Go Conventions
|
|
36
|
+
- Interfaces defined at the consumer side (usecase/), not implementation side (infrastructure/)
|
|
37
|
+
- Error handling uses custom error types defined in domain/
|
|
38
|
+
- Struct initialization uses New functions: NewOrderUseCase(), NewOrderRepo()
|
|
39
|
+
- Context passed throughout: handler → usecase → repository
|
|
40
|
+
|
|
41
|
+
## File Naming
|
|
42
|
+
- snake_case: create_order.go
|
|
43
|
+
- Test files: create_order_test.go
|
|
44
|
+
- One type per file within same package
|
|
45
|
+
|
|
46
|
+
## Testing
|
|
47
|
+
- domain: pure unit tests
|
|
48
|
+
- usecase: mock interfaces (using mockgen or hand-written mocks)
|
|
49
|
+
- infrastructure: integration tests (using testcontainers or test DB)
|
|
50
|
+
- handler: HTTP tests (using httptest)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Architecture: Clean Architecture (Go Standard Library)
|
|
2
|
+
|
|
3
|
+
## Directory Structure
|
|
4
|
+
```
|
|
5
|
+
internal/
|
|
6
|
+
├── domain/
|
|
7
|
+
│ ├── entity/order.go # Entities, Value Objects
|
|
8
|
+
│ └── errors.go # Domain errors
|
|
9
|
+
├── usecase/
|
|
10
|
+
│ ├── create_order.go # Use Cases
|
|
11
|
+
│ └── interfaces.go # Port interfaces
|
|
12
|
+
├── infrastructure/
|
|
13
|
+
│ ├── postgres/
|
|
14
|
+
│ │ └── order_repo.go # Repository implementation
|
|
15
|
+
│ └── config/
|
|
16
|
+
│ └── env.go # Environment configuration
|
|
17
|
+
├── handler/
|
|
18
|
+
│ └── http/
|
|
19
|
+
│ ├── order_handler.go # net/http handler
|
|
20
|
+
│ ├── middleware/
|
|
21
|
+
│ │ └── auth.go # Middleware
|
|
22
|
+
│ └── router.go # http.ServeMux routes
|
|
23
|
+
└── pkg/
|
|
24
|
+
└── logger/
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Dependency Rule
|
|
28
|
+
- domain → depends on nothing outside, pure Go structs and interfaces
|
|
29
|
+
- usecase → depends only on domain; calls infrastructure through interfaces
|
|
30
|
+
- infrastructure → implements usecase interfaces
|
|
31
|
+
- handler → depends on usecase; handles HTTP layer using net/http
|
|
32
|
+
|
|
33
|
+
## Go Conventions
|
|
34
|
+
- Use net/http ServeMux (Go 1.22+ enhanced routing) instead of external routers
|
|
35
|
+
- Interfaces defined at the consumer side (usecase/)
|
|
36
|
+
- Error handling uses custom error types defined in domain/
|
|
37
|
+
- Struct initialization uses New functions
|
|
38
|
+
- Context passed throughout: handler → usecase → repository
|
|
39
|
+
|
|
40
|
+
## File Naming
|
|
41
|
+
- snake_case: create_order.go
|
|
42
|
+
- Test files: create_order_test.go
|
|
43
|
+
- One type per file within same package
|
|
44
|
+
|
|
45
|
+
## Testing
|
|
46
|
+
- domain: pure unit tests
|
|
47
|
+
- usecase: mock interfaces
|
|
48
|
+
- infrastructure: integration tests (using testcontainers)
|
|
49
|
+
- handler: HTTP tests (using httptest)
|
|
@@ -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,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
|