# Domain vs Data: Where Does Logic Belong?

> Why does the data side of one feature need 4 files across 2 different modules?

- URL: https://dantech.academy/en/courses/kotlin-accelerator/engineer-builder/04-clean-architecture-integration/lesson-02-separate-repository-contracts-and-data-implementations
- Course: [Mobile Action Pro](https://dantech.academy/en/courses/kotlin-accelerator.md)
- Module: Clean Architecture and Integration
- Duration: 12 min
- Difficulty: intermediate
- Access: Enrolled students
- Tiếng Việt: https://dantech.academy/courses/kotlin-accelerator/engineer-builder/04-clean-architecture-integration/lesson-02-separate-repository-contracts-and-data-implementations.md

## Objectives

- Choose between repository, service and manager by their real role
- What happens if you put everything into 1 file
- Read DomainResult and DomainFailure and know that errors are classified once in :data

## In this lesson

1. Lesson Goal
2. Part 1: Module Dependencies
3. Part 2: Errors Are Classified In :data, Once
4. Part 3: An Abstraction Only Exposes What's Essential
5. Part 4: Why Repository, Service Or Manager?
6. Part 5: A Contract Lives With Its Consumer
7. Code Reading Path
8. Bad Smells
9. Key Takeaways

## Study with an AI agent

The full lesson is for students of this course. Students open the lesson on the web and press **Markdown** to copy all of it, then paste it into Claude, ChatGPT, Cursor or whichever agent you use. Faster: mint a token at `/profile/ai-agents` and your agent reads lessons over MCP.

- [Join the course](https://dantech.academy/en/kotlin-accelerator/checkout)

---

- Previous lesson: [Use Case: The App's Unit Of Business Logic](https://dantech.academy/en/courses/kotlin-accelerator/engineer-builder/04-clean-architecture-integration/lesson-01-read-domain-use-cases.md)
- Next lesson: [The Clean Architecture Of A Sign-In Tap](https://dantech.academy/en/courses/kotlin-accelerator/engineer-builder/04-clean-architecture-integration/lesson-03-trace-supabase-auth-flow.md)
