@venizia/ignis-docs 0.0.1-8 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/LICENSE.md +1 -0
  2. package/package.json +2 -2
  3. package/wiki/changelogs/2025-12-16-initial-architecture.md +145 -0
  4. package/wiki/changelogs/2025-12-16-model-repo-datasource-refactor.md +300 -0
  5. package/wiki/changelogs/2025-12-17-refactor.md +90 -0
  6. package/wiki/changelogs/2025-12-18-performance-optimizations.md +130 -0
  7. package/wiki/changelogs/2025-12-18-repository-validation-security.md +249 -0
  8. package/wiki/changelogs/index.md +33 -0
  9. package/wiki/changelogs/planned-transaction-support.md +216 -0
  10. package/wiki/changelogs/template.md +123 -0
  11. package/wiki/get-started/5-minute-quickstart.md +1 -1
  12. package/wiki/get-started/best-practices/api-usage-examples.md +12 -10
  13. package/wiki/get-started/best-practices/architectural-patterns.md +2 -2
  14. package/wiki/get-started/best-practices/common-pitfalls.md +7 -5
  15. package/wiki/get-started/best-practices/contribution-workflow.md +2 -0
  16. package/wiki/get-started/best-practices/data-modeling.md +91 -40
  17. package/wiki/get-started/best-practices/security-guidelines.md +3 -1
  18. package/wiki/get-started/building-a-crud-api.md +63 -78
  19. package/wiki/get-started/core-concepts/application.md +72 -3
  20. package/wiki/get-started/core-concepts/bootstrapping.md +566 -0
  21. package/wiki/get-started/core-concepts/components.md +4 -2
  22. package/wiki/get-started/core-concepts/controllers.md +14 -14
  23. package/wiki/get-started/core-concepts/persistent.md +383 -431
  24. package/wiki/get-started/core-concepts/services.md +21 -27
  25. package/wiki/get-started/quickstart.md +1 -1
  26. package/wiki/references/base/bootstrapping.md +789 -0
  27. package/wiki/references/base/components.md +1 -1
  28. package/wiki/references/base/controllers.md +40 -16
  29. package/wiki/references/base/datasources.md +195 -33
  30. package/wiki/references/base/dependency-injection.md +98 -5
  31. package/wiki/references/base/models.md +398 -28
  32. package/wiki/references/base/repositories.md +475 -22
  33. package/wiki/references/base/services.md +2 -2
  34. package/wiki/references/components/authentication.md +228 -10
  35. package/wiki/references/components/health-check.md +1 -1
  36. package/wiki/references/components/index.md +1 -1
  37. package/wiki/references/components/swagger.md +1 -1
  38. package/wiki/references/helpers/error.md +2 -2
  39. package/wiki/references/helpers/inversion.md +8 -3
  40. package/wiki/references/src-details/boot.md +379 -0
  41. package/wiki/references/src-details/core.md +8 -7
  42. package/wiki/references/src-details/inversion.md +4 -4
  43. package/wiki/references/utilities/request.md +16 -7
@@ -0,0 +1,379 @@
1
+ # @venizia/ignis-boot
2
+
3
+ > **Package**: `@venizia/ignis-boot`
4
+ > **Purpose**: Application bootstrapping system with artifact auto-discovery
5
+ > **Version**: 0.0.0
6
+
7
+ ## Overview
8
+
9
+ The `@venizia/ignis-boot` package provides a powerful bootstrapping system that automatically discovers and loads application artifacts (controllers, services, repositories, datasources) during application startup. It eliminates the need for manual registration of each artifact, making application setup cleaner and more maintainable.
10
+
11
+ ## Key Concepts
12
+
13
+ ### Boot Phases
14
+
15
+ The boot process consists of three phases executed in order:
16
+
17
+ 1. **Configure** - Booters configure their discovery patterns
18
+ 2. **Discover** - Booters scan filesystem for matching artifacts
19
+ 3. **Load** - Booters load classes and bind them to the application container
20
+
21
+ ### Artifacts
22
+
23
+ An artifact is any application component that can be auto-discovered:
24
+ - **Controllers** - REST/API endpoint handlers
25
+ - **Services** - Business logic layer
26
+ - **Repositories** - Data access layer
27
+ - **Datasources** - Database connections
28
+
29
+ ### Booters
30
+
31
+ Booters are specialized classes that handle discovery and loading of specific artifact types. Each booter:
32
+ - Defines default discovery patterns (directories, file extensions)
33
+ - Scans filesystem for matching files
34
+ - Loads classes from discovered files
35
+ - Binds loaded classes to application container
36
+
37
+ ## Core Components
38
+
39
+ ### Bootstrapper
40
+
41
+ Orchestrates the entire boot process.
42
+
43
+ | Feature | Description |
44
+ |---------|-------------|
45
+ | **Phase Execution** | Runs configure → discover → load phases |
46
+ | **Booter Discovery** | Automatically finds all registered booters |
47
+ | **Error Handling** | Catches and reports errors during boot |
48
+ | **Performance Tracking** | Measures time taken for each phase |
49
+
50
+ **Usage:**
51
+
52
+ ```typescript
53
+ import { Bootstrapper, IBootExecutionOptions } from '@venizia/ignis-boot';
54
+
55
+ const bootstrapper = app.get<Bootstrapper>({ key: 'bootstrapper' });
56
+ await bootstrapper.boot({
57
+ phases: ['configure', 'discover', 'load'], // optional, default: all phases
58
+ booters: ['ControllerBooter', 'ServiceBooter'], // optional, default: all booters
59
+ });
60
+ ```
61
+
62
+ ### BaseArtifactBooter
63
+
64
+ Abstract base class for creating custom booters.
65
+
66
+ | Method | Phase | Description |
67
+ |--------|-------|-------------|
68
+ | `configure()` | Configure | Sets up discovery patterns |
69
+ | `discover()` | Discover | Scans filesystem for artifacts |
70
+ | `load()` | Load | Loads classes and binds to container |
71
+ | `getPattern()` | - | Generates glob pattern for file discovery |
72
+ | `bind()` | - | Abstract method - implement to bind loaded classes |
73
+
74
+ **Custom Booter Example:**
75
+
76
+ ```typescript
77
+ import { BaseArtifactBooter, IBooterOptions } from '@venizia/ignis-boot';
78
+ import { inject } from '@venizia/ignis-inversion';
79
+
80
+ export class CustomBooter extends BaseArtifactBooter {
81
+ constructor(
82
+ @inject({ key: '@app/project_root' }) root: string,
83
+ @inject({ key: '@app/instance' }) private app: IApplication,
84
+ @inject({ key: '@app/boot-options' }) bootOptions: IBootOptions,
85
+ ) {
86
+ super({
87
+ scope: CustomBooter.name,
88
+ root,
89
+ artifactOptions: bootOptions.custom ?? {}
90
+ });
91
+ }
92
+
93
+ protected getDefaultDirs(): string[] {
94
+ return ['custom'];
95
+ }
96
+
97
+ protected getDefaultExtensions(): string[] {
98
+ return ['.custom.js'];
99
+ }
100
+
101
+ protected async bind(): Promise<void> {
102
+ for (const cls of this.loadedClasses) {
103
+ this.app.bind({ key: `custom.${cls.name}` }).toClass(cls);
104
+ }
105
+ }
106
+ }
107
+ ```
108
+
109
+ ### Built-in Booters
110
+
111
+ #### ControllerBooter
112
+
113
+ Auto-discovers and registers controllers.
114
+
115
+ | Configuration | Default Value |
116
+ |---------------|---------------|
117
+ | **Directories** | `['controllers']` |
118
+ | **Extensions** | `['.controller.js']` |
119
+ | **Binding Pattern** | `controllers.{ClassName}` |
120
+
121
+ #### ServiceBooter
122
+
123
+ Auto-discovers and registers services.
124
+
125
+ | Configuration | Default Value |
126
+ |---------------|---------------|
127
+ | **Directories** | `['services']` |
128
+ | **Extensions** | `['.service.js']` |
129
+ | **Binding Pattern** | `services.{ClassName}` |
130
+
131
+ #### RepositoryBooter
132
+
133
+ Auto-discovers and registers repositories.
134
+
135
+ | Configuration | Default Value |
136
+ |---------------|---------------|
137
+ | **Directories** | `['repositories']` |
138
+ | **Extensions** | `['.repository.js']` |
139
+ | **Binding Pattern** | `repositories.{ClassName}` |
140
+
141
+ #### DatasourceBooter
142
+
143
+ Auto-discovers and registers datasources.
144
+
145
+ | Configuration | Default Value |
146
+ |---------------|---------------|
147
+ | **Directories** | `['datasources']` |
148
+ | **Extensions** | `['.datasource.js']` |
149
+ | **Binding Pattern** | `datasources.{ClassName}` |
150
+
151
+ ### BootMixin
152
+
153
+ Mixin that adds bootable capability to any application.
154
+
155
+ **Features:**
156
+ - Automatically binds default booters
157
+ - Exposes `boot()` method
158
+ - Configurable via `bootOptions`
159
+
160
+ **Usage:**
161
+
162
+ ```typescript
163
+ import { BootMixin } from '@venizia/ignis-boot';
164
+ import { Container } from '@venizia/ignis-inversion';
165
+
166
+ class MyApp extends BootMixin(Container) {
167
+ bootOptions = {
168
+ controllers: {
169
+ dirs: ['private-controllers', 'public-controllers'],
170
+ extensions: ['.controller.js', '.controller.ts']
171
+ },
172
+ services: {
173
+ isNested: true // scan subdirectories
174
+ }
175
+ };
176
+ }
177
+
178
+ const app = new MyApp();
179
+ await app.boot();
180
+ ```
181
+
182
+ ## Boot Options
183
+
184
+ Configure artifact discovery per artifact type.
185
+
186
+ ### IArtifactOptions
187
+
188
+ | Property | Type | Default | Description |
189
+ |----------|------|---------|-------------|
190
+ | `dirs` | `string[]` | Varies | Directories to scan |
191
+ | `extensions` | `string[]` | Varies | File extensions to match |
192
+ | `isNested` | `boolean` | `true` | Scan subdirectories |
193
+ | `glob` | `string` | - | Custom glob pattern (overrides dirs/extensions) |
194
+
195
+ ### IBootOptions
196
+
197
+ ```typescript
198
+ interface IBootOptions {
199
+ controllers?: IArtifactOptions;
200
+ services?: IArtifactOptions;
201
+ repositories?: IArtifactOptions;
202
+ datasources?: IArtifactOptions;
203
+ [artifactType: string]: IArtifactOptions | undefined;
204
+ }
205
+ ```
206
+
207
+ **Example Configuration:**
208
+
209
+ ```typescript
210
+ const bootOptions: IBootOptions = {
211
+ controllers: {
212
+ dirs: ['controllers/private', 'controllers/public'],
213
+ extensions: ['.controller.js'],
214
+ isNested: true
215
+ },
216
+ repositories: {
217
+ glob: 'data-access/**/*.repository.js' // custom pattern
218
+ },
219
+ services: {
220
+ dirs: ['services'],
221
+ extensions: ['.service.js', '.service.ts'],
222
+ isNested: false // only scan root level
223
+ }
224
+ };
225
+ ```
226
+
227
+ ## Integration with Core
228
+
229
+ ### BaseApplication Integration
230
+
231
+ Boot system is integrated into `BaseApplication` via `IBootableApplication` interface:
232
+
233
+ ```typescript
234
+ export abstract class BaseApplication
235
+ extends AbstractApplication
236
+ implements IRestApplication, IBootableApplication {
237
+
238
+ bootOptions?: IBootOptions;
239
+
240
+ boot(): Promise<IBootReport> {
241
+ const bootstrapper = this.get<Bootstrapper>({ key: 'bootstrapper' });
242
+ return bootstrapper.boot({});
243
+ }
244
+ }
245
+ ```
246
+
247
+ ### Automatic Initialization
248
+
249
+ If `bootOptions` is defined in application config, boot runs automatically during `initialize()`:
250
+
251
+ ```typescript
252
+ override async initialize() {
253
+ if (this.configs.bootOptions) {
254
+ // Bind boot infrastructure
255
+ this.bind({ key: '@app/boot-options' }).toValue(this.bootOptions ?? {});
256
+ this.bind({ key: 'bootstrapper' }).toClass(Bootstrapper);
257
+
258
+ // Register default booters
259
+ this.booter(DatasourceBooter);
260
+ this.booter(RepositoryBooter);
261
+ this.booter(ServiceBooter);
262
+ this.booter(ControllerBooter);
263
+
264
+ // Execute boot
265
+ await this.boot();
266
+ }
267
+
268
+ // ... rest of initialization
269
+ }
270
+ ```
271
+
272
+ ## Utilities
273
+
274
+ ### discoverFiles
275
+
276
+ Discovers files matching a glob pattern.
277
+
278
+ ```typescript
279
+ const files = await discoverFiles({
280
+ pattern: 'controllers/**/*.controller.js',
281
+ root: '/path/to/project'
282
+ });
283
+ // Returns: ['/path/to/project/controllers/user.controller.js', ...]
284
+ ```
285
+
286
+ ### loadClasses
287
+
288
+ Loads class constructors from files.
289
+
290
+ ```typescript
291
+ const classes = await loadClasses({
292
+ files: ['/path/to/file1.js', '/path/to/file2.js'],
293
+ root: '/path/to/project'
294
+ });
295
+ // Returns: [UserController, ProductController, ...]
296
+ ```
297
+
298
+ ### isClass
299
+
300
+ Type guard to check if value is a class constructor.
301
+
302
+ ```typescript
303
+ if (isClass(exported)) {
304
+ // exported is TClass<any>
305
+ }
306
+ ```
307
+
308
+ ## Complete Example
309
+
310
+ ```typescript
311
+ import { BaseApplication, IApplicationConfigs } from '@venizia/ignis';
312
+ import { IBootOptions } from '@venizia/ignis-boot';
313
+
314
+ export const appConfigs: IApplicationConfigs = {
315
+ name: 'MyApp',
316
+ bootOptions: {
317
+ controllers: {
318
+ dirs: ['controllers'],
319
+ extensions: ['.controller.js'],
320
+ isNested: true
321
+ },
322
+ services: {
323
+ dirs: ['services'],
324
+ extensions: ['.service.js'],
325
+ isNested: true
326
+ },
327
+ repositories: {
328
+ dirs: ['repositories'],
329
+ extensions: ['.repository.js']
330
+ },
331
+ datasources: {
332
+ dirs: ['datasources'],
333
+ extensions: ['.datasource.js']
334
+ }
335
+ }
336
+ };
337
+
338
+ export class MyApp extends BaseApplication {
339
+ constructor() {
340
+ super(appConfigs);
341
+ }
342
+ }
343
+
344
+ // Boot runs automatically during initialize()
345
+ const app = new MyApp();
346
+ await app.start(); // Calls initialize() which triggers boot
347
+ ```
348
+
349
+ ## Benefits
350
+
351
+ | Benefit | Description |
352
+ |---------|-------------|
353
+ | **Auto-discovery** | No manual registration of controllers/services/repositories |
354
+ | **Convention-based** | Follow naming conventions, framework handles the rest |
355
+ | **Flexible** | Customize discovery patterns per artifact type |
356
+ | **Extensible** | Create custom booters for new artifact types |
357
+ | **Performance** | Track boot time per phase |
358
+ | **Developer Experience** | Focus on writing code, not wiring infrastructure |
359
+
360
+ ## When to Use
361
+
362
+ ✅ **Use Boot System When:**
363
+ - Building applications with many controllers/services/repositories
364
+ - Want convention-over-configuration approach
365
+ - Need consistent artifact registration across projects
366
+ - Building modular applications with clear folder structure
367
+
368
+ ❌ **Manual Registration When:**
369
+ - Very small applications (< 5 artifacts)
370
+ - Need fine-grained control over registration order
371
+ - Dynamic artifact registration based on runtime conditions
372
+ - Artifacts don't follow file naming conventions
373
+
374
+ ## Related Documentation
375
+
376
+ - [Bootstrapping Concepts](/get-started/core-concepts/bootstrapping.md)
377
+ - [Application Guide](/get-started/core-concepts/application.md)
378
+ - [Dependency Injection](/references/base/dependency-injection.md)
379
+ - [Core Package](/references/src-details/core.md)
@@ -12,7 +12,7 @@ Detailed breakdown of the core framework directory structure.
12
12
  |-----------|---------------|----------------|
13
13
  | **`base`** | Core architecture | Applications, Controllers, Repositories, Services, Models |
14
14
  | **`components`** | Pluggable features | Auth, Swagger, HealthCheck, SocketIO |
15
- | **`helpers`** | Utilities | Re-exports from `@venizia/ignis-helpers` |
15
+ | **`helpers`** | Utilities | DI (extended), Re-exports from `@venizia/ignis-helpers` |
16
16
  | **`common`** | Shared code | Constants, bindings, types, environments |
17
17
  | **`utilities`** | Pure functions | Crypto, date, parse, performance, schema |
18
18
  | **`__tests__`** | Tests | Integration and E2E tests |
@@ -27,7 +27,7 @@ Top-level breakdown of the `src` directory:
27
27
  | **`base`** | The core building blocks and abstract classes of the framework. This is where the fundamental architecture is defined. |
28
28
  | **`common`** | A directory for code that is shared and used across the entire framework. |
29
29
  | **`components`** | A collection of ready-to-use, high-level components that can be plugged into an Ignis application. |
30
- | **`helpers`** | Re-exports all modules from the dedicated `@venizia/ignis-helpers` package. |
30
+ | **`helpers`** | Contains core extensions (like Inversion) and re-exports from `@venizia/ignis-helpers`. |
31
31
  | **`utilities`** | A collection of pure, standalone utility functions. |
32
32
 
33
33
  ---
@@ -52,8 +52,8 @@ This is the foundational layer of Ignis, defining the core architecture and abst
52
52
  | File/Folder | Purpose/Key Details |
53
53
  | :------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
54
54
  | `abstract.ts` | Defines `AbstractApplication`, the base class for Ignis applications. Handles core server setup (Hono instance, runtime detection for Bun/Node.js), environment validation, and route inspection. Mandates abstract methods for middleware setup and configuration. |
55
- | `base.ts` | Extends `AbstractApplication` to provide `BaseApplication`, implementing common functionalities like component, controller, service, repository, and datasource registration. Includes default middleware registration (e.g., error handling, favicon, request tracking) and startup information logging. |
56
- | `types.ts` | Contains interfaces for application configurations (`IApplicationConfigs`), application information (`IApplicationInfo`), and various middleware options (e.g., `ICORSOptions`, `ICSRFOptions`). |
55
+ | `base.ts` | Extends `AbstractApplication` to provide `BaseApplication`, implementing common functionalities like component, controller, service, repository, and datasource registration. Includes default middleware registration (e.g., error handling, favicon, request tracking) and startup information logging. Integrates with `@venizia/ignis-boot` for automatic artifact discovery when `bootOptions` is configured. |
56
+ | `types.ts` | Contains interfaces for application configurations (`IApplicationConfigs`), application information (`IApplicationInfo`), and various middleware options (e.g., `ICORSOptions`, `ICSRFOptions`). Now includes `IBootableApplication` interface for boot system integration. |
57
57
 
58
58
  #### `base/components`
59
59
 
@@ -237,11 +237,12 @@ Generates interactive OpenAPI documentation.
237
237
 
238
238
  ### `helpers`
239
239
 
240
- The `helpers` directory has been refactored into its own dedicated package, `@venizia/ignis-helpers`, to improve modularity. The `src/helpers` directory within the core framework now simply re-exports all modules from this new package.
240
+ Contains framework extensions and utilities.
241
241
 
242
242
  | File/Folder | Purpose/Key Details |
243
243
  | :---------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------- |
244
- | `index.ts` | Re-exports all helpers from the `@venizia/ignis-helpers` package, making them available through the core framework for backward compatibility and convenience. |
244
+ | `inversion/`| **Framework DI Extension**: Extends `@venizia/ignis-inversion` to provide application-aware dependency injection with logging and enhanced metadata support. |
245
+ | `index.ts` | Re-exports extensions and utilities from `@venizia/ignis-helpers`. |
245
246
 
246
247
  ### `utilities`
247
248
 
@@ -260,4 +261,4 @@ This directory contains pure, standalone utility functions that perform common,
260
261
 
261
262
  ---
262
263
 
263
- This detailed breakdown illustrates the modular and layered design of the Ignis framework, emphasizing its extensibility and adherence to robust architectural patterns.
264
+ This detailed breakdown illustrates the modular and layered design of the Ignis framework, emphasizing its extensibility and adherence to robust architectural patterns.
@@ -309,22 +309,22 @@ if (cache) {
309
309
 
310
310
  ---
311
311
 
312
- ## Relationship with @venizia/ignis-helpers
312
+ ## Integration with Framework
313
313
 
314
- The `@venizia/ignis-helpers` package extends this base inversion package with:
314
+ The core `@venizia/ignis` package extends this base inversion package with:
315
315
 
316
316
  - **ApplicationLogger integration**: Container with structured logging
317
317
  - **Framework-specific metadata**: Controllers, models, repositories, data sources
318
318
  - **Decorator implementations**: `@inject`, `@controller`, `@service`, etc.
319
319
 
320
- For framework usage, import from `@venizia/ignis-helpers` or `@venizia/ignis`. For standalone DI container usage, import directly from `@venizia/ignis-inversion`.
320
+ For framework usage, import from `@venizia/ignis`. For standalone DI container usage, import directly from `@venizia/ignis-inversion`.
321
321
 
322
322
  ```typescript
323
323
  // Standalone usage
324
324
  import { Container, Binding } from '@venizia/ignis-inversion';
325
325
 
326
326
  // Framework usage (includes logging and framework metadata)
327
- import { Container, inject, service } from '@venizia/ignis-helpers';
327
+ import { Container, inject, service } from '@venizia/ignis';
328
328
  ```
329
329
 
330
330
  ---
@@ -31,7 +31,7 @@ The function returns a `Promise` that resolves to an array of `IParsedFile` obje
31
31
  Here is an example of how to use `parseMultipartBody` in a controller to handle a file upload.
32
32
 
33
33
  ```typescript
34
- import { BaseController, controller, ... } from '@venizia/ignis';
34
+ import { BaseController, controller, HTTP } from '@venizia/ignis';
35
35
  import { parseMultipartBody } from '@venizia/ignis';
36
36
 
37
37
  @controller({ path: '/files' })
@@ -55,9 +55,15 @@ export class FileController extends BaseController {
55
55
 
56
56
  console.log('Uploaded files:', files);
57
57
 
58
- return c.json({ message: `${files.length} file(s) uploaded successfully.` });
58
+ return c.json(
59
+ { message: `${files.length} file(s) uploaded successfully.` },
60
+ HTTP.ResultCodes.RS_2.Ok,
61
+ );
59
62
  } catch (error) {
60
- return c.json({ message: 'Failed to upload files', error: error.message }, 500);
63
+ return c.json(
64
+ { message: 'Failed to upload files', error: error.message },
65
+ HTTP.ResultCodes.RS_5.InternalServerError,
66
+ );
61
67
  }
62
68
  },
63
69
  });
@@ -180,10 +186,13 @@ export class FileController extends BaseController {
180
186
  uploadDir: './uploads',
181
187
  });
182
188
 
183
- return ctx.json({
184
- message: 'Files uploaded successfully',
185
- files: files.map(f => ({ name: f.originalname, size: f.size })),
186
- });
189
+ return ctx.json(
190
+ {
191
+ message: 'Files uploaded successfully',
192
+ files: files.map(f => ({ name: f.originalname, size: f.size })),
193
+ },
194
+ HTTP.ResultCodes.RS_2.Ok,
195
+ );
187
196
  },
188
197
  });
189
198