Layer Overview
Location:~/workspace/source/Chapi/Application/
Responsibilities:
- Implement use cases (user stories)
- Orchestrate domain entities and services
- Define application-specific interfaces
- Coordinate transactions and workflows
- Transform data between layers
- ✅ Depends on Domain Layer (entities, interfaces)
- ❌ No dependencies on Infrastructure or Presentation
Architecture Pattern
Chapi uses the Use Case pattern to organize application logic:Use Cases
Use cases represent single user actions or business operations.Git Use Cases
Project Use Cases
AI Use Cases
Application Services
Application services provide cross-cutting functionality for use cases.Application Interfaces
Interfaces defined at the application level for infrastructure to implement.Application/Interfaces/Workspace/IWorkspaceService.cs
Use Case Categories
Git Operations
- CommitChangesUseCase
- PushChangesUseCase
- LoadHistoryUseCase
- SwitchBranchUseCase
- StashChangesUseCase
Project Management
- CreateProjectUseCase
- LoadProjectsUseCase
- SwitchProjectUseCase
- DeployProjectReleaseUseCase
AI Features
- SendChatMessageUseCase
- GenerateCommitMessageUseCase
- GenerateSqlQueryUseCase
Code Generation
- GenerateModuleUseCase
- AddApiControllerUseCase
- AddDependencyInjectionUseCase
Dependency Injection
Use cases are registered as transient services:Request/Response Pattern
Many use cases follow a Request/Response pattern:- Type-safe parameters
- Immutable requests (using records)
- Easy to test
- Self-documenting API
Testing Use Cases
Best Practices
Single Responsibility
Single Responsibility
Each use case handles one user action or business operation.
Validation First
Validation First
Always validate inputs before calling domain services:
Progress Reporting
Progress Reporting
For long-running operations, provide progress callbacks:
Use Result Pattern
Use Result Pattern
Return
Result<T> instead of throwing exceptions for expected failures.Related Documentation
Domain Layer
Core entities and interfaces
Infrastructure Layer
Implementation of services
Presentation Layer
ViewModels consuming use cases