- Home
- Skills
- Kaakati
- Rails Enterprise Dev
- Core Layer Patterns
core-layer-patterns_skill
- Shell
6
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill kaakati/rails-enterprise-dev --skill core-layer-patterns- SKILL.md14.9 KB
Overview
This skill bundles core-layer patterns for Flutter Clean Architecture: base failure and exception types, reusable utilities, environment and theme configuration, and a simple dependency injection setup. It focuses on pure Dart building blocks that can be shared across domain, data, and presentation layers. The goal is to standardize error handling, input validation, small helpers, and app-wide configuration for scalable apps.
How this skill works
It provides Failure classes returned by use cases and Exception classes thrown by data sources, with clear mapping from exceptions to failures inside repositories. Utility extension methods and validators reduce boilerplate in forms and common value checks. AppConfig and ThemeConfig factories centralize environment and theme choices. A lightweight dependency injection container registers core services, HTTP client, storage, configs, and placeholders for data sources, repositories, and use cases.
When to use it
- When building apps with Clean Architecture to enforce consistent error semantics across layers.
- When you need a minimal, pure-Dart core with no Flutter-specific dependencies (except optional UI helpers).
- When you want reusable validators and extensions to reduce form and string/DateTime boilerplate.
- When you need environment-aware configuration and consistent theming across builds.
- When you want a simple DI initialization flow to organize service registration.
Best practices
- Return Failure objects from use cases (Either<Failure, T>) rather than throwing in domain code.
- Throw Exceptions in data sources and convert them to Failures in repositories with precise mapping (ServerException -> ServerFailure, etc.).
- Keep core layer free of UI logic; expose only pure Dart utilities and configuration factories.
- Compose validators for form fields to make reusable, testable validation rules.
- Register only long-lived core dependencies as permanent; use lazy registration for data sources and use cases to speed startup.
Example use cases
- Implement Login use case that returns Either<Failure, User> and maps remote exceptions to Failure types in repository implementation.
- Use Validators.compose for form fields combining required, email, and min-length rules in a single validator function.
- Swap AppConfig.factory to development or production in main to change API base URL, timeouts, and logging without code changes.
- Call DependencyInjection.init() in main to register http.Client, GetStorage, and application config, then lazily register data sources and repositories.
- Use StringExtensions.capitalize and ContextExtensions.showSnackBar to reduce UI helper code and improve readability.
FAQ
Catch specific exceptions in repositories and return corresponding Failure types (e.g., ServerException -> ServerFailure, NetworkException -> NetworkFailure). Provide a generic ServerFailure fallback for unexpected errors.
Is the core layer Flutter-dependent?
No. Core is primarily pure Dart. Only small UI helper extensions reference Flutter (BuildContext, ThemeData) and can be isolated if you want a strictly platform-agnostic core.