Bỏ qua, đến nội dung

Tổng quan hệ thống

1) Digiforce là gì

Digiforce là nền tảng low-code / no-code xây dựng ứng dụng doanh nghiệp. Toàn bộ tính năng nghiệp vụ (workflow, quản lý dữ liệu, biểu mẫu, dashboard, tích hợp…) đều được cung cấp dưới dạng plugin - core chỉ lo pipeline HTTP, quản lý dữ liệu, phân quyền và lifecycle.

Mục tiêuCách đạt được
Mở rộng không fork coreMọi feature ship dưới dạng plugin; core chỉ expose contract (hook, manager, middleware).
Metadata-drivenCollection, field, UI schema, action khai báo runtime thay vì hardcode.
Đa data sourceDataSourceManager trừu tượng hoá nguồn dữ liệu; request pipeline nhất quán bất kể backend.
Bảo mật xuyên suốtRequest API qua resource pipeline: AuthManagerACL trước khi handler dùng Repository.
Quan sát đượcLogger, request ID, telemetry, SQL logger - truy vết toàn bộ lifecycle.

2) System context - ai tương tác với hệ thống

Thành phầnVai trò
User / AdminSử dụng giao diện SPA để thao tác dữ liệu, cấu hình hệ thống, quản lý plugin.
DeveloperPhát triển plugin (server + client), chạy CLI (install, upgrade, dev).
Hệ thống ngoàiGọi API hoặc nhận webhook, tích hợp SSO/OAuth.
Client SPAỨng dụng React, render UI Schema, giao tiếp server qua REST + WebSocket.
ServerNode.js / Koa, xử lý request, quản lý plugin lifecycle, pipeline dữ liệu.
DatabaseLưu trữ chính (PostgreSQL, MySQL hoặc SQLite cho dev).
Cache / PubSubRedis - cache, pub/sub giữa các instance, lock phân tán.
File StorageLocal disk hoặc object storage (S3, MinIO…) cho file upload.

3) Container view - bên trong platform

Hai runtime hoàn toàn tách biệt, giao tiếp qua HTTP API và WebSocket:

  • Server là ứng dụng Koa mở rộng, quản lý toàn bộ dữ liệu, bảo mật và plugin server-side.
  • Client là SPA React, tải plugin client (static + remote) và render UI dựa trên Schema.

4) Bản đồ package (monorepo)

NhómPackage tiêu biểuVai trò
Core - runtimeserver, clientHai Application chính (server Koa, client React).
Core - datadatabase, data-source-manager, resourcer, actionsORM, quản lý data source, resource/action pipeline.
Core - securityacl, authEngine phân quyền và xác thực.
Core - infracache, logger, telemetry, utilsCache, log, quan sát, tiện ích chung.
Core - toolingbuild, cli, sdk, test, create-digiforce-nc-appBuild, CLI, scaffold, test.
Pluginsplugin-acl, plugin-workflow, plugin-action-*, plugin-block-*Tính năng nghiệp vụ, UI block, tích hợp.

5) Nguyên tắc thiết kế xuyên suốt

Mở rộng qua plugin

Core (pipeline, manager, engine) expose contract (hook, event, middleware slot). Plugin đăng ký vào contract, không sửa core. Chi tiết: Plugin architecture.

Middleware có thứ tự rõ ràng

Tất cả middleware (server Koa, resource pipeline, data source) đều dùng Toposort với tag before / after. Plugin khai báo vị trí tương đối thay vì hard-index.

Metadata-driven

Collection / Field / UI Schema khai báo bằng JSON, lưu trong database và đọc runtime. Thay đổi cấu trúc dữ liệu hoặc giao diện không cần build lại code. Chi tiết: Data model & metadata.

Backward compatibility

API cũ được giữ lại qua deprecation path. Migration tự động khi upgrade - core migration chạy trước, plugin migration chạy sau.

Quan sát hệ thống

Logger (app, request, SQL), Telemetry (hook vào lifecycle và request), Audit (sự kiện thay đổi quan trọng).


6) Deployment điển hình

Thành phầnGhi chú
Load BalancerPhân tải HTTP + WebSocket; sticky session cho WS nếu cần.
InstanceMỗi instance chạy server Node.js + phục vụ client build (static). Có thể scale horizontal.
PostgreSQLDatabase chính; MySQL cũng hỗ trợ. SQLite cho dev/test.
RedisBắt buộc khi multi-instance - cache, pub/sub đồng bộ trạng thái, distributed lock.
Object StorageFile upload; local disk (single instance) hoặc S3/MinIO (production).

Khi chạy nhiều instance, PubSubManager + SyncMessageManager qua Redis đảm bảo đồng bộ trạng thái plugin, cache invalidation và lock.


Đọc tiếp