Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# <img src="./logo.webp" alt="i0c.cc" width="420">

i0c.cc is a personal edge redirect playground with a PostgreSQL control plane and an archived Git fallback. It runs the same core through optional edge-platform adapters and provides a WebUI with optional analytics for my own use.
i0c.cc is a personal edge redirect playground with a database-backed control plane, PostgreSQL enabled by default, and an archived Git fallback. It runs the same core through optional edge-platform adapters and provides a WebUI with optional analytics for my own use.

## Positioning

This repository is maintained for personal use and engineering experimentation. It is not intended to be a hosted URL-shortening service or an enterprise redirect platform.

- Deploy whichever Runtime adapter fits the environment; Cloudflare, Vercel, and Netlify are supported alternatives rather than required replicas.
- Use PostgreSQL for immediate database-backed saves, immutable history, and rollback; Git remains an archived build-time fallback.
- Use PostgreSQL by default, or bind Cloudflare D1 on a compatible WebUI host, for immediate saves, immutable history, and rollback; Git remains an archived build-time fallback.
- Use the WebUI and analytics when they help the personal workflow; the roadmap prioritizes clarity and reliability over feature parity with commercial products.

## Projects
Expand All @@ -22,7 +22,7 @@ This repository is maintained for personal use and engineering experimentation.
| Plugin Catalog | [packages/plugin-catalog](packages/plugin-catalog) | Optional official presets and host-specific plugin configuration validation. |
| Runtime Host | [packages/runtime-host](packages/runtime-host) | Platform-neutral Runtime deployment and executable-plugin installation contracts. |
| Runtime Build | [packages/runtime-build](packages/runtime-build) | Build-time installation validation, root-config binding, and selected-adapter bundling. |
| Official plugins | [plugins](plugins) | Git and PostgreSQL data backends, an HTTP Runtime snapshot source, three Runtime adapters, analytics delivery and storage, and bot classification. |
| Official plugins | [plugins](plugins) | Git, PostgreSQL, and D1 data backends, an HTTP Runtime snapshot source, three Runtime adapters, analytics delivery and storage, and bot classification. |

Executable plugins are selected at build time: Runtime installations live in [i0c.runtime.config.ts](i0c.runtime.config.ts), WebUI server installations in [i0c.webui.config.ts](i0c.webui.config.ts), and client-safe WebUI renderers in [apps/webui/webui.extensions.ts](apps/webui/webui.extensions.ts). The remote `config.json` document configures installed code but never downloads or executes new packages.

Expand Down Expand Up @@ -81,13 +81,13 @@ The selected WebUI Repository contains two independently editable documents:
- `config.json` stores non-sensitive instance settings such as the canonical Runtime origin, cache TTLs, robots policy, analytics namespace and collector endpoint, WebUI access policy, and namespaced plugin configuration.
- `redirects.json` stores redirect rules.

The checked-in PostgreSQL Repository uses optimistic document revisions and exposes an atomic two-document snapshot. An empty database enters a one-time WebUI setup flow that creates both documents atomically. Every save, import, migration, and rollback produces an immutable revision; restoring an older document creates a new head instead of rewriting history. Managers can import and export both JSON documents for backup and migration.
The PostgreSQL and D1 Repositories implement the same optimistic-revision, atomic-snapshot, immutable-history, import/export, and rollback contract. The checked-in deployment selects PostgreSQL. A D1-capable WebUI host may select D1 and inject its database binding before the Repository is initialized.

GitHub Contents remains available as an archived build-time fallback that preserves commits on a configured branch, but it is not enabled by the checked-in deployment. The WebUI can edit both documents; invalid `config.json` content remains visible to managers so it can be repaired.

The checked-in HTTP Snapshot Source reads one validated WebUI snapshot so config and rules always come from the same Repository revision. It uses ETags, bounded retries and timeouts, and the last valid memory or platform cache. GitHub Raw remains available when Git-backed data is selected. Runtime deployments never receive PostgreSQL credentials.
The checked-in HTTP Snapshot Source reads one validated WebUI snapshot so config and rules always come from the same Repository revision. It uses ETags, bounded retries and timeouts, and the last valid memory or platform cache. GitHub Raw remains available when Git-backed data is selected. Runtime deployments never receive database credentials or bindings.

[packages/config](packages/config) owns schemas, validation, safe defaults, and the build-time Repository and Source selection. Bootstrap changes such as GitHub paths, PostgreSQL connection policy, HTTP snapshot URL, or GitHub OAuth scope require rebuilding. PostgreSQL Repository migrations are deliberate external writes and never run during a build or application startup.
[packages/config](packages/config) owns schemas, validation, safe defaults, and the build-time Repository and Source selection. Bootstrap changes such as GitHub paths, database provider or connection policy, HTTP snapshot URL, or GitHub OAuth scope require rebuilding. Repository migrations are deliberate external writes and never run during a build or application startup.

The former non-sensitive environment variables are not read as overrides or fallbacks. Existing values left in a provider dashboard are ignored and can be removed after the new deployment is verified. Secrets and deployment-specific bindings remain in each application's environment example.

Expand Down Expand Up @@ -143,7 +143,7 @@ pnpm check

## Data documents

The two Repository implementations use the same document schemas:
All Repository implementations use the same document schemas:

```text
packages/config/config.schema.json
Expand Down
14 changes: 7 additions & 7 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# i0c.cc

i0c.cc 是一个以 PostgreSQL 为控制面、保留归档 Git 回退方案的个人边缘重定向实验项目。同一套核心可以通过不同边缘平台适配器运行,并提供自用的 WebUI 与可选统计功能。
i0c.cc 是一个以数据库为控制面、默认启用 PostgreSQL、并保留归档 Git 回退方案的个人边缘重定向实验项目。同一套核心可以通过不同边缘平台适配器运行,并提供自用的 WebUI 与可选统计功能。

## 项目定位

这个仓库面向个人使用和工程实验,不准备成为托管短链接服务或企业级重定向平台。

- 按部署环境选择所需的 Runtime 适配器;Cloudflare、Vercel 与 Netlify 是可选方案,不要求同时运行。
- 使用 PostgreSQL 实现数据库即时保存、不可变历史与回滚;Git 只作为归档的构建期回退方案保留。
- 默认使用 PostgreSQL;兼容的 WebUI 宿主也可绑定 Cloudflare D1,实现即时保存、不可变历史与回滚;Git 只作为归档的构建期回退方案保留。
- WebUI 与统计功能服务于个人工作流;后续路线优先保证清晰和可靠,不追求与商业产品功能对齐。

## 项目
Expand All @@ -22,7 +22,7 @@ i0c.cc 是一个以 PostgreSQL 为控制面、保留归档 Git 回退方案的
| 插件目录 | [packages/plugin-catalog](packages/plugin-catalog) | 可选的官方预设与按宿主执行的插件配置校验。 |
| Runtime 宿主 | [packages/runtime-host](packages/runtime-host) | 平台无关的 Runtime 部署与可执行插件安装契约。 |
| Runtime 构建 | [packages/runtime-build](packages/runtime-build) | 构建期安装校验、根配置绑定与所选适配器 Bundle 生成。 |
| 官方插件 | [plugins](plugins) | Git 与 PostgreSQL 数据后端、HTTP Runtime 快照源、三个 Runtime 适配器、统计投递与存储,以及机器人分类。 |
| 官方插件 | [plugins](plugins) | Git、PostgreSQLD1 数据后端、HTTP Runtime 快照源、三个 Runtime 适配器、统计投递与存储,以及机器人分类。 |

可执行插件在构建期选择:Runtime 安装位于 [i0c.runtime.config.ts](i0c.runtime.config.ts),WebUI 服务端安装位于 [i0c.webui.config.ts](i0c.webui.config.ts),客户端安全的 WebUI Renderer 位于 [apps/webui/webui.extensions.ts](apps/webui/webui.extensions.ts)。远程 `config.json` 文档只能配置已安装代码,不会下载或执行新包。

Expand Down Expand Up @@ -81,13 +81,13 @@ Vercel 需要保持开启 **Include source files outside of the Root Directory i
- `config.json` 存放非敏感实例配置,包括 Runtime 规范域名、缓存时间、robots 策略、统计命名空间与收集端地址、WebUI 访问策略,以及按命名空间隔离的插件配置。
- `redirects.json` 存放重定向规则。

仓库当前启用的 PostgreSQL Repository 使用乐观文档版本,并提供两份文档的原子快照。数据库为空时,WebUI 会进入一次性初始化流程,并原子创建两份文档。每次保存、导入、迁移和回滚都会产生不可变版本;恢复旧文档会创建新的活动版本,而不是改写历史。管理者可以导入和导出两份 JSON,用于备份和迁移
PostgreSQL 与 D1 Repository 实现同一套乐观版本、原子快照、不可变历史、导入导出和回滚契约。仓库当前部署选择 PostgreSQL;支持 D1 的 WebUI 宿主可选择 D1,并在 Repository 初始化前注入数据库 binding

GitHub Contents 仍保留为归档的构建期回退方案,并可在指定分支保留 commit,但仓库当前部署不会启用它。WebUI 可以编辑两份文档;即使 `config.json` 写坏,管理员仍能看到原文并修复。

仓库当前启用的 HTTP Snapshot Source 从 WebUI 读取一份经过校验的快照,确保配置和规则来自同一个 Repository revision;它使用 ETag、有限重试与超时,并保留最后一次有效的内存或平台缓存。选择 Git 数据后端时仍可使用 GitHub Raw。Runtime 部署不会获得 PostgreSQL 凭据
仓库当前启用的 HTTP Snapshot Source 从 WebUI 读取一份经过校验的快照,确保配置和规则来自同一个 Repository revision;它使用 ETag、有限重试与超时,并保留最后一次有效的内存或平台缓存。选择 Git 数据后端时仍可使用 GitHub Raw。Runtime 部署不会获得数据库凭据或 binding

[packages/config](packages/config) 负责 schema、校验、安全默认值,以及构建期 Repository 与 Source 选择。修改 GitHub 路径、PostgreSQL 连接策略、HTTP 快照地址或 GitHub OAuth scope 等启动配置后仍需重新构建。PostgreSQL Repository 迁移属于明确的外部写入,构建与应用启动都不会自动执行。
[packages/config](packages/config) 负责 schema、校验、安全默认值,以及构建期 Repository 与 Source 选择。修改 GitHub 路径、数据库类型或连接策略、HTTP 快照地址或 GitHub OAuth scope 等启动配置后仍需重新构建。Repository 迁移属于明确的外部写入,构建与应用启动都不会自动执行。

原有非敏感环境变量不再作为覆盖值或回退值读取。平台后台遗留的旧值会被忽略,确认新部署正常后即可删除。密钥和与部署绑定的值继续保留在各应用的环境变量示例中。

Expand Down Expand Up @@ -143,7 +143,7 @@ pnpm check

## 数据文档

两种 Repository 实现共用下面的文档 schema:
所有 Repository 实现共用下面的文档 schema:

```text
packages/config/config.schema.json
Expand Down
12 changes: 7 additions & 5 deletions apps/webui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,19 @@ This project provides two rule-editing modes and a separate settings surface:

## Data repository

The checked-in deployment selects PostgreSQL through [../../packages/config/src/defaults.ts](../../packages/config/src/defaults.ts) and uses `DATABASE_URL`.
The checked-in deployment selects PostgreSQL through [../../packages/config/src/defaults.ts](../../packages/config/src/defaults.ts) and uses `DATABASE_URL`. A D1-capable WebUI host may select `provider: "d1"` and inject a `D1Database` binding through `configureAppDataRepositoryBinding` before the Repository is first used.

First-run setup creates both documents in one transaction and refuses partially initialized databases. Every save creates an immutable revision. Import validates both JSON files and replaces them atomically, while restore copies an old document into a new head revision instead of rewriting history. Managers can export, import, inspect, and restore revisions from **Settings → Data and history**.
PostgreSQL and D1 are held to the same shared behavior contract. First-run setup creates both documents atomically and refuses partially initialized databases. Every save creates an immutable revision. Import validates both JSON files and replaces them atomically, while restore copies an old document into a new head revision instead of rewriting history. Managers can export, import, inspect, and restore revisions from **Settings → Data and history**.

D1 owns independent migrations in [../../plugins/repository/d1/migrations](../../plugins/repository/d1/migrations). Apply them deliberately to the bound database before opening setup. The current Vercel deployment remains on PostgreSQL because Vercel does not provide a native D1 binding.

The `seed` command remains available for controlled non-interactive migrations, but it is not part of the normal deployment flow:

```bash
pnpm --filter @i0c/plugin-data-repository-postgres seed -- --config <config.json> --redirects <redirects.json>
```

For database-backed documents, also select the HTTP Runtime Source in the same bootstrap configuration and point it at `https://<webui-domain>/api/runtime/snapshot`. The public endpoint returns one validated config-and-rules revision with an ETag; it contains no Secret values. Edge Runtime deployments fetch this endpoint and never receive the PostgreSQL connection string.
For database-backed documents, also select the HTTP Runtime Source in the same bootstrap configuration and point it at `https://<webui-domain>/api/runtime/snapshot`. The public endpoint returns one validated config-and-rules revision with an ETag; it contains no Secret values. Edge Runtime deployments fetch this endpoint and never receive the database connection or binding.

GitHub Contents and GitHub Raw remain in the workspace as archived build-time alternatives. Re-enabling them requires deliberately changing the bootstrap Repository and Runtime Source selections, restoring the required OAuth Repository scope, and rebuilding both applications. They are not part of the default first-run flow.

Expand Down Expand Up @@ -140,10 +142,10 @@ The WebUI does not read former non-sensitive environment variables as overrides

- Versioned authenticated, numeric-ID allowlist, or GitHub-wide read-only access with configured managers and optional blocked users.
- Visual editing of `redirects.json`: group tree management + rule form editing.
- Rules JSON editor: line numbers, current line highlighting, JSON syntax validation (error prompts for formatting issues).
- GitHub Repository-only rules source override and JSON editor with line highlighting and syntax validation.
- Visual, validated `config.json` settings with a raw recovery editor only when the current document cannot be represented safely.
- First-run database initialization without hand-written JSON or a seed command.
- Immutable document history, non-destructive rollback, and atomic JSON backup import/export.
- Immutable document history with Git-style line diffs, non-destructive rollback, and atomic JSON backup import/export.
- Authenticated plugin status reporting for installed manifests, configuration state, capabilities, missing bindings, and selected-Store health.
- Form behavior aligned with the schema (specification source: [https://raw.githubusercontent.com/Revaea/i0c.cc/main/packages/config/redirects.schema.json](https://raw.githubusercontent.com/Revaea/i0c.cc/main/packages/config/redirects.schema.json)).
- Supports undo/redo for quick editing rollback.
Expand Down
Loading