From ac6a884c5b890f9352890d62d3aec13a8311ebf4 Mon Sep 17 00:00:00 2001 From: argszero Date: Wed, 21 Oct 2026 18:03:43 +0800 Subject: [PATCH] docs(architecture): name the gateway module in the src/ module table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Section 3 lists nine modules, and gateway.rs is not one of them -- the whole document does not contain the string once. It is declared in src/main.rs:19 and is the largest production module in the tree (3136 lines; protocol.rs 2141, sse.rs 2709, billing.rs 931), and it holds the six handlers a request actually lands in: chat_completions, anthropic_messages, responses, models, plans and v1_models. Its own module doc opens with "网关兼容端点(architecture §6 API 一览)", so it treats this document as its map. The omission is visible from inside the document, twice over: - Section 4 walks one call step by step -- endpoint, auth, balance pre-check, key routing, upstream, settle -- and every step but the first has a row in section 3 (auth.rs, billing.rs, router.rs, sse.rs). The module that receives the request is the one missing. - The routes/ row names the platform APIs it serves and does not include the three gateway endpoints, which are registered in src/routes/mod.rs and handled in gateway.rs. One row added, next to routes/ (the two are the parallel HTTP layers: platform API versus model calls). The other production modules that the document never names -- config.rs, main.rs, i18n_pack.rs -- are left alone: section 4's flow does not pass through them, so this reading does not cover them. Tests: cargo test 579 passed / 0 failed; cargo fmt --check and cargo clippy --all-targets clean. No gate reads docs/architecture.md, so this change is unguarded by design -- the axis' standing rule is to correct the data, not to pin one wording. --- docs/architecture.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/architecture.md b/docs/architecture.md index d937bc9..6535a70 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -34,6 +34,7 @@ | `auth.rs` / `mail.rs` | Bearer 认证(API Key)+ argon2;SMTP 验证码(重试 2 次,共 3 次尝试) | | `db.rs` | SQLite 建表 + 幂等迁移 + seed(models 表启动时同步 config `[[models]]`;测试用户 seed 仅测试) | | `dao.rs` | 数据访问层 | +| `gateway.rs` | 网关三条端点(`/v1/chat/completions`、`/v1/responses`、`/anthropic/v1/messages`):取 model → 路由选 key → 按 plan 端点定出站协议(跨协议转换交 `protocol.rs` / `sse.rs`)→ 转发上游 → 解析 usage 交 `billing.rs` 计费;模型 / 套餐列表端点亦在此 | | `routes/` | 认证 / 钱包 / 交易 / 仪表盘 / 共享 / 管理 / 运营者 API | ## 4. 数据流(一次调用)