@futdevpro/nts-dynamo 1.14.68 → 1.14.70

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.
package/README.md CHANGED
@@ -1,140 +1,676 @@
1
+ # Dynamo-NTS
1
2
 
3
+ <div align="center">
4
+ <img src="src/_assets/dynamo-nts-logo-256.png" alt="Dynamo-NTS Logo" width="256">
5
+ </div>
2
6
 
3
- Dynamo is a framework developed by FDP that allows you to perform software development tasks easily, efficiently, quickly, and simply. As well as creating a unified system, the development of which will increase the stability of all our projects. Dynamo is easy to use, with the goal of creating complete systems with the right energy investment for the design process so that it can be easily upgraded in any form later.
7
+ **Dynamo-NTS** (NodeTS) is a comprehensive backend framework for building robust, secure, and scalable Node.js applications with TypeScript. Built on top of [Dynamo FSM](https://www.npmjs.com/package/@futdevpro/fsm-dynamo) (`@futdevpro/fsm-dynamo`), it provides a structured approach to server-side development with clear separation of concerns, extensive configuration options, and production-ready implementations for common backend tasks.
4
8
 
5
- Using dynamo can reduce software development costs by a fraction.
9
+ Dynamo-NTS uses **[Dynamo FSM](https://www.npmjs.com/package/@futdevpro/fsm-dynamo)** as its foundational layer, implementing the server-side components of the FSM architecture. All core interfaces, types, and utilities are provided by FSM, ensuring consistency and type safety across the entire Dynamo ecosystem.
6
10
 
11
+ Dynamo-NTS is part of the unified **Dynamo ecosystem**, a full-stack development framework designed to accelerate the development of scalable web applications. The ecosystem consists of interconnected packages that work together seamlessly, with Dynamo-NTS serving as the backend implementation layer. The frontend counterpart is **[Dynamo NGX](https://www.npmjs.com/package/@futdevpro/ngx-dynamo)**, which uses **[Dynamo NGX Models](https://www.npmjs.com/package/@futdevpro/ngx-dynamo-models)** for type-safe model definitions.
7
12
 
8
- Part of this project is also a builder or editor interface, through which even those who are not software developers or have no development experience, can perform the development.
13
+ ### Design Philosophy
9
14
 
10
- This interface can help juniors and people unfamiliar with development to easily make minor modifications and repairs to the system. Or they can easily get to know and understand the operation and structure of even a more complex project.
15
+ Dynamo-NTS is built with two key principles:
11
16
 
12
- ...
17
+ - **Full Override Capability**: Every component, service, and class can be overridden or extended. The framework provides a solid foundation with sensible defaults, but you have complete control to customize or replace any part to fit your specific needs. This makes Dynamo-NTS highly customizable and adaptable to any project requirements.
13
18
 
14
- more documentation and description soon...
19
+ - **Complete Type Information**: All types, interfaces, and definitions are included in the compiled output. This ensures excellent readability and maintainability—everything you need is available at compile time through TypeScript's type system, providing full IntelliSense support and eliminating the need to reference external documentation during development.
15
20
 
16
- ...
21
+ ### Simplified System Definitions
17
22
 
18
- support out projects to make it happen sooner!
19
- https://futdevpro.hu/support/dynamo
23
+ Dynamo-NTS simplifies complex system definitions by abstracting common backend infrastructure into simple parameterization. Instead of manually configuring various libraries and services, you define your application through straightforward parameter objects:
20
24
 
25
+ - **Express Usage**: HTTP/HTTPS server setup, routing, middleware, and error handling are configured through `DyNTS_App_Params`, `DyNTS_Http_Settings`, and `DyNTS_RoutingModule` parameters (simplifies Express server initialization and route management)
26
+ - **MongoDB/Mongoose Usage**: Database connections, models, schemas, and operations are managed through `DyNTS_DBService` and `DyNTS_DataService` with simple data model parameter definitions (simplifies Mongoose schema creation and model management)
27
+ - **Socket.io Usage**: Real-time communication setup, event handling, and presence tracking are configured through `DyNTS_SocketServerService` parameters and the `DyNTS_AppExtended` class (simplifies Socket.io server initialization and event management)
28
+ - **Nodemailer Usage**: Email sending with templating, attachments, and async delivery is handled through `DyNTS_EmailService` with template component definitions (simplifies Nodemailer transporter setup and email template management)
29
+ - **OAuth2 Implementation**: Complete OAuth2.0 protocol flows including authorization codes, token exchange, and refresh tokens are managed through `DyNTS_OAuth2_Controller` and `DyNTS_OAuth2_AuthService` (simplifies complex OAuth2 flow implementation)
30
+ - **Axios Usage**: HTTP client requests to external APIs are standardized through `DyNTS_ApiService` with `DyNTS_ApiCall_Params` configuration (simplifies Axios request setup, error handling, and response management)
31
+ - **Discord.js / Slack / Teams Bot Development**: Platform-agnostic bot framework through `DyNTS_Bot_MessagingProvider_ServiceBase` and bot modules (simplifies Discord.js, Slack, and Teams bot development with unified interfaces)
32
+ - **OpenAI / AI Provider Integration**: AI/LLM operations including chat, embeddings, and vector search are abstracted through `DyNTS_AI_Provider_ServiceBase` and provider implementations (simplifies OpenAI SDK usage and enables multi-provider architecture)
33
+ - **Location Tracking**: IP-based geolocation through `geoip-lite` is integrated into the usage tracking module (simplifies location data collection from HTTP requests)
21
34
 
35
+ This parameterization approach eliminates boilerplate code and provides a consistent, type-safe interface for all backend operations. Instead of learning multiple library APIs and their configuration patterns, developers work with unified Dynamo-NTS parameter objects that handle the underlying complexity.
22
36
 
37
+ ## Table of Contents
23
38
 
39
+ - [Installation](#installation)
40
+ - [Quick Start](#quick-start)
41
+ - [Core Concepts](#core-concepts)
42
+ - [Modules Overview](#modules-overview)
43
+ - [Usage Examples](#usage-examples)
44
+ - [Ecosystem Integration](#ecosystem-integration)
45
+ - [API Reference](#api-reference)
24
46
 
47
+ ## Installation
25
48
 
26
- Development notes...:
49
+ Install Dynamo-NTS using pnpm (recommended) or npm:
27
50
 
28
- # Hashtag1
29
- ## Hashtag2
30
- ### Hashtag3
31
- #### Hashtag4
32
- ##### Hashtag5
33
- ###### Hashtag6
51
+ ```bash
52
+ pnpm add @futdevpro/dynamo-nts
53
+ # or
54
+ npm install @futdevpro/dynamo-nts
55
+ ```
34
56
 
35
- ____________________________________
57
+ ### Peer Dependencies
36
58
 
59
+ Dynamo-NTS requires peer dependencies that are divided into two categories: core dependencies (required for the main module) and module-specific dependencies (required only when using specific modules).
37
60
 
38
- - LINE
39
- - LINES
40
- - MORE LINES
61
+ #### Core Dependencies (Required)
41
62
 
42
- * star line
43
- * star lines
44
- * more star lines
63
+ These dependencies are required for the main Dynamo-NTS functionality:
45
64
 
46
- 1. num1
47
- 2. num2
48
- 3. num3
65
+ - [`@futdevpro/fsm-dynamo`](https://www.npmjs.com/package/@futdevpro/fsm-dynamo) - The foundational package providing core interfaces and utilities (always required)
66
+ - `express` - Web framework for Node.js (simplified through Dynamo-NTS parameterization)
67
+ - `mongoose` - MongoDB object modeling (simplified through Dynamo-NTS data services)
68
+ - `axios` - HTTP client (simplified through Dynamo-NTS API service)
69
+ - `body-parser` - Request body parsing middleware
70
+ - `dotenv` - Environment variable management
71
+ - `rxjs` - Reactive programming library
72
+ - `@types/express` - TypeScript types for Express
73
+ - `@types/node` - TypeScript types for Node.js
74
+ - `ts-node` - TypeScript execution environment
49
75
 
50
- **STARS**
51
- **[STARS-N-BRACET]**
76
+ Install core dependencies:
52
77
 
53
- EZMIEZ
54
- Standard [VajonE](https://futdevpro.hu)
55
- Standard [Jinja2](https://jinja.palletsprojects.com/en/2.10.x/templates/)
78
+ ```bash
79
+ pnpm add @futdevpro/fsm-dynamo express mongoose axios body-parser dotenv rxjs @types/express @types/node ts-node
80
+ ```
56
81
 
57
- check &check;
58
- cross &cross;
82
+ #### Module-Specific Dependencies (Optional)
59
83
 
60
- ```
61
- valami
62
- ```
84
+ These dependencies are only required when using specific modules:
63
85
 
86
+ - **Socket Module**: `socket.io` - Real-time communication (simplified through Dynamo-NTS socket services)
87
+ - **Email Service**: `nodemailer` - Email sending (simplified through Dynamo-NTS email services)
88
+ - **Usage Module**: `geoip-lite` and `@types/geoip-lite` - IP geolocation (simplified through Dynamo-NTS usage module)
89
+ - **Bot Module (Discord)**: `discord.js` - Discord bot development (simplified through Dynamo-NTS bot module)
90
+ - **AI Module (OpenAI)**: `openai` - OpenAI API integration (simplified through Dynamo-NTS AI module)
64
91
 
65
- ```xml
66
- <asd>
67
- <fgh>
68
- <id>central-mirror</id>
69
- <name>AAFK {projektname} repo</name>
70
- <url>https://futdevpro.hu</url>
71
- </fgh>
72
- </asd>
73
- ```
92
+ Install module-specific dependencies as needed:
93
+
94
+ ```bash
95
+ # For Socket module
96
+ pnpm add socket.io
74
97
 
75
- ```yaml
76
- web:
77
- ports:
78
- - number: 1234
79
- protocol: TCP
80
- - number: 2345
81
- protocol: UDP
98
+ # For Email service
99
+ pnpm add nodemailer
100
+
101
+ # For Usage module
102
+ pnpm add geoip-lite @types/geoip-lite
103
+
104
+ # For Bot module (Discord)
105
+ pnpm add discord.js
106
+
107
+ # For AI module (OpenAI)
108
+ pnpm add openai
82
109
  ```
83
110
 
111
+ ## Quick Start
112
+
113
+ The following example demonstrates how to set up a basic Dynamo-NTS application with routing and socket support:
114
+
115
+ ```typescript
116
+ import {
117
+ DyNTS_AppExtended,
118
+ DyNTS_App_Params,
119
+ DyNTS_GlobalService_Settings,
120
+ DyNTS_Http_Settings,
121
+ DyNTS_RoutingModule
122
+ } from '@futdevpro/nts-dynamo';
123
+ import {
124
+ DyNTS_SocketServerService
125
+ } from '@futdevpro/nts-dynamo/socket';
126
+ import { DyFM_usageSession_dataParams } from '@futdevpro/fsm-dynamo/usage';
127
+ import { DyFM_customData_dataParams } from '@futdevpro/fsm-dynamo/custom-data';
128
+ import { DyNTS_getUsageRoutingModule } from '@futdevpro/nts-dynamo/usage';
129
+ import { DyNTS_getTestRoutingModule } from '@futdevpro/nts-dynamo/test';
130
+
131
+ import { AuthService } from './core-services/auth.service';
132
+ import { Email_ServiceCollection } from './core-services/email.service-collection';
133
+ import { User_Controller } from './routes/user/user.controller';
134
+ import { Chat_SocketServerService } from './socket-services/chat.socket-server-service';
135
+
136
+ export class App extends DyNTS_AppExtended {
137
+
138
+ getAppParams(): DyNTS_App_Params {
139
+ return new DyNTS_App_Params({
140
+ name: 'My Application',
141
+ version: '1.0.0',
142
+ dbName: 'myapp',
143
+ dbUri: process.env.MONGO_URL || 'mongodb://localhost:27017/myapp',
144
+ systemShortCodeName: 'MYAPP',
145
+ });
146
+ }
147
+
148
+ getGlobalServiceCollection(): DyNTS_GlobalService_Settings {
149
+ return {
150
+ authService: AuthService.getInstance(),
151
+ emailServiceCollection: Email_ServiceCollection.getInstance(),
152
+ dbModels: [
153
+ // Your data model parameters here
154
+ DyFM_usageSession_dataParams,
155
+ DyFM_customData_dataParams,
156
+ ],
157
+ };
158
+ }
159
+
160
+ getPortSettings(): DyNTS_Http_Settings {
161
+ return new DyNTS_Http_Settings({
162
+ httpPort: 3000,
163
+ });
164
+ }
165
+
166
+ getRoutingModules(): DyNTS_RoutingModule[] {
167
+ return [
168
+ new DyNTS_RoutingModule({
169
+ route: '/user',
170
+ controllers: [
171
+ User_Controller.getInstance(),
172
+ ],
173
+ }),
174
+ DyNTS_getTestRoutingModule(),
175
+ DyNTS_getUsageRoutingModule(),
176
+ ];
177
+ }
84
178
 
85
- ```json
86
- {
87
- "name": "@futdevpro/nts-dynamo",
88
- "version": "01.05.57",
89
- "description": "Dynamic NodeTS (NodeJS-Typescript), MongoDB Backend System Framework by Future Development Program Ltd.",
90
- "scripts": {
91
- "test": "echo \"Error: no test specified\" && exit 1",
92
-
93
- "build": "npm run install-n-build",
179
+ getSocketServices(): DyNTS_SocketServerService<any>[] {
180
+ return [
181
+ Chat_SocketServerService.getInstance(),
182
+ ];
94
183
  }
95
184
  }
185
+
186
+ // Start the application
187
+ const app = new App();
96
188
  ```
97
189
 
98
- ```ts
190
+ ## Core Concepts
191
+
192
+ Dynamo-NTS uses [Dynamo FSM](https://www.npmjs.com/package/@futdevpro/fsm-dynamo) as its foundation, implementing all server-side components defined in the FSM architecture. All types, interfaces, and base models are provided by FSM, ensuring full type safety and consistency.
193
+
194
+ ### Extensibility and Customization
195
+
196
+ Dynamo-NTS is designed with extensibility in mind. Every component, service, and class can be overridden or extended to meet your specific requirements:
197
+
198
+ - **Service Override**: All services (authentication, email, data services, etc.) can be extended or completely replaced with custom implementations
199
+ - **Method Override**: Abstract methods in base classes allow you to customize behavior while maintaining the framework structure
200
+ - **Configuration Override**: Global settings, route security, and application parameters can be overridden at any level
201
+ - **Type Safety**: All overrides maintain full TypeScript type safety, with all types and interfaces available at compile time
202
+
203
+ This design philosophy ensures that Dynamo-NTS provides a solid foundation while remaining fully customizable for your specific use cases.
204
+
205
+ ### Complete Type Information
206
+
207
+ All types, interfaces, and definitions are included in the compiled output, ensuring excellent readability and maintainability. When you compile your project, you have access to:
208
+
209
+ - Complete type definitions for all services, models, and interfaces
210
+ - Full IntelliSense support in your IDE
211
+ - Compile-time type checking for all framework components
212
+ - Self-documenting code through TypeScript's type system
213
+
214
+ This approach eliminates the need to reference external documentation during development—everything you need is available in your IDE's autocomplete and type hints.
215
+
216
+ ### Application Classes
217
+
218
+ Dynamo-NTS provides two main application base classes that simplify Express server setup:
219
+
220
+ - **`DyNTS_App`**: Basic application class for standard HTTP server applications without real-time socket support
221
+ - **`DyNTS_AppExtended`**: Extended application class that includes built-in socket server capabilities for real-time communication (simplifies Socket.io setup)
222
+
223
+ Both classes abstract away Express server configuration, requiring you to implement several abstract methods with simple parameter objects:
224
+
225
+ - `getAppParams()`: Define application parameters (name, version, database name, etc.) - replaces Express app initialization
226
+ - `getGlobalServiceCollection()`: Configure global services (authentication, email, database models) - replaces manual service registration
227
+ - `getPortSettings()`: Configure HTTP/HTTPS ports - replaces Express server.listen() configuration
228
+ - `getRoutingModules()`: Define API routes and controllers - replaces Express router setup
229
+
230
+ ### Data Services
231
+
232
+ Data services provide a structured way to interact with MongoDB, simplifying Mongoose model and schema definitions:
233
+
234
+ - **`DyNTS_DBService<T>`**: Low-level MongoDB service for direct database operations (simplifies Mongoose model creation)
235
+ - **`DyNTS_DataService<T>`**: High-level data service with business logic, validation, and dependency management (simplifies MongoDB CRUD operations)
236
+ - **`DyNTS_ArchiveDataService<T>`**: Service for managing archived data in separate collections
237
+
238
+ Instead of manually creating Mongoose schemas and models, you define data models through `DyFM_DataModel_Params` (from FSM), and Dynamo-NTS handles schema generation, model creation, and connection management automatically. Data services handle CRUD operations, data validation, dependency tracking, and provide methods for searching, filtering, and managing data relationships.
239
+
240
+ ### Routing System
241
+
242
+ The routing system provides a structured approach to defining RESTful API endpoints, simplifying Express router configuration:
243
+
244
+ - **`DyNTS_RoutingModule`**: Groups related controllers under a common route path (replaces Express Router setup)
245
+ - **`DyNTS_Controller`**: Abstract base class for defining HTTP endpoints (simplifies Express route handlers)
246
+ - **`DyNTS_Endpoint_Params`**: Configuration for individual API endpoints (replaces Express route definitions)
247
+
248
+ Instead of manually setting up Express routers and route handlers, you define endpoints through parameter objects. Controllers define endpoints with support for:
249
+ - Multiple HTTP methods (GET, POST, PUT, PATCH, DELETE)
250
+ - Pre-processing middleware (authentication, validation)
251
+ - Task functions for handling requests
252
+ - Route security levels (open, secure, both)
253
+
254
+ ### Global Services
255
+
256
+ The `DyNTS_GlobalService` provides centralized access to:
257
+
258
+ - Authentication service
259
+ - Email service collection
260
+ - Database models registry
261
+ - Error handlers
262
+ - Socket server instances
263
+
264
+ ### Authentication
265
+
266
+ Dynamo-NTS provides an abstract `DyNTS_AuthService` class that you can extend to implement your authentication logic. The framework supports:
267
+
268
+ - Token-based authentication
269
+ - OAuth2 flows (via the OAuth2 module)
270
+ - Session management
271
+ - Route-level security configuration
272
+
273
+ ## Modules Overview
274
+
275
+ Dynamo-NTS is organized into focused modules, each providing specific functionality:
276
+
277
+ ### Main Module
278
+
279
+ The core foundation providing essential components:
280
+
281
+ - **Collections**: Archive utilities, global settings, environment configuration
282
+ - **Enums**: Data model types, service functions, route security levels
283
+ - **Models**: Application configuration interfaces, control models, database types
284
+ - **Services**: Core services for API communication, authentication, data management, routing
285
+
286
+ ### AI Module
287
+
288
+ Provides abstractions and implementations for AI operations:
289
+
290
+ - **Abstract Service Bases**: Base classes for AI providers, LLM services, LLM chat services, and embedding services
291
+ - **OpenAI Implementation**: Complete OpenAI integration with LLM, chat, and embedding support
292
+ - **Document AI**: Document chunking and preprocessing for AI models
293
+ - **Vector Search**: MongoDB Atlas vector database operations with automatic data vectorization
294
+
295
+ ### Assistant Module
296
+
297
+ Platform and AI provider agnostic solutions for creating intelligent assistants:
298
+
299
+ - Integrates communication providers (bot) with AI providers (LLM Chat)
300
+ - Message conversion utilities
301
+ - Conversation management
302
+ - Configurable settings for system prompts and message filtering
303
+
304
+ ### Bot Module
305
+
306
+ Platform-agnostic bot functionality:
307
+
308
+ - Message, channel, and user wrappers for any messaging platform
309
+ - Command system for bot commands
310
+ - Routine system for scheduled and event-driven tasks
311
+ - IO management for bot interactions
312
+ - Provider support for Discord, Slack, and Teams
313
+
314
+ ### Socket Module
315
+
316
+ Real-time communication capabilities that simplify Socket.io setup:
317
+
318
+ - Socket client and server implementations with secure and open connection options (simplifies Socket.io server initialization)
319
+ - Event handling system for managing real-time communications (replaces manual Socket.io event handler setup)
320
+ - Presence tracking for monitoring connected clients
321
+ - Error handling and logging for reliable operation
322
+ - Extended application class with built-in socket server capabilities (automatically configures Socket.io with Express server)
323
+
324
+ ### Messaging Module
325
+
326
+ Backend implementation for unified messaging system:
327
+
328
+ - Data services for messages and conversations
329
+ - Control services for business logic orchestration
330
+ - Real-time socket events
331
+ - RESTful HTTP endpoints
332
+ - Integration with bot and assistant modules
333
+
334
+ ### OAuth2 Module
335
+
336
+ Complete OAuth2.0 protocol implementation:
337
+
338
+ - OAuth2 authorization and token management
339
+ - Client management and user authentication
340
+ - Token exchange and refresh operations
341
+ - Authorization code and access token generation
342
+
343
+ ### Server Module
344
+
345
+ Solutions for basic server endpoints:
346
+
347
+ - Error handling for saving and retrieving server errors
348
+ - Server status monitoring with version and uptime information
349
+ - Server status snapshots for saving and retrieving status at specific times
350
+ - Error statistics for monitoring and analysis
351
+
352
+ ### Defaults Module
353
+
354
+ Default implementations for common services:
355
+
356
+ - Default user data model and service for authentication and user management
357
+ - Default authentication service with basic token-based authentication
358
+ - Default socket events service with graceful degradation
359
+ - All services can be extended or replaced with custom implementations
360
+
361
+ ### Custom Data Module
362
+
363
+ Tools for managing custom data:
364
+
365
+ - Data service for handling custom data operations with optional initialization
366
+ - Controller with RESTful endpoints for data operations
367
+ - GET endpoint for retrieving custom data by ID
368
+ - POST endpoint for modifying custom data
369
+ - Configurable routing module with optional security overrides
370
+
371
+ ### Test Module
372
+
373
+ Testing and monitoring tools:
374
+
375
+ - Test endpoints for different HTTP methods (GET, POST, DELETE)
376
+ - Server status endpoint with version and uptime information
377
+ - Configurable routing module with security override options
378
+ - Automatic controller registration for easy setup
379
+
380
+ ### Usage Module
381
+
382
+ Session and usage tracking tools:
383
+
384
+ - Session management tools for creating, updating, and closing sessions
385
+ - Usage data collection and analysis tools
386
+ - Location tracking from HTTP requests
387
+ - Usage statistics retrieval with time range filtering
388
+ - Daily usage statistics calculation
389
+
390
+ ## Usage Examples
391
+
392
+ ### Basic Application Setup
393
+
394
+ This example shows a complete application setup using `DyNTS_AppExtended`:
395
+
396
+ ```typescript
397
+ import {
398
+ DyNTS_AppExtended,
399
+ DyNTS_App_Params,
400
+ DyNTS_GlobalService_Settings,
401
+ DyNTS_Http_Settings,
402
+ DyNTS_RoutingModule
403
+ } from '@futdevpro/nts-dynamo';
404
+ import { DyNTS_SocketServerService } from '@futdevpro/nts-dynamo/socket';
405
+
99
406
  export class App extends DyNTS_AppExtended {
100
-
101
- ...
102
-
103
- // Setting up App params, and preparing project global settings
104
- setupAppParams(): void {
105
- this.params = new DyNTS_AppParams({
106
- name: 'Warbots Server',
107
- title: warbotsTitleLog,
108
- version: version,
109
- dbName: 'warbots',
407
+
408
+ getAppParams(): DyNTS_App_Params {
409
+ return new DyNTS_App_Params({
410
+ name: 'My Server',
411
+ version: '1.0.0',
412
+ dbName: 'myapp',
110
413
  });
111
-
112
- // dynamoNTS_GlobalSettings.logRequestsContent = false;
113
414
  }
114
-
115
- ...
415
+
416
+ getGlobalServiceCollection(): DyNTS_GlobalService_Settings {
417
+ return {
418
+ authService: AuthService.getInstance(),
419
+ dbModels: [
420
+ // Your data models
421
+ ],
422
+ };
423
+ }
424
+
425
+ getPortSettings(): DyNTS_Http_Settings {
426
+ return new DyNTS_Http_Settings({
427
+ httpPort: 3000,
428
+ });
429
+ }
430
+
431
+ getRoutingModules(): DyNTS_RoutingModule[] {
432
+ return [
433
+ new DyNTS_RoutingModule({
434
+ route: '/api',
435
+ controllers: [
436
+ MyController.getInstance(),
437
+ ],
438
+ }),
439
+ ];
440
+ }
441
+
442
+ getSocketServices(): DyNTS_SocketServerService<any>[] {
443
+ return [
444
+ MySocketService.getInstance(),
445
+ ];
446
+ }
447
+ }
448
+ ```
449
+
450
+ ### Routing Module Configuration
451
+
452
+ Multiple routing modules can be configured to organize your API:
453
+
454
+ ```typescript
455
+ getRoutingModules(): DyNTS_RoutingModule[] {
456
+ return [
457
+ new DyNTS_RoutingModule({
458
+ route: '/user',
459
+ controllers: [
460
+ User_Controller.getInstance(),
461
+ UserData_Controller.getInstance(),
462
+ UserSettings_Controller.getInstance(),
463
+ ],
464
+ }),
465
+ new DyNTS_RoutingModule({
466
+ route: '/project',
467
+ controllers: [
468
+ Project_Controller.getInstance(),
469
+ ProjectExtension_Controller.getInstance(),
470
+ ],
471
+ }),
472
+ new DyNTS_RoutingModule({
473
+ route: '/server',
474
+ controllers: [
475
+ ServerStatus_Controller.getInstance(),
476
+ ],
477
+ }),
478
+ DyNTS_getTestRoutingModule(),
479
+ DyNTS_getUsageRoutingModule(),
480
+ ];
481
+ }
482
+ ```
483
+
484
+ ### Controller Implementation
485
+
486
+ Controllers define API endpoints with authentication and business logic:
487
+
488
+ ```typescript
489
+ import { Request, Response } from 'express';
490
+ import { DyNTS_Controller, DyNTS_Endpoint_Params } from '@futdevpro/nts-dynamo';
491
+ import { DyFM_HttpCallType } from '@futdevpro/fsm-dynamo';
492
+
493
+ export class User_Controller extends DyNTS_Controller {
494
+
495
+ static getInstance(): User_Controller {
496
+ return User_Controller.getSingletonInstance();
497
+ }
498
+
499
+ private authService: AuthService = AuthService.getInstance();
500
+
501
+ setupEndpoints(): void {
502
+ this.endpoints = [
503
+ new DyNTS_Endpoint_Params({
504
+ name: 'getUser',
505
+ type: DyFM_HttpCallType.get,
506
+ endpoint: '/get/:userId',
507
+ preProcesses: [this.authService.authenticate_tokenSelf],
508
+ tasks: [
509
+ async (req: Request, res: Response, issuer: string): Promise<void> => {
510
+ const userService = new User_DataService({ issuer });
511
+ await userService.getDataById(req.params.userId);
512
+ res.send(userService.data);
513
+ },
514
+ ],
515
+ }),
516
+ new DyNTS_Endpoint_Params({
517
+ name: 'updateUser',
518
+ type: DyFM_HttpCallType.post,
519
+ endpoint: '/update',
520
+ preProcesses: [this.authService.authenticate_tokenSelf],
521
+ tasks: [
522
+ async (req: Request, res: Response, issuer: string): Promise<void> => {
523
+ const userService = new User_DataService({ issuer });
524
+ await userService.saveData(req.body);
525
+ res.send(userService.data);
526
+ },
527
+ ],
528
+ }),
529
+ ];
530
+ }
531
+ }
116
532
  ```
117
533
 
118
- ```scss
119
- @import '@futdevpro/ngx-dynamo';
534
+ ### Data Service Implementation
535
+
536
+ Data services provide a structured way to interact with MongoDB:
537
+
538
+ ```typescript
539
+ import { DyNTS_DataService } from '@futdevpro/nts-dynamo';
540
+ import { DyFM_DataModel_Params } from '@futdevpro/fsm-dynamo'; // FSM provides the data model parameter definition
541
+
542
+ // Define your data model parameters
543
+ const userDataParams: DyFM_DataModel_Params<UserData> = new DyFM_DataModel_Params({
544
+ dataName: 'userData',
545
+ typeSample: {
546
+ userId: '',
547
+ preferences: {},
548
+ },
549
+ // ... additional configuration
550
+ });
551
+
552
+ export class User_DataService extends DyNTS_DataService<UserData> {
553
+ constructor(params: { issuer: string }) {
554
+ super(userDataParams);
555
+ this.issuer = params.issuer;
556
+ }
557
+
558
+ // Custom business logic methods
559
+ async getUserPreferences(userId: string): Promise<UserPreferences> {
560
+ await this.getDataByDependencyId({ userId });
561
+ return this.data?.preferences || {};
562
+ }
563
+ }
120
564
  ```
121
565
 
122
- ```shell script
123
- npm run start
566
+ ### Socket Server Service
567
+
568
+ Socket services enable real-time communication:
569
+
570
+ ```typescript
571
+ import { DyNTS_SocketServerService, DyNTS_SocketPresence } from '@futdevpro/nts-dynamo/socket';
572
+
573
+ export class Chat_SocketServerService extends DyNTS_SocketServerService<DyNTS_SocketPresence, any> {
574
+
575
+ static getInstance(): Chat_SocketServerService {
576
+ return Chat_SocketServerService.getSingletonInstance();
577
+ }
578
+
579
+ protected setupSocketEvents(): void {
580
+ this.socketServer.on('connection', (socket) => {
581
+ socket.on('joinRoom', (roomId: string) => {
582
+ socket.join(roomId);
583
+ });
584
+
585
+ socket.on('sendMessage', async (data: { roomId: string; message: string }) => {
586
+ this.socketServer.to(data.roomId).emit('newMessage', data);
587
+ });
588
+ });
589
+ }
590
+ }
124
591
  ```
125
592
 
126
- ```html
127
- <dynamo-form [params]="newFeedbackFormParams"></dynamo-form>
593
+ ### Vector Search with AI
594
+
595
+ Dynamo-NTS provides built-in support for MongoDB Atlas vector search with automatic vectorization:
596
+
597
+ ```typescript
598
+ import { DyNTS_OAI_VectorDataService } from '@futdevpro/nts-dynamo/ai/open-ai';
599
+
600
+ export class Knowledge_DataService extends DyNTS_OAI_VectorDataService<Knowledge> {
601
+
602
+ constructor() {
603
+ super(knowledgeDataParams);
604
+ }
605
+
606
+ async searchSimilarContent(query: string, limit: number = 10): Promise<Knowledge[]> {
607
+ return await this.vectorSearch({
608
+ input: query,
609
+ searchInKey: 'content', // Property that has vectorization enabled
610
+ limit: limit,
611
+ numberOfCandidates: 100,
612
+ });
613
+ }
614
+ }
128
615
  ```
129
616
 
130
- ![NTS](/src/_assets/dynamo-nts-512.png)
617
+ The vector search automatically:
618
+ - Creates embeddings for search queries using the configured AI provider
619
+ - Performs semantic search in MongoDB Atlas vector database
620
+ - Returns results sorted by relevance
621
+ - Supports filtering with additional MongoDB queries
622
+
623
+ ## Ecosystem Integration
624
+
625
+ Dynamo-NTS is part of the unified **Dynamo ecosystem**, which consists of several interconnected packages:
626
+
627
+ ### Dynamo FSM (Full Stack Module)
628
+
629
+ The foundational package [`@futdevpro/fsm-dynamo`](https://www.npmjs.com/package/@futdevpro/fsm-dynamo) that provides:
630
+ - Core interfaces and types shared across the ecosystem
631
+ - Base model definitions (used by all Dynamo-NTS data services)
632
+ - Utility functions
633
+ - Type definitions for system-wide use
634
+ - Data model parameter definitions (`DyFM_DataModel_Params`)
635
+
636
+ Dynamo-NTS is built on top of Dynamo FSM and implements the server-side components of the FSM architecture. All data models, interfaces, and type definitions used in Dynamo-NTS are provided by FSM, ensuring consistency and type safety across the entire ecosystem.
637
+
638
+ ### Dynamo NGX (AngularX)
639
+
640
+ The frontend counterpart [`@futdevpro/dynamo-ngx`](https://www.npmjs.com/package/@futdevpro/dynamo-ngx) provides:
641
+ - Angular components and services
642
+ - Frontend models that integrate with Dynamo-NTS backend (using shared FSM types)
643
+ - Real-time communication clients (connects to Dynamo-NTS socket services)
644
+ - Form management and data table components
645
+
646
+ ### Unified Patterns
647
+
648
+ The Dynamo ecosystem enforces consistent patterns across all packages:
649
+
650
+ - **Naming Conventions**: Consistent prefixes (`DyNTS_` for backend, `DyNX_` for frontend, `DyFM_` for shared)
651
+ - **Type Safety**: Full TypeScript support with shared type definitions
652
+ - **Architecture Patterns**: Consistent service patterns, data models, and API structures
653
+ - **Error Handling**: Unified error handling across the stack
654
+ - **Logging**: Consistent logging patterns and utilities
655
+
656
+ This unified approach ensures that:
657
+ - Developers learn one set of patterns that apply everywhere
658
+ - Frontend and backend code integrate seamlessly
659
+ - Type safety is maintained across the entire stack
660
+ - Maintenance and updates are simplified
661
+
662
+ ## API Reference
663
+
664
+ For detailed API documentation, see:
665
+
666
+ - [Dynamo-NTS Documentation](documentations/specifications/dynamo-packages/dynamo-nts/dynamo-nts.md)
667
+ - [Dynamo FSM Documentation](documentations/specifications/dynamo-packages/dynamo-fsm/dynamo-fsm.md)
668
+ - [Dynamo Ecosystem Overview](documentations/specifications/dynamo-packages/dynamo_packages.md)
131
669
 
670
+ ## License
132
671
 
133
- - [![dependency - npm](../../svg/dependency_npm.svg)](https://www.npmjs.com/package/font-awesome) font-awesome 4.7.0
672
+ ISC
134
673
 
135
- | Dynamo verzió | Angular verzió |
136
- | :-----: | :------------: |
137
- | 01.01.x | 11.00.x |
138
- | 01.05.x | 13.00.x |
674
+ ## Support
139
675
 
140
- ...
676
+ For issues, questions, or contributions, please refer to the project repository.