Skip to content

Commit 376732d

Browse files
committed
Initial release of nest_core, nest_flutter, and nest_frog packages with comprehensive documentation, feature sets, and integration examples for modular Dart applications and backend services.
1 parent 54dd394 commit 376732d

File tree

13 files changed

+860
-93
lines changed

13 files changed

+860
-93
lines changed

packages/nest_core/CHANGELOG.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1-
## 1.0.0
1+
# Changelog
22

3-
- Initial version.
3+
All notable changes to the `nest_core` package will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.1.0] - 2025-08-02
9+
10+
### Added
11+
- **Core dependency injection system** with ApplicationContainer
12+
- **Module-based architecture** with import/export mechanism
13+
- **Service registration** support for singletons, factories, and lazy singletons
14+
- **Lifecycle hooks** with onModuleInit and onModuleDestroy
15+
- **Access control** with service export restrictions
16+
- **Error handling** with ServiceNotExportedException
17+
- **Circular dependency detection** during module registration
18+
- **Type-safe service resolution** with compile-time checks
19+
- **Named instance support** for service registration
20+
- **Service disposal** with cleanup functions
21+
- **Module context** for debugging and testing
22+
- **Container monitoring** with readiness checks and service availability
23+
24+
### Features
25+
- ApplicationContainer for centralized service management
26+
- Abstract Module base class for organizing services
27+
- Locator interface for type-safe dependency injection
28+
- ModuleContext for tracking module relationships
29+
- Scoped service access with export validation
30+
- Automatic dependency resolution with proper initialization order
31+
32+
### Documentation
33+
- Complete API documentation
34+
- Getting started guide with examples
35+
- Module lifecycle documentation
36+
- Service registration patterns
37+
- Testing guidelines and examples
38+
39+
This is the initial release of nest_core, providing the foundation for building modular Dart applications with dependency injection.

packages/nest_core/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Thorn Chorn
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/nest_core/README.md

Lines changed: 140 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,154 @@
1-
<!--
2-
This README describes the package. If you publish this package to pub.dev,
3-
this README's contents appear on the landing page for your package.
1+
# nest_core
42

5-
For information about how to write a good package README, see the guide for
6-
[writing package pages](https://dart.dev/tools/pub/writing-package-pages).
3+
Core dependency injection and module system for Nest Dart - a NestJS-inspired framework for Dart applications.
74

8-
For general information about developing packages, see the Dart guide for
9-
[creating packages](https://dart.dev/guides/libraries/create-packages)
10-
and the Flutter guide for
11-
[developing packages and plugins](https://flutter.dev/to/develop-packages).
12-
-->
5+
## Features
136

14-
TODO: Put a short description of the package here that helps potential users
15-
know whether this package might be useful for them.
7+
- 🏗️ **Modular Architecture** - Organize code into reusable, self-contained modules
8+
- 💉 **Dependency Injection** - Type-safe service resolution with access control
9+
- 🔄 **Lifecycle Management** - Module initialization and cleanup hooks
10+
- 🔒 **Export Control** - Services are private by default, must be explicitly exported
11+
-**Performance** - Minimal overhead with compile-time safety
1612

17-
## Features
13+
## Installation
14+
15+
Add `nest_core` to your `pubspec.yaml`:
16+
17+
```yaml
18+
dependencies:
19+
nest_core: ^0.1.0
20+
```
21+
22+
## Quick Start
23+
24+
### 1. Create a Service
25+
26+
```dart
27+
class LoggerService {
28+
void log(String message) {
29+
print('[LOG] ${DateTime.now()}: $message');
30+
}
31+
}
32+
```
33+
34+
### 2. Create a Module
35+
36+
```dart
37+
import 'package:nest_core/nest_core.dart';
38+
39+
class CoreModule extends Module {
40+
@override
41+
void providers(Locator locator) {
42+
locator.registerSingleton<LoggerService>(LoggerService());
43+
}
44+
45+
@override
46+
List<Type> get exports => [LoggerService];
47+
}
48+
```
49+
50+
### 3. Initialize Application
51+
52+
```dart
53+
void main() async {
54+
final container = ApplicationContainer();
55+
await container.registerModule(CoreModule());
56+
57+
final logger = container.get<LoggerService>();
58+
logger.log('Application started!');
59+
}
60+
```
61+
62+
## Core Concepts
63+
64+
### ApplicationContainer
1865

19-
TODO: List what your package can do. Maybe include images, gifs, or videos.
66+
The central container that manages modules and services:
2067

21-
## Getting started
68+
```dart
69+
final container = ApplicationContainer();
70+
await container.registerModule(AppModule());
71+
72+
// Get services
73+
final userService = container.get<UserService>();
2274
23-
TODO: List prerequisites and provide or point to information on how to
24-
start using the package.
75+
// Check if ready
76+
if (container.isReady) {
77+
print('Container initialized');
78+
}
79+
```
2580

26-
## Usage
81+
### Module System
2782

28-
TODO: Include short and useful examples for package users. Add longer examples
29-
to `/example` folder.
83+
Modules group related services and define dependencies:
3084

3185
```dart
32-
const like = 'sample';
86+
class UserModule extends Module {
87+
@override
88+
List<Module> get imports => [CoreModule()];
89+
90+
@override
91+
void providers(Locator locator) {
92+
locator.registerSingleton<UserService>(
93+
UserService(locator.get<LoggerService>()),
94+
);
95+
}
96+
97+
@override
98+
List<Type> get exports => [UserService];
99+
}
33100
```
34101

35-
## Additional information
102+
### Service Registration
103+
104+
Multiple registration patterns:
105+
106+
```dart
107+
// Singleton (created once)
108+
locator.registerSingleton<UserService>(UserService());
109+
110+
// Factory (new instance each time)
111+
locator.registerFactory<UserService>(() => UserService());
112+
113+
// Lazy Singleton (created on first access)
114+
locator.registerLazySingleton<UserService>(() => UserService());
115+
```
116+
117+
### Lifecycle Hooks
118+
119+
Initialize and cleanup resources:
120+
121+
```dart
122+
class DatabaseModule extends Module {
123+
@override
124+
Future<void> onModuleInit(Locator locator, ModuleContext context) async {
125+
final db = locator.get<DatabaseService>();
126+
await db.connect();
127+
}
128+
129+
@override
130+
Future<void> onModuleDestroy(Locator locator, ModuleContext context) async {
131+
final db = locator.get<DatabaseService>();
132+
await db.disconnect();
133+
}
134+
}
135+
```
136+
137+
## Platform Integrations
138+
139+
- **[nest_flutter](https://pub.dev/packages/nest_flutter)** - Flutter integration with widget support
140+
- **[nest_frog](https://pub.dev/packages/nest_frog)** - Dart Frog backend integration
141+
142+
## Documentation
143+
144+
- [Getting Started Guide](https://chornthorn.github.io/nest-dart/getting-started)
145+
- [API Reference](https://chornthorn.github.io/nest-dart/api-reference)
146+
- [Examples](https://chornthorn.github.io/nest-dart/examples)
147+
148+
## Contributing
149+
150+
We welcome contributions! Please see our [Contributing Guide](https://github.com/chornthorn/nest-dart/blob/main/CONTRIBUTING.md) for details.
151+
152+
## License
36153

37-
TODO: Tell users more about the package: where to find more information, how to
38-
contribute to the package, how to file issues, what response they can expect
39-
from the package authors, and more.
154+
This project is licensed under the BSD 3-Clause License - see the [LICENSE](LICENSE) file for details.

packages/nest_core/lib/src/core.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'dart:async';
22
import 'package:get_it/get_it.dart';
3-
import 'dart:developer';
43

54
import 'package:logger/web.dart';
65

packages/nest_core/pubspec.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
name: nest_core
2-
description: A starting point for Dart libraries or applications.
2+
description: Core dependency injection and module system for Nest Dart - a NestJS-inspired framework for building modular Dart applications.
33
version: 0.1.0
44
resolution: workspace
5+
homepage: https://chornthorn.github.io/nest-dart
6+
repository: https://github.com/chornthorn/nest-dart
7+
issue_tracker: https://github.com/chornthorn/nest-dart/issues
8+
documentation: https://chornthorn.github.io/nest-dart/core-guide
59

610
environment:
711
sdk: ^3.8.1

packages/nest_flutter/CHANGELOG.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
1-
## 1.0.0
1+
# Changelog
22

3-
- Initial version.
3+
All notable changes to the `nest_flutter` package will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.1.0] - 2025-08-02
9+
10+
### Added
11+
- **ModularApp widget** for easy Flutter app initialization
12+
- **ApplicationContainerProvider** for widget tree integration
13+
- **ApplicationContainerNotifier** with ChangeNotifier support
14+
- **Static Modular API** for global service access
15+
- **Context-based service resolution** with BuildContext integration
16+
- **Reactive service support** with ChangeNotifier integration
17+
- **Widget testing utilities** for testing with dependency injection
18+
- **Multi-platform support** for all Flutter platforms
19+
20+
### Features
21+
- ModularApp widget wraps your app with dependency injection
22+
- ApplicationContainerProvider provides container to widget tree
23+
- Modular class with static methods for service access
24+
- Support for both static and context-based service resolution
25+
- Integration with Flutter's reactive system via ChangeNotifier
26+
- Proper disposal and cleanup of services
27+
- Testing support with mock modules
28+
29+
### Widget Integration
30+
- Easy service access from any widget
31+
- Automatic container initialization
32+
- Proper lifecycle management
33+
- Memory leak prevention with proper disposal
34+
35+
### Documentation
36+
- Complete Flutter integration guide
37+
- Widget usage examples
38+
- Testing patterns and examples
39+
- Performance optimization tips
40+
41+
This is the initial release of nest_flutter, providing seamless integration between Nest Dart's dependency injection system and Flutter's widget architecture.

packages/nest_flutter/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Thorn Chorn
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)