-
Notifications
You must be signed in to change notification settings - Fork 2
Data and Domain Architecture
This document covers the domain layer architecture and data flow patterns in the Effective Office system. It focuses on the business logic implementation, use case patterns, domain models, and how data flows through the application layers.
For detailed information about specific use case implementations, see[Domain Use Cases](Data and Domain Architecture/Domain Use Cases). For repository implementations and data access patterns, see [Data Layer and Repositories](Data and Domain Architecture/Data Layer and Repositories).
The Effective Office system follows clean architecture principles with clear separation between domain logic, data access, and presentation layers. The domain layer contains business rules and use cases that are independent of external frameworks and data sources.
The system implements the use case pattern to encapsulate business logic and maintain clean separation of concerns. Each use case represents a single business operation and follows consistent patterns for error handling and data flow.
Category | Use Cases | Purpose |
---|---|---|
Booking Operations |
CreateBookingUseCase , UpdateBookingUseCase , DeleteBookingUseCase
|
Manage room bookings with network/local synchronization |
Room Management |
RoomInfoUseCase , SelectRoomUseCase , GetRoomByNameUseCase
|
Handle room information and selection logic |
Data Synchronization |
RefreshDataUseCase , UpdateUseCase , GetEventsFlowUseCase
|
Coordinate data updates and real-time synchronization |
Validation |
CheckBookingUseCase , CheckSettingsUseCase
|
Validate business rules and constraints |
The domain layer defines core business entities that represent the system's data model. These models are used consistently across use cases and provide type safety for business operations.
The main domain models include:
-
RoomInfo
: Represents room state including current and upcoming events -
EventInfo
: Represents booking/event details with loading states -
ErrorResponse
: Standardized error information with HTTP status codes -
Either<ErrorResponse, T>
: Functional error handling pattern
The UpdateUseCase
implements intelligent timing for room status updates based on event schedules:
The domain layer implements consistent error handling using the Either
pattern and maintains data consistency through dual repository operations.
All booking operations return Either<ErrorResponse, T>
to provide type-safe error handling:
// Example from DeleteBookingUseCase
suspend operator fun invoke(
roomName: String,
eventInfo: EventInfo,
): Either<ErrorResponse, String>
Booking operations follow a consistent pattern of optimistic local updates with network synchronization:
- Immediate Local Update: Update local repository with loading state
- Network Operation: Attempt network operation
-
Result Handling:
- Success: Confirm local changes
- Error: Rollback to original state
The domain layer uses Koin for dependency injection with a centralized module configuration that defines all use case dependencies and their relationships.
The dependency injection follows these patterns:
- Constructor Injection: All use cases receive dependencies through constructors
- Single Instance: All use cases are registered as singletons
- Layered Dependencies: Use cases depend only on repositories and other use cases, never on presentation layer components