Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Architecture Overview

Efision follows a 5-layer Clean Architecture pattern where business logic is completely separated from infrastructure concerns.

Layer Diagram

CLI (commands/) → Services → Domain (Entities + Repositories) ← Infrastructure (sqlserver/) → Database
LayerLocationResponsibility
CLIcrates/cli/Command parsing, user interaction, output formatting
Servicescrates/core/src/services/Business logic, orchestration (database-agnostic)
Domaincrates/core/src/domain/Entities, DTOs, Repository trait definitions
Infrastructurecrates/core/src/infrastructure/SQL Server implementations of repository traits
Configcrates/core/src/infrastructure/config.rsDatabase connection, region resolution

Key Principle

Services are generic over repository traits:

#![allow(unused)]
fn main() {
struct WheelService<R: WheelRepository> {
    repo: R,
}
}

This means the business logic never depends on SQL Server directly. To switch databases, only the infrastructure layer changes.

Cargo Workspace

The project is split into two crates:

CratePackageRole
crates/core/efision-coreShared library: domain, services, infrastructure
crates/cli/efision-cliBinary: CLI commands, user interaction

This separation allows future crates (e.g., crates/api/ for a REST API) to share the same business logic.

Business Domains

DomainEntitiesRepositoryService
Productsdomain/entities/products/infrastructure/sqlserver/products/services/products/
Salesdomain/entities/sales/infrastructure/sqlserver/sales/services/sales/
Warehousedomain/entities/warehouse/infrastructure/sqlserver/warehouse/services/warehouse/
Customersdomain/entities/customers/infrastructure/sqlserver/customers/services/customers/

Database Stats

StatValue
Tables in schema305
Entity files64 (across 4 business domains)
Repository traits5