server-architecture

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Steedos Server Architecture | Steedos 服务端架构

Steedos Server Architecture | Steedos 服务端架构

Overview | 概述

Overview | 概述

Steedos Server (
builder6/server
) is a NestJS + Moleculer hybrid backend that powers the Steedos low-code platform. It combines NestJS for HTTP/REST handling with Moleculer for microservice orchestration.
Steedos 服务端是基于 NestJS + Moleculer 的混合后端,为低代码平台提供 HTTP/REST 接口和微服务编排。
Steedos服务端(
builder6/server
)是基于NestJS + Moleculer的混合后端,为Steedos低代码平台提供支撑。它结合NestJS处理HTTP/REST请求,以及Moleculer进行微服务编排。
Steedos 服务端是基于 NestJS + Moleculer 的混合后端,为低代码平台提供 HTTP/REST 接口和微服务编排。

Technology Stack | 技术栈

Technology Stack | 技术栈

  • HTTP Framework: NestJS 11 (Express adapter)
  • Microservices: Moleculer 0.14
  • Real-time: Socket.IO via
    @nestjs/websockets
  • Database: MongoDB 3.7 via
    @steedos/objectql
  • Session Store: Redis via
    connect-redis
    +
    ioredis
  • Cache: Redis via Moleculer cacher
  • Auth: Passport (local + OIDC) + JWT via
    @builder6/core
  • API Docs: Swagger/OpenAPI at
    /api/v6
  • HTTP框架:NestJS 11(Express适配器)
  • 微服务:Moleculer 0.14
  • 实时通信:通过
    @nestjs/websockets
    集成Socket.IO
  • 数据库:通过
    @steedos/objectql
    连接MongoDB 3.7
  • 会话存储:通过
    connect-redis
    +
    ioredis
    集成Redis
  • 缓存:通过Moleculer缓存器集成Redis
  • 认证:Passport(本地认证+OIDC) + 通过
    @builder6/core
    实现JWT
  • API文档:在
    /api/v6
    路径提供Swagger/OpenAPI文档

Source Layout | 源码结构

Source Layout | 源码结构

builder6/server/
├── package.json                      # @steedos/server v3.0.x
├── default.steedos.settings.yml      # Default configuration template
├── steedos-config.yml                # Project-level config (optional)
├── plugins/                          # Dynamic plugin directory
└── src/
    ├── main.ts                       # Entry point → calls bootstrap()
    ├── bootstrap.ts                  # App creation, middleware, Swagger, static files
    ├── app.module.ts                 # Root NestJS module (25+ imports)
    ├── app.controller.ts             # Health checks, public settings
    ├── app.gateway.ts                # WebSocket gateway (Socket.IO)
    ├── app.moleculer.ts              # Moleculer service definition + events
    ├── config/
    │   ├── index.ts                  # Config export (getConfigs, getMoleculerConfigs)
    │   ├── steedos.config.ts         # YAML config loader with env interpolation
    │   └── moleculler.config.ts      # Moleculer broker settings
    ├── api/
    │   ├── api.module.ts             # API module
    │   └── data/
    │       ├── data.controller.ts    # CRUD at /api/v6/data/:objectName
    │       └── data.service.ts       # ObjectQL data access
    ├── objects/
    │   ├── objects.module.ts         # Objects module
    │   ├── objects.controller.ts     # GET /api/v6/objects/:objectApiName
    │   ├── objects.service.ts        # ObjectQL schema access + function runner
    │   └── functions.controller.ts   # GET|POST /api/v6/functions/:obj/:func
    └── workflow/
        ├── workflow.module.ts        # Workflow module
        ├── file.controller.ts        # File upload endpoint
        ├── file.service.ts           # File processing
        └── file.moleculer.ts         # Moleculer file service
builder6/server/
├── package.json                      # @steedos/server v3.0.x
├── default.steedos.settings.yml      # Default configuration template
├── steedos-config.yml                # Project-level config (optional)
├── plugins/                          # Dynamic plugin directory
└── src/
    ├── main.ts                       # Entry point → calls bootstrap()
    ├── bootstrap.ts                  # App creation, middleware, Swagger, static files
    ├── app.module.ts                 # Root NestJS module (25+ imports)
    ├── app.controller.ts             # Health checks, public settings
    ├── app.gateway.ts                # WebSocket gateway (Socket.IO)
    ├── app.moleculer.ts              # Moleculer service definition + events
    ├── config/
    │   ├── index.ts                  # Config export (getConfigs, getMoleculerConfigs)
    │   ├── steedos.config.ts         # YAML config loader with env interpolation
    │   └── moleculler.config.ts      # Moleculer broker settings
    ├── api/
    │   ├── api.module.ts             # API module
    │   └── data/
    │       ├── data.controller.ts    # CRUD at /api/v6/data/:objectName
    │       └── data.service.ts       # ObjectQL data access
    ├── objects/
    │   ├── objects.module.ts         # Objects module
    │   ├── objects.controller.ts     # GET /api/v6/objects/:objectApiName
    │   ├── objects.service.ts        # ObjectQL schema access + function runner
    │   └── functions.controller.ts   # GET|POST /api/v6/functions/:obj/:func
    └── workflow/
        ├── workflow.module.ts        # Workflow module
        ├── file.controller.ts        # File upload endpoint
        ├── file.service.ts           # File processing
        └── file.moleculer.ts         # Moleculer file service

NestJS Modules | NestJS 模块

NestJS Modules | NestJS 模块

The root
AppModule
imports 25+ modules:
ModulePackagePurpose
ConfigModule
@nestjs/config
Environment/config loading
LoggerModule
nestjs-pino
Structured logging
ScheduleModule
@nestjs/schedule
Cron/task scheduling
MoleculerModule
@builder6/moleculer
Moleculer broker integration
AuthModule
@builder6/core
Authentication guards + strategies
MongodbModule
@builder6/core
MongoDB connection management
SteedosModule
@builder6/steedos
Core Steedos metadata + ObjectQL
TablesModule
@builder6/tables
Data table management
FilesModule
@builder6/files
File upload/download
EmailModule
@builder6/email
Email services
PagesModule
@builder6/pages
Micro page management
RoomsModule
@builder6/rooms
Real-time collaboration rooms
ServicesModule
@builder6/services
Microservice management
SharepointModule
@builder6/sharepoint
SharePoint integration
OidcModule
@builder6/oidc
OpenID Connect client
OnlyOfficeModule
@builder6/onlyoffice
Office document editing
DocsModule
@builder6/docs
Documentation services
AiModule
@steedos/ai
AI features
PluginModule
@builder6/core
Dynamic plugin loading
MicroserviceModule
@builder6/microservices
Inter-service communication
ApiModule
(local)REST data API
ObjectsModule
(local)Object metadata + functions API
WorkflowModule
(local)File upload workflow
根模块
AppModule
导入了25+个模块:
模块用途
ConfigModule
@nestjs/config
环境/配置加载
LoggerModule
nestjs-pino
结构化日志
ScheduleModule
@nestjs/schedule
定时任务调度
MoleculerModule
@builder6/moleculer
Moleculer代理集成
AuthModule
@builder6/core
认证守卫 + 策略
MongodbModule
@builder6/core
MongoDB连接管理
SteedosModule
@builder6/steedos
Steedos核心元数据 + ObjectQL
TablesModule
@builder6/tables
数据表管理
FilesModule
@builder6/files
文件上传/下载
EmailModule
@builder6/email
邮件服务
PagesModule
@builder6/pages
微页面管理
RoomsModule
@builder6/rooms
实时协作房间
ServicesModule
@builder6/services
微服务管理
SharepointModule
@builder6/sharepoint
SharePoint集成
OidcModule
@builder6/oidc
OpenID Connect客户端
OnlyOfficeModule
@builder6/onlyoffice
办公文档编辑
DocsModule
@builder6/docs
文档服务
AiModule
@steedos/ai
AI功能
PluginModule
@builder6/core
动态插件加载
MicroserviceModule
@builder6/microservices
服务间通信
ApiModule
(local)REST数据API
ObjectsModule
(local)对象元数据 + 函数API
WorkflowModule
(local)文件上传工作流

Bootstrap Sequence | 启动流程

Bootstrap Sequence | 启动流程

main.ts → bootstrap()
  1. NestFactory.create<NestExpressApplication>(AppModule)
  2. Connect Redis cluster microservice transport
  3. Set up Logger (pino), GlobalFilters (AllExceptionsFilter)
  4. Set up HybridAdapter for WebSocket
  5. Enable CORS (all origins, credentials: true)
  6. Create Redis session store
  7. Apply Express middleware stack (see below)
  8. Configure Swagger at /api/v6
  9. Set up cloud proxy if STEEDOS_CLOUD_URL is set
  10. Start all microservices
  11. Mount static router (@steedos/router)
  12. Serve @steedos/webapp SPA (frontend routes → index.html)
  13. Listen on B6_PORT (default: 5100)
main.ts → bootstrap()
  1. NestFactory.create<NestExpressApplication>(AppModule)
  2. Connect Redis cluster microservice transport
  3. Set up Logger (pino), GlobalFilters (AllExceptionsFilter)
  4. Set up HybridAdapter for WebSocket
  5. Enable CORS (all origins, credentials: true)
  6. Create Redis session store
  7. Apply Express middleware stack (see below)
  8. Configure Swagger at /api/v6
  9. Set up cloud proxy if STEEDOS_CLOUD_URL is set
  10. Start all microservices
  11. Mount static router (@steedos/router)
  12. Serve @steedos/webapp SPA (frontend routes → index.html)
  13. Listen on B6_PORT (default: 5100)

Middleware Stack | 中间件栈

Middleware Stack | 中间件栈

Applied in order during bootstrap:
  1. Session — Redis-backed via
    connect-redis
    (prefix:
    steedos-session:
    )
  2. Cookie Parser
    cookie-parser
  3. JSON Body
    express.json()
    (limit: 50mb)
  4. URL Encoded
    express.urlencoded()
    (limit: 100mb)
  5. Compression
    compression()
  6. Cloud Proxy
    http-proxy-middleware
    STEEDOS_CLOUD_URL/api/cloud
    (if configured)
  7. Static Router
    @steedos/router
    for platform static assets
  8. SPA Fallback
    @steedos/webapp
    index.html with injected
    BUILDER6_PUBLIC_SETTINGS
启动过程中按以下顺序应用:
  1. 会话管理 — 基于Redis的
    connect-redis
    (前缀:
    steedos-session:
  2. Cookie解析
    cookie-parser
  3. JSON请求体
    express.json()
    (限制:50mb)
  4. URL编码
    express.urlencoded()
    (限制:100mb)
  5. 压缩
    compression()
  6. 云代理
    http-proxy-middleware
    → 指向
    STEEDOS_CLOUD_URL/api/cloud
    (若已配置)
  7. 静态路由
    @steedos/router
    用于平台静态资源
  8. SPA回退
    @steedos/webapp
    的index.html,注入
    BUILDER6_PUBLIC_SETTINGS

Guards | 认证守卫

Guards | 认证守卫

GuardPackageUsage
AuthGuard
@builder6/core
Applied to all data/objects/functions controllers
AdminGuard
@builder6/core
Available for admin-only endpoints
Authentication uses cookie-based tokens:
X-Space-Id
+
X-Auth-Token
headers/cookies.
守卫用途
AuthGuard
@builder6/core
应用于所有数据/对象/函数控制器
AdminGuard
@builder6/core
适用于仅管理员可访问的端点
认证使用基于Cookie的令牌:
X-Space-Id
+
X-Auth-Token
头/Cookie。

ObjectQL Data Access Pattern | ObjectQL 数据访问模式

ObjectQL Data Access Pattern | ObjectQL 数据访问模式

All data operations go through
@steedos/objectql
:
typescript
import { getObject } from "@steedos/objectql";

const obj = getObject("orders");
await obj.find(query, userSession);
await obj.findOne(id, userSession);
await obj.insert(doc, userSession);
await obj.update(id, data, userSession);
await obj.delete(id, userSession);
await obj.runFunction(functionApiName, params, userSession);
The
userSession
parameter enforces permission checks based on the authenticated user.
所有数据操作都通过
@steedos/objectql
进行:
typescript
import { getObject } from "@steedos/objectql";

const obj = getObject("orders");
await obj.find(query, userSession);
await obj.findOne(id, userSession);
await obj.insert(doc, userSession);
await obj.update(id, data, userSession);
await obj.delete(id, userSession);
await obj.runFunction(functionApiName, params, userSession);
userSession
参数会根据已认证用户强制执行权限检查。

Edition System | 版本系统

Edition System | 版本系统

The server supports three editions based on environment configuration:
EditionConditionServices
Community (ce)Default
@steedos/service-community
Enterprise (ee)
STEEDOS_LICENSE
set
+
@steedos/service-license
+
@steedos/service-enterprise
Cloud
STEEDOS_TENANT_ENABLE_SAAS=true
Same as Enterprise
服务端支持基于环境配置的三个版本:
版本条件服务
社区版(ce)默认
@steedos/service-community
企业版(ee)设置了
STEEDOS_LICENSE
+
@steedos/service-license
+
@steedos/service-enterprise
云版
STEEDOS_TENANT_ENABLE_SAAS=true
与企业版相同

Development Commands | 开发命令

Development Commands | 开发命令

bash
undefined
bash
undefined

Build

Build

nest build
nest build

Development with hot reload

Development with hot reload

nest start --watch
nest start --watch

Debug mode

Debug mode

nest start --debug --watch
nest start --debug --watch

Production

Production

node dist/main
node dist/main

Lint

Lint

eslint "{src,apps,libs,test}/**/*.ts" --fix
eslint "{src,apps,libs,test}/**/*.ts" --fix

Format

Format

prettier --write "src/**/*.ts"
prettier --write "src/**/*.ts"

Moleculer REPL (debugging)

Moleculer REPL (debugging)

moleculer connect --config ./steedos.config.js
undefined
moleculer connect --config ./steedos.config.js
undefined