syzygy_foundation_flutter 1.2.0
syzygy_foundation_flutter: ^1.2.0 copied to clipboard
Foundational contracts, primitives, and shared types for the Syzygy Flutter ecosystem
syzygy-foundation-flutter #
The root layer of the Syzygy ecosystem — providing SharedTypes, base protocols, and shared contracts that every peer layer builds on.
About #
syzygy-foundation-flutter is the base layer every other Syzygy Flutter library depends on. It defines the abstract classes that Services implements, the value types that UI and Core consume, and the error types the whole stack shares. Nothing in Foundation has behaviour beyond property storage — no network calls, no platform APIs, no business logic. Swap any implementation in Services or Core by extending these contracts; Foundation never needs to change.
Role in the Syzygy Ecosystem #
syzygy-foundation-flutter is the root layer — the only dependency shared by all peer layers. It depends on nothing. Every peer layer (UI, Core, Services, AI) depends on Foundation and nothing else.
Full ecosystem architecture: ecosystem-fragment.md
Shared Contracts #
Foundation defines the shared contracts that all peer layers consume. These contracts are the abstraction layer that allows UI, Core, Services and AI to each depend on Foundation without depending on each other.
NetworkClientProtocol— abstracts HTTP networking so any peer layer can make network requests without depending on a concrete implementation.syzygy-services-flutterprovides the concrete Dio implementation.AuthProvider— abstracts authentication and token management.syzygy-services-flutterprovides the concrete OAuth and flutter_secure_storage implementations.StorageProvider— abstracts local persistence.syzygy-services-flutterprovides the concrete flutter_secure_storage implementation.LoggerProtocol— abstracts logging and observability so all peer layers can log without depending on a specific logging framework.
These contracts are currently defined as planned interfaces. Concrete implementations will ship with
syzygy-services-flutterin Phase 2 of the ecosystem roadmap.
Release Process #
Releases follow the Syzygy tag-push release flow:
- Create a
release/X.X.Xbranch - Bump the version in
syzygy.yml,pubspec.yaml, the README badge, andCHANGELOG.md - Open a PR to
mainand wait for CI to pass - Merge the PR
- Push the tag:
git tag X.X.Xandgit push origin X.X.X - The tag push triggers the org-level release workflow which validates
syzygy.ymlmatches the tag, extracts the CHANGELOG entry, publishes to pub.dev, and creates the GitHub Release
For the full release standard see the Syzygy-Hub/.github release standard.
Platforms #
| Platform | Min Version | Package Manager | Status |
|---|---|---|---|
| Flutter | 3.10+ | pub.dev | ✅ Supported |
Requirements #
- Flutter 3.10+
- Dart 3.0+
Installation #
dependencies:
syzygy_foundation_flutter: ^1.2.0
// Runtime
import 'package:syzygy_foundation_flutter/syzygy_foundation_flutter.dart';
// Test support (test files only)
import 'package:syzygy_foundation_flutter/syzygy_foundation_flutter_testing.dart';
Architecture #
SyzygyFoundation exposes two libraries:
- syzygy_foundation_flutter.dart — runtime exports. Import in your app and library source files.
- syzygy_foundation_flutter_testing.dart — test support. Import in test files only.
Depends on: nothing
Used by: syzygy-ui-flutter, syzygy-core-flutter, syzygy-services-flutter, syzygy-ai-flutter
For the full ecosystem architecture see syzygy-ecosystem.md.
API #
Primitives #
SyzygyID<T>— phantom-typed identifier preventing accidental ID mixingSyzygyPage<T>/PaginationRequest— paginated data structuresSyzygyTimestamp/SyzygyDuration/TimeProvider— cross-platform time primitivesValidationResult/ValidationRule— validation contract and result type
Contracts #
NetworkClientProtocol/NetworkRequest/NetworkResponse— networking contractStorageProvider/StorageKey— type-safe storage contractAuthProvider/AuthToken/AuthState— authentication contractAnalyticsProvider/AnalyticsEvent— analytics contractLoggerProtocol/LogLevel/LogEntry— logging contractConnectivityProvider/ConnectivityState— connectivity contract
Shared Types #
SyzygyEnvironment— debug / staging / productionSyzygyConfiguration— app configuration contractSyzygyBuildInfo— consumer-injected build metadataSyzygyVersion— semantic version with comparison support
Errors #
SyzygyError— base error abstract classSyzygyErrorCode— typed, extensible error codesSyzygyErrorSeverity— error severity levels
Testing Support #
Import syzygy_foundation_flutter_testing.dart in test files only.
MockLogger,MockConnectivityProvider,MockAuthProvider,MockStorageProvider,MockNetworkClientSpyAnalyticsProviderFixtureProvider,FixedTimeProvider
Usage #
Implementing a contract #
import 'package:syzygy_foundation_flutter/syzygy_foundation_flutter.dart';
import 'package:http/http.dart' as http;
class HttpNetworkClient extends NetworkClientProtocol {
@override
Future<NetworkResponse> execute(NetworkRequest request) async {
final response = await http.get(Uri.parse(request.url));
return NetworkResponse(
statusCode: response.statusCode,
data: response.bodyBytes,
headers: response.headers,
);
}
}
Using a primitive #
import 'package:syzygy_foundation_flutter/syzygy_foundation_flutter.dart';
class User {}
class Post {}
void main() {
final userId = SyzygyID<User>.generate();
final postId = SyzygyID<Post>.generate();
print(userId == postId); // false — distinct phantom types
}
Using test support #
import 'package:syzygy_foundation_flutter_testing/syzygy_foundation_flutter_testing.dart';
import 'package:test/test.dart';
void main() {
test('execute returns queued response', () async {
final client = MockNetworkClient();
client.enqueue(NetworkResponse(statusCode: 200, data: Uint8List(0), headers: {}));
final result = await client.execute(NetworkRequest(url: 'https://example.com'));
expect(result.statusCode, equals(200));
});
}
Platform Notes #
- Async pattern:
Future SyzygyErroris an abstract class implementingExceptionConnectivityProvider: controlled — passisOfflineprop (no first-party network detection)SyzygyBuildInfo: consumer-injected — populate at app startup
Contributing #
Contributions are welcome. Please follow the Syzygy engineering standards when submitting pull requests.
License #
MIT — see LICENSE