Commit 0911cfd
committed
Merge #100: Add DDD Layer Placement Guide to Contributing Documentation
585027d docs: [#79] replace specific code examples with generic patterns (copilot-swe-agent[bot])
e5d5f99 docs: [#79] clarify infrastructure layer directory organization (copilot-swe-agent[bot])
444fbe9 docs: [#79] add comprehensive DDD layer placement guide (copilot-swe-agent[bot])
018fad5 Initial plan (copilot-swe-agent[bot])
Pull request description:
The project lacked clear guidelines on DDD layer placement, leading to architectural violations like the config module being placed in domain when it belonged in application (#75). Contributors needed explicit rules to distinguish between domain entities, DTOs, and infrastructure concerns.
## Changes
### Documentation Added
- **`docs/contributing/ddd-layer-placement.md`** - Comprehensive guide with:
- Layer specifications for Domain, Application, Infrastructure (`adapters/` + `infrastructure/`), and Presentation
- Decision flowchart mapping code characteristics to correct layer
- Generic, illustrative patterns demonstrating common architectural concepts (value objects, command handlers, adapters for external tools, CLI definitions)
- Common mistakes section showing wrong placements with corrections
- **Critical nuance on serde usage** - Distinguishes acceptable from problematic patterns:
```rust
// ✅ Domain entity with serde for persistence (acceptable pragmatic trade-off)
#[derive(Serialize, Deserialize)]
pub struct EnvironmentName(String);
// ❌ DTO in domain layer (wrong - belongs in application)
#[derive(Serialize, Deserialize)]
pub struct ConfigDto {
pub name: String, // Raw primitive, no domain validation
}
```
### Documentation Updated
- **`docs/contributing/README.md`** - Expanded quick reference table with all contributing guides, DDD placement listed first
- **`.github/copilot-instructions.md`** - Added layer placement as Essential Rule #1
### Examples Approach
The guide uses generic, illustrative code patterns rather than specific codebase examples. This makes the documentation more maintainable (no updates needed when actual code changes) while still effectively demonstrating the architectural principles and common patterns like command handlers, repository implementations, and external tool adapters.
## Resolves
Closes #79
Related to #75 (the violation that exposed this gap)
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>Add DDD Layer Placement Guide to Contributing Documentation</issue_title>
> <issue_description># Add DDD Layer Placement Guide to Contributing Documentation
>
> ## 📋 Issue Information
>
> - **Type**: Documentation Enhancement
> - **Priority**: High
> - **Related Issue**: #75 - Move config module to correct DDD layer
> - **Parent Epic**: None (standalone improvement)
>
> ## 🎯 Problem Statement
>
> The project lacks clear guidelines on which code belongs in which DDD layer (Domain, Application, Infrastructure, Presentation). This has led to violations like the config module (#75) being placed in the domain layer when it clearly belongs in the application layer.
>
> Without explicit documentation, contributors (including AI assistants) may:
>
> - Place DTOs in the domain layer
> - Mix infrastructure concerns (file I/O, HTTP) with domain logic
> - Create unclear boundaries between layers
> - Make code harder to maintain and test
>
> ## 💡 Proposed Solution
>
> Create a comprehensive guide `docs/contributing/ddd-layer-placement.md` that clearly documents each layer's purpose, rules, red flags, examples, and includes a decision flowchart.
>
> ## 📝 Implementation Plan
>
> See detailed specification: [docs/issues/add-ddd-layer-placement-guide.md](https://github.com/torrust/torrust-tracker-deployer/blob/main/docs/issues/add-ddd-layer-placement-guide.md)
>
> ## ✅ Acceptance Criteria
>
> > **Note for Contributors**: These criteria define what the PR reviewer will check. Use this as your pre-review checklist before submitting the PR to minimize back-and-forth iterations.
>
> - [ ] Document created at `docs/contributing/ddd-layer-placement.md`
> - [ ] All four layers documented with clear rules and examples
> - [ ] Nuanced guidance on serde usage included (entities vs DTOs)
> - [ ] Decision flowchart included for quick reference
> - [ ] Real code examples from the codebase
> - [ ] Linked from `docs/contributing/README.md`
> - [ ] Referenced in `.github/copilot-instructions.md`
> - [ ] All linters pass (markdownlint, cspell)
> - [ ] Document follows project markdown conventions
>
> ## 🏷️ Labels
>
> documentation, enhancement, DDD, contributing-guide</issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
- Fixes #79
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.
ACKs for top commit:
josecelano:
ACK 585027d
Tree-SHA512: ebb14adfc94ea7a36c98c32943c0a7d49f507ef6c8980aff987258032e1e116e64064a7947a4bb77ab0c1c236045adf17a9411492743b6c65ed92d5943a9bed2File tree
3 files changed
+826
-15
lines changed- .github
- docs/contributing
3 files changed
+826
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
74 | | - | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
88 | | - | |
| 90 | + | |
89 | 91 | | |
90 | | - | |
| 92 | + | |
91 | 93 | | |
92 | | - | |
| 94 | + | |
93 | 95 | | |
94 | | - | |
| 96 | + | |
95 | 97 | | |
96 | | - | |
| 98 | + | |
97 | 99 | | |
98 | | - | |
| 100 | + | |
99 | 101 | | |
100 | 102 | | |
101 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
13 | 21 | | |
14 | 22 | | |
15 | 23 | | |
| |||
0 commit comments