Entities: Enterprise Business Rules
What You'll Learn
You'll learn what Entities are in Clean Architecture and how they encapsulate your most critical, application-independent business rules.
The Core Concept
Entities are the innermost layer of Clean Architecture—they contain the core business logic that would exist even if you never built any software. These are the fundamental rules that define your business domain.
Think of Entities like the immutable laws of physics in a simulation. Whether you're running that simulation on a supercomputer, a phone app, or pen-and-paper, the laws stay the same. Similarly, your business rules—"a loan must have a positive interest rate," "an order can't be placed with negative quantities"—remain true regardless of whether you expose them through a web API, mobile app, or command-line tool.
Entities differ from application-specific logic. They don't know about databases, HTTP requests, or UI frameworks. An Entity representing a BankAccount doesn't care if it's stored in PostgreSQL or MongoDB, or if it's accessed via REST or GraphQL.
Characteristics of Entities
- Technology-agnostic: No dependencies on frameworks, databases, or external libraries
- Business-focused: Represent real-world business concepts and constraints
- Stable: Change only when fundamental business rules change, not when UI or infrastructure changes
- Reusable: Could theoretically be used across multiple applications in the same business domain
For example, a LoanApplication entity might contain rules about credit scores, income requirements, and debt-to-income ratios—rules that are true whether you're building a web portal, mobile app, or batch processing system.
Key Takeaway: Entities are your system's fundamental business rules, completely independent of technology choices—they represent what your business is, not how it's implemented.