Data Flow

Last Updated: May 19, 2025

This document describes the data flow patterns within the Typus Development Framework, illustrating how data moves between different components and layers of the system.

Overview

The Typus Development Framework implements several data flow patterns to handle different types of operations:

  1. Request-Response Flow: Synchronous data flow for immediate operations
  2. Asynchronous Task Flow: Deferred processing for long-running operations
  3. Real-time Data Flow: WebSocket-based communication for live updates
  4. DSL-Based Data Flow: Type-safe data transformation using the DSL system
  5. Content Management Flow: CMS-specific data operations

Request-Response Data Flow

The standard request-response flow handles synchronous operations where the client expects an immediate response.

DatabaseRepository LayerService LayerBackend APIAPI ClientFrontend LayerClient BrowserDatabaseRepository LayerService LayerBackend APIAPI ClientFrontend LayerClient BrowserRequest validationBusiness logicAuthorization checksData accessTransaction managementQuery optimizationUser ActionAPI RequestHTTP RequestProcess RequestData OperationQuery ExecutionQuery ResultsProcessed DataResponse DataHTTP ResponseAPI ResponseUI Update

Key Components in Request-Response Flow

  1. Client Browser: Initiates the flow through user actions
  2. Frontend Layer: Captures user actions and translates them into API requests
  3. API Client: Handles communication with the backend API
  4. Backend API: Receives and routes requests to appropriate services
  5. Service Layer: Implements business logic and orchestrates data operations
  6. Repository Layer: Abstracts database access and implements data access patterns
  7. Database: Stores and retrieves persistent data

Asynchronous Task Flow

For long-running operations, the system uses an asynchronous task flow through the Dispatcher Layer.

DatabaseWorker ProcessDispatcher LayerService LayerBackend APIFrontend LayerClient BrowserDatabaseWorker ProcessDispatcher LayerService LayerBackend APIFrontend LayerClient Browseralt[Real-time Notification][Polling]User ActionAPI RequestProcess RequestQueue TaskTask AcknowledgedImmediate ResponseOperation PendingUI FeedbackProcess TaskData OperationsOperation ResultsTask CompletedNotificationWebSocket EventUI UpdateStatus CheckTask StatusTask StatusStatus UpdateUI Update

Key Components in Asynchronous Flow

  1. Dispatcher Layer: Manages task queues and distributes work to workers
  2. Worker Process: Executes tasks asynchronously
  3. WebSocket Connection: Provides real-time updates on task progress (optional)
  4. Polling Mechanism: Alternative method for checking task status

Real-time Data Flow

For real-time features, the system uses WebSocket connections to push updates to clients.

DatabaseBackend ServicesWebSocket ServerWebSocket ClientClient BrowserDatabaseBackend ServicesWebSocket ServerWebSocket ClientClient Browserloop[Real-time Updates]ConnectEstablish ConnectionConnection EstablishedReady StateSubscribe to EventsRegister SubscriptionsData Change EventPublish EventPush UpdateUpdate UISend MessageTransmit MessageProcess MessageUpdate DataConfirmationPublish UpdatePush UpdateUpdate UI

Key Components in Real-time Flow

  1. WebSocket Client: Manages WebSocket connection on the client side
  2. WebSocket Server: Handles connections and message distribution
  3. Event Subscription: Allows clients to subscribe to specific event types
  4. Event Publication: Broadcasts events to subscribed clients

DSL-Based Data Flow

The DSL system provides a type-safe data flow between different layers of the application.

Data Transformation

Model Definitions

DSL Registry

Backend DSL Implementation

Frontend DSL Client

API Controllers

Services

Repositories

Typed API Client

Form Validation

Typed Stores

TypeScript Interfaces

Prisma Schema

Validation Schemas

DSL Data Flow Process

  1. Model Definition: Data structures are defined once in the DSL system
  2. Code Generation: TypeScript interfaces, Prisma schema, and validation schemas are generated
  3. Type Consistency: Generated types ensure consistency across layers
  4. Validation: Input data is validated against the generated schemas
  5. Transformation: Data is transformed between different representations as needed

Content Management Data Flow

The CMS module implements a specialized data flow for content management.

Client BrowserFrontend RendererContent StorageDynamic RouterCMS ModuleAdmin UserClient BrowserFrontend RendererContent StorageDynamic RouterCMS ModuleAdmin UserCreate/Edit ContentStore ContentContent StoredUpdate RoutesRoutes UpdatedConfirmationRequest PageResolve RouteFetch ContentContent DataContent + TemplateRender ContentRendered Page

Key Components in CMS Data Flow

  1. CMS Module: Provides content management interface
  2. Dynamic Router: Maps URLs to content and templates
  3. Content Storage: Persists content data
  4. Frontend Renderer: Renders content using appropriate templates

Data Flow in DSX System

The DSX system implements a component-based data flow for dynamic UI rendering.

Backend APIAPI ClientData SourceDSX ComponentDSX BlockDSX PageBackend APIAPI ClientData SourceDSX ComponentDSX BlockDSX Pagealt[Has SetupClass]alt[API Data Source][Local Data Source]InitializeRender BlocksRender ComponentsInitializeCreate Setup InstanceCall Setup HooksBefore Data FetchFetch DataAPI RequestHTTP RequestHTTP ResponseResponse DataProcess Local DataRaw DataAfter Data FetchTransform DataBefore RenderRender with DataRendered ComponentRendered Block

Key Components in DSX Data Flow

  1. DSX Page: Top-level container for page rendering
  2. DSX Block: Container for components within a layout
  3. DSX Component: Individual UI component with data binding
  4. Data Source: Provides data to components
  5. Component Lifecycle Hooks: Process data at different stages

Database Data Flow

The database layer implements a structured data flow for data persistence.

Data Transformation

Service Layer

Repository Layer

Prisma Client

Connection Pool

Database

Query Builder

Transaction Manager

DTO Mapper

Model Mapper

Entity Mapper

Key Components in Database Flow

  1. Repository Layer: Implements data access patterns
  2. Prisma Client: ORM for database operations
  3. Query Builder: Constructs optimized database queries
  4. Transaction Manager: Ensures data consistency
  5. Data Mappers: Transform between different data representations

Authentication Data Flow

The authentication system implements a secure data flow for user authentication.

DatabaseUser ServiceJWT ServiceAuth ModuleFrontend LayerClient BrowserDatabaseUser ServiceJWT ServiceAuth ModuleFrontend LayerClient Browseralt[Valid Credentials][Invalid Credentials]alt[Valid Refresh Token][Invalid Refresh Token]alt[Valid Access Token][Expired Access Token]Login RequestAuthentication RequestValidate CredentialsQuery UserUser DataValidation ResultGenerate TokensAccess & Refresh TokensAuthentication SuccessStore TokensLogin SuccessAuthentication FailedLogin FailedAccess Protected ResourceRequest with Access TokenResource DataDisplay ResourceToken ExpiredRefresh Token RequestValidate Refresh TokenValidation ResultGenerate New TokensNew Access & Refresh TokensNew TokensStore New TokensRetry RequestResource DataDisplay ResourceAuthentication RequiredRedirect to Login

Key Components in Authentication Flow

  1. Auth Module: Handles authentication requests
  2. JWT Service: Generates and validates tokens
  3. User Service: Validates user credentials
  4. Token Storage: Securely stores tokens on the client
  5. Token Refresh: Handles expired access tokens

File Upload Data Flow

The file system module implements a specialized data flow for file uploads.

DatabaseFile StorageFile ServiceBackend APIFrontend LayerClient BrowserDatabaseFile StorageFile ServiceBackend APIFrontend LayerClient BrowserSelect FileValidate FileUpload RequestProcess UploadValidate FileStore FileStorage ReferenceStore MetadataConfirmationUpload ResultUpload ResponseUpload Feedback

Key Components in File Upload Flow

  1. File Input: Allows users to select files
  2. File Validation: Validates file type, size, etc.
  3. File Service: Processes and stores files
  4. Storage Provider: Physical storage for files
  5. Metadata Storage: Tracks file information in the database

Conclusion

The Typus Development Framework implements multiple data flow patterns to handle different types of operations efficiently. These patterns ensure:

  1. Type Safety: Consistent data types across the application
  2. Performance: Optimized data access and transformation
  3. Scalability: Asynchronous processing for resource-intensive operations
  4. Real-time Capabilities: Immediate updates for collaborative features
  5. Security: Proper validation and authorization at each step

Understanding these data flow patterns is essential for developing and extending the framework effectively. Each pattern is designed to address specific requirements while maintaining consistency with the overall architecture.

WARNING

Failed to fetch dynamically imported module: https://typus.dev/assets/RecursiveNavItem-Cep7andh.js

{ "stack": "AppError: Failed to fetch dynamically imported module: https://typus.dev/assets/RecursiveNavItem-Cep7andh.js\n at https://typus.dev/assets/index-DS79FI73.js:315:420\n at dn (https://typus.dev/assets/vue-vendor-Ct83yDeK.js:13:1385)\n at We (https://typus.dev/assets/vue-vendor-Ct83yDeK.js:13:1455)\n at Ws.t.__weh.t.__weh (https://typus.dev/assets/vue-vendor-Ct83yDeK.js:14:7364)\n at jt (https://typus.dev/assets/vue-vendor-Ct83yDeK.js:13:1866)\n at v (https://typus.dev/assets/vue-vendor-Ct83yDeK.js:14:4019)\n at https://typus.dev/assets/vue-vendor-Ct83yDeK.js:14:4097" }