server-architecture
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSteedos Server Architecture | Steedos 服务端架构
Steedos Server Architecture | Steedos 服务端架构
Overview | 概述
Overview | 概述
Steedos 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.
builder6/serverSteedos 服务端是基于 NestJS + Moleculer 的混合后端,为低代码平台提供 HTTP/REST 接口和微服务编排。
Steedos服务端()是基于NestJS + Moleculer的混合后端,为Steedos低代码平台提供支撑。它结合NestJS处理HTTP/REST请求,以及Moleculer进行微服务编排。
builder6/serverSteedos 服务端是基于 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-redisioredis - 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
- 实时通信:通过集成Socket.IO
@nestjs/websockets - 数据库:通过连接MongoDB 3.7
@steedos/objectql - 会话存储:通过+
connect-redis集成Redisioredis - 缓存:通过Moleculer缓存器集成Redis
- 认证:Passport(本地认证+OIDC) + 通过实现JWT
@builder6/core - API文档:在路径提供Swagger/OpenAPI文档
/api/v6
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 servicebuilder6/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 serviceNestJS Modules | NestJS 模块
NestJS Modules | NestJS 模块
The root imports 25+ modules:
AppModule| Module | Package | Purpose |
|---|---|---|
| | Environment/config loading |
| | Structured logging |
| | Cron/task scheduling |
| | Moleculer broker integration |
| | Authentication guards + strategies |
| | MongoDB connection management |
| | Core Steedos metadata + ObjectQL |
| | Data table management |
| | File upload/download |
| | Email services |
| | Micro page management |
| | Real-time collaboration rooms |
| | Microservice management |
| | SharePoint integration |
| | OpenID Connect client |
| | Office document editing |
| | Documentation services |
| | AI features |
| | Dynamic plugin loading |
| | Inter-service communication |
| (local) | REST data API |
| (local) | Object metadata + functions API |
| (local) | File upload workflow |
根模块导入了25+个模块:
AppModule| 模块 | 包 | 用途 |
|---|---|---|
| | 环境/配置加载 |
| | 结构化日志 |
| | 定时任务调度 |
| | Moleculer代理集成 |
| | 认证守卫 + 策略 |
| | MongoDB连接管理 |
| | Steedos核心元数据 + ObjectQL |
| | 数据表管理 |
| | 文件上传/下载 |
| | 邮件服务 |
| | 微页面管理 |
| | 实时协作房间 |
| | 微服务管理 |
| | SharePoint集成 |
| | OpenID Connect客户端 |
| | 办公文档编辑 |
| | 文档服务 |
| | AI功能 |
| | 动态插件加载 |
| | 服务间通信 |
| (local) | REST数据API |
| (local) | 对象元数据 + 函数API |
| (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:
- Session — Redis-backed via (prefix:
connect-redis)steedos-session: - Cookie Parser —
cookie-parser - JSON Body — (limit: 50mb)
express.json() - URL Encoded — (limit: 100mb)
express.urlencoded() - Compression —
compression() - Cloud Proxy — →
http-proxy-middleware(if configured)STEEDOS_CLOUD_URL/api/cloud - Static Router — for platform static assets
@steedos/router - SPA Fallback — index.html with injected
@steedos/webappBUILDER6_PUBLIC_SETTINGS
启动过程中按以下顺序应用:
- 会话管理 — 基于Redis的(前缀:
connect-redis)steedos-session: - Cookie解析 —
cookie-parser - JSON请求体 — (限制:50mb)
express.json() - URL编码 — (限制:100mb)
express.urlencoded() - 压缩 —
compression() - 云代理 — → 指向
http-proxy-middleware(若已配置)STEEDOS_CLOUD_URL/api/cloud - 静态路由 — 用于平台静态资源
@steedos/router - SPA回退 — 的index.html,注入
@steedos/webappBUILDER6_PUBLIC_SETTINGS
Guards | 认证守卫
Guards | 认证守卫
| Guard | Package | Usage |
|---|---|---|
| | Applied to all data/objects/functions controllers |
| | Available for admin-only endpoints |
Authentication uses cookie-based tokens: + headers/cookies.
X-Space-IdX-Auth-Token| 守卫 | 包 | 用途 |
|---|---|---|
| | 应用于所有数据/对象/函数控制器 |
| | 适用于仅管理员可访问的端点 |
认证使用基于Cookie的令牌: + 头/Cookie。
X-Space-IdX-Auth-TokenObjectQL Data Access Pattern | ObjectQL 数据访问模式
ObjectQL Data Access Pattern | ObjectQL 数据访问模式
All data operations go through :
@steedos/objectqltypescript
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 parameter enforces permission checks based on the authenticated user.
userSession所有数据操作都通过进行:
@steedos/objectqltypescript
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);userSessionEdition System | 版本系统
Edition System | 版本系统
The server supports three editions based on environment configuration:
| Edition | Condition | Services |
|---|---|---|
| Community (ce) | Default | |
| Enterprise (ee) | | + |
| Cloud | | Same as Enterprise |
服务端支持基于环境配置的三个版本:
| 版本 | 条件 | 服务 |
|---|---|---|
| 社区版(ce) | 默认 | |
| 企业版(ee) | 设置了 | + |
| 云版 | | 与企业版相同 |
Development Commands | 开发命令
Development Commands | 开发命令
bash
undefinedbash
undefinedBuild
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
undefinedmoleculer connect --config ./steedos.config.js
undefined