Architecture

Design Architecture

设计架构

OpenList Worker is a Serverless-first rewrite of the OpenList Go backend in TypeScript. The system is divided into three layers: edge runtime, data access, and frontend static assets.

OpenList Worker 是将 OpenList Go 后端以 TypeScript 重写的 Serverless 优先架构。系统分为边缘运行时、数据访问和前端静态资源三层。

Tech Stack

技术栈

Backend

后端

ComponentTechnologyDescription
HTTP frameworkHono.jsLightweight, edge-native web framework
RuntimeCloudflare Workers / EdgeOne Functions / ESAEdge compute platforms
LanguageTypeScriptFully typed, compiled via esbuild / Vite
ORMDrizzle ORMType-safe SQL query builder for D1 / MySQL
Build toolesbuild / ViteSingle-file Worker bundle
组件技术说明
HTTP 框架Hono.js轻量级、边缘原生 Web 框架
运行时Cloudflare Workers / EdgeOne 云函数 / ESA边缘计算平台
语言TypeScript全类型,使用 esbuild / Vite 编译
ORMDrizzle ORM为 D1 / MySQL 提供类型安全的 SQL 查询构建器
构建工具esbuild / Vite单文件 Worker 产物

Frontend

前端

ComponentTechnologyDescription
FrameworkSolidJS + TypeScriptReactive SPA frontend
UI libraryHope UI (@hope-ui/solid)Component library
Build toolViteFast frontend build
Bundled withWorkers Static AssetsServed from the same origin as the API
组件技术说明
框架SolidJS + TypeScript响应式 SPA 前端
UI 库Hope UI(@hope-ui/solid)组件库
构建工具Vite快速前端构建
与 Worker 同源Workers Static AssetsAPI 与前端同源部署,无跨域问题

Data Storage

数据存储

Storage Format (DB_FORMAT)

存储格式(DB_FORMAT

The DB_FORMAT variable controls how data is serialized:

ValueDescriptionBest for
map (default)Whole object serialized as a single JSON valueKV / Blob storage
keyPer-key storage, one record per entityKV with high read frequency
sqlRelational tables, identical schema to the Go backendD1 / MySQL — enables Go ↔ TS migration

DB_FORMAT 控制数据序列化方式:

说明最适用场景
map(默认)整对象序列化为单个 JSON 值KV / Blob 存储
key分 key 存储,每实体一条记录高频读写 KV
sql关系表,与 Go 后端 schema 完全一致D1 / MySQL——支持 Go ↔ TS 迁移

Storage Driver (DB_DRIVER)

存储驱动(DB_DRIVER

The DB_DRIVER variable selects the physical storage backend:

ValuePlatformDescription
auto (default)UniversalAuto-detect: blob → cfkv → kv → d1 → memory
blobEdgeOne / ESAEdgeOne Blob or Alibaba ESA Blob
cfkvUniversalCloudflare KV via REST API (cross-platform)
kvCloudflare WorkersCloudflare KV binding
d1Cloudflare WorkersCloudflare D1 (SQLite)
doCloudflare WorkersDurable Objects (strong consistency)
mysqlNode.js containerExternal MySQL / MariaDB

DB_DRIVER 选择物理存储后端:

平台说明
auto(默认)通用自动检测:blob → cfkv → kv → d1 → memory
blobEdgeOne / ESAEdgeOne Blob 或阿里云 ESA Blob
cfkv通用Cloudflare KV REST API(跨平台远程调用)
kvCloudflare WorkersCloudflare KV 绑定
d1Cloudflare WorkersCloudflare D1(SQLite)
doCloudflare WorkersDurable Objects(强一致性)
mysqlNode.js 容器外部 MySQL / MariaDB

SQL Table Alignment with Go Backend

与 Go 后端的 SQL 表对齐

When DB_FORMAT = "sql", the TS Worker uses the same table names and schema as the Go backend (GORM, default prefix x_), so the two backends can share the same physical database:

Go structTable name
SettingItemx_setting_items
SharingDBx_sharing_dbs
Storagex_storages
Userx_users
Metax_metas
(TS only)x_plugins

The prefix can be changed via the TABLE_PREFIX environment variable.

DB_FORMAT = "sql" 时,TS Worker 使用与 Go 后端(GORM,默认前缀 x_)相同的表名与 schema,两个后端可共享同一物理数据库:

Go 结构体表名
SettingItemx_setting_items
SharingDBx_sharing_dbs
Storagex_storages
Userx_users
Metax_metas
(仅 TS)x_plugins

表名前缀可通过 TABLE_PREFIX 环境变量修改。

Project Structure

项目结构

OpenList-Worker/
├── src/
│   ├── backend/          # Hono.js Worker entry & backend logic
│   │   ├── worker.ts     # Cloudflare Workers entry
│   │   ├── drivers/      # Storage driver implementations (kv / d1 / blob / mysql …)
│   │   ├── server/       # Route registrations & middleware
│   │   ├── pkg/          # Shared utilities & helpers
│   │   └── internal/     # Core business logic (auth, storage, meta, …)
│   └── frontend/         # Built-in frontend (SolidJS + Vite)
├── dist/                 # Build output (Worker bundle + frontend assets)
├── esa-entry.ts          # Alibaba Cloud ESA entry
├── wrangler.toml         # Cloudflare Workers configuration
├── esa.jsonc             # Alibaba Cloud ESA configuration
├── edgeone.json          # EdgeOne schedules configuration
└── package.json
OpenList-Worker/
├── src/
│   ├── backend/          # Hono.js Worker 入口与后端逻辑
│   │   ├── worker.ts     # Cloudflare Workers 入口
│   │   ├── drivers/      # 存储驱动实现(kv / d1 / blob / mysql …)
│   │   ├── server/       # 路由注册与中间件
│   │   ├── pkg/          # 公共工具与辅助函数
│   │   └── internal/     # 核心业务逻辑(认证、存储、元数据 …)
│   └── frontend/         # 内置前端(SolidJS + Vite)
├── dist/                 # 构建产物(Worker bundle + 前端资源)
├── esa-entry.ts          # 阿里云 ESA 入口
├── wrangler.toml         # Cloudflare Workers 配置
├── esa.jsonc             # 阿里云 ESA 配置
├── edgeone.json          # EdgeOne 定时任务配置
└── package.json

Supported Platforms

支持平台

PlatformEntryPersistenceNotes
Cloudflare Workersworker.tsD1 / KV / DOOne-click deploy supported
Tencent Cloud EdgeOneworker.tsBlob / KVOne-click deploy supported
Alibaba Cloud ESAesa-entry.tsEdgeKVManual build & deploy
Node.js containerworker.ts (with adapter)MySQLSelf-hosted
平台入口持久化备注
Cloudflare Workersworker.tsD1 / KV / DO支持一键部署
腾讯云 EdgeOneworker.tsBlob / KV支持一键部署
阿里云 ESAesa-entry.tsEdgeKV手动构建部署
Node.js 容器worker.ts(带适配层)MySQL自托管

Contributors