Architecture Overview
The CO2 Asset Management platform is built using Domain-Driven Design (DDD) principles combined with Clean Architecture and CQRS patterns.
Layered Architecture
Section titled “Layered Architecture”┌─────────────────────────────────────────────────────────────┐│ Presentation Layer ││ (Flutter UI, Riverpod, GoRouter) │├─────────────────────────────────────────────────────────────┤│ Application Orchestration ││ (Commands, Queries, Event Handlers, Workflows) │├─────────────────────────────────────────────────────────────┤│ Domain Layer ││ (Aggregates, Events, Value Objects per Bounded Context) │├─────────────────────────────────────────────────────────────┤│ Infrastructure Layer ││ (Firebase, Local Storage, Sync Engine) │└─────────────────────────────────────────────────────────────┘Core Layer (Shared Kernel)
Section titled “Core Layer (Shared Kernel)”The Core Layer defines semantically stable, cross-cutting value objects and contracts shared between bounded contexts:
- Identifiers:
AssetId,EstateId,UserIdwith strong typing - Roles & Scopes: Centralized permission types
- Value Objects:
Timestamp,EmailAddress,GeoCoordinate - Interfaces:
Identifiable<T>, common error types
Domain Layer
Section titled “Domain Layer”Each bounded context contains:
- Event-Sourced Aggregates: Emit domain events for all state changes
- No Cross-Context Ownership: Each context owns its data
- Typed Composition: Capabilities via separate bounded contexts
Application Orchestration
Section titled “Application Orchestration”Coordinates business operations:
- Command Handlers: Execute write operations
- Query Handlers: Read-only data access
- Event Handlers: React to domain events
- Workflows: Multi-step business processes
Presentation Layer
Section titled “Presentation Layer”Flutter UI using:
- Riverpod: State management (migrating from GetX)
- GoRouter: Navigation
- Notifiers: Per-screen state management
Event Sourcing with Nomos
Section titled “Event Sourcing with Nomos”See Nomos Framework for details on:
- Intents (user commands)
- Directives (atomic mutations)
- Events (audit trail)
- Workspaces and Timelines
Package Structure
Section titled “Package Structure”The admin app is split into three packages:
| Package | Purpose |
|---|---|
apps/admin | Entry point, tests, assets |
apps/admin_frontend | Views, components, state management |
apps/admin_composition | Domain registration and wiring |