38 lines
959 B
Markdown
38 lines
959 B
Markdown
|
|
# ADR-009: Persistence Independence
|
||
|
|
|
||
|
|
## Status
|
||
|
|
Accepted
|
||
|
|
|
||
|
|
## Context
|
||
|
|
We need to ensure that business logic is not coupled to persistence implementation.
|
||
|
|
|
||
|
|
## Decision
|
||
|
|
Same use cases must produce same results regardless of repository implementation.
|
||
|
|
|
||
|
|
### Verification Method
|
||
|
|
1. Run test with InMemoryRepository
|
||
|
|
2. Run test with PostgresRepository (when implemented)
|
||
|
|
3. Compare results
|
||
|
|
4. If different, adapter is wrong
|
||
|
|
|
||
|
|
### Architecture Rules
|
||
|
|
- Domain: 0 external dependencies
|
||
|
|
- Application: only domain + contracts
|
||
|
|
- Infrastructure: may depend on external libraries, never reverse
|
||
|
|
- Persistence Independence: same use cases, same results
|
||
|
|
|
||
|
|
## Consequences
|
||
|
|
|
||
|
|
### Positive
|
||
|
|
- Strong architecture verification
|
||
|
|
- Easy to swap implementations
|
||
|
|
- Tests document expected behavior
|
||
|
|
|
||
|
|
### Negative
|
||
|
|
- Need to maintain two test suites
|
||
|
|
- PostgreSQL tests require database setup
|
||
|
|
|
||
|
|
## Related
|
||
|
|
- ADR-006: In-Memory Adapters for Testing
|
||
|
|
- ADR-008: PostgreSQL Adapters for Production
|