feat(backend): P0-A skeleton — axum server, TOML config, SQLite schema+seed, argon2 auth, api-key endpoints (v0.2.0) - #71
Merged
Conversation
…a+seed, argon2 auth, api-key endpoints (v0.2.0)
This was referenced Aug 17, 2026
argszero
added a commit
that referenced
this pull request
Aug 18, 2026
- §4.1 网关层标注已实现:OpenAI/Anthropic 双协议 + SSE 流式 + 余额预检(可用余额口径)+ 完整 API 一览 - §4.2 补上游 key AES-256-GCM 加密(v1:<nonce>:<cipher>,ATP_MASTER_KEY → config.master_key → dev 随机兜底) - §4.3/4.4 计量与账本标注已实现:点数公式、事务性 settle、双余额账户、每日赠送/惰性过期清理、先赠后永扣减、SHARE_RATIO=0.9、管理员充值 topup - §4.6 管理台补管理员 API(role 判定/403、种子账号) - §5 数据库设计改为实表(gift_grants/schema_version/quotas 双列),§6 补配置说明 - §7 路线勾掉 P0/P1(v0.1.0→v0.3.0,PR #71–#75) Co-authored-by: argszero <argszero@argszerodeMac-mini.local>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
P0-A of rant
2026-08-17T22:21:52(后端实现 P0-A — 服务骨架 + 配置加载 + SQLite 数据层 + 认证, v0.2.0): first backend milestone implementing the UI prototype (docs ready: architecture v0.2 / user-stories v1.12 / plan-api-matrix).Scope delivered
src/main.rs): axum Router on0.0.0.0:8080(config[server].addr);GET /healthz→{"status":"ok","version":"0.2.0"}; clap--config(defaultconfig/config.toml, printscp config.example.toml config/config.tomlhint + exit 1 if missing); env_logger +tower_http::trace::TraceLayerrequest loggingsrc/config.rs):Configmirroringconfig/config.example.toml—[server](addr/db_path with defaults) /[points](anchor_currency / points_per_unit / display_name / symbol) /providers[](id/name/country/has_plan) /plans[](id/provider/type/key_prefix/interactive_only/endpoints[{protocol,base_url}]) /price_overrides[]; serde deserialization + unit test parsing the example filesrc/db.rs): SQLite (rusqlite bundled), path from[server].db_path(defaultdata/aitokenpool.db); tables per architecture §5 —users/keys(upstream, provider/plan/model/status/owner_id/encrypted_key) /api_keys(atk_live_ prefix) /models/quotas/transactions/usage_records+schema_version; idempotent migrations (re-run safe); dev seed: demo user (demo@aitokenpool.local / demo1234, argon2) + points account (12471) + example upstream keysrc/auth.rs+src/routes/mod.rs):POST /api/auth/login— argon2 verify → returns the user's valid API Key (get-or-create);AuthUserextractor —Authorization: Bearer <key>→ api_keys lookup → inject user id; invalid → 401 JSONsrc/routes/api_keys.rs):POST /api/api-keysgeneratesatk_live_+ 24 hex (UI-prototype parity);GET /api/api-keysreturns masked list (atk_live_****xxxx)Acceptance criteria (all verified)
cargo build+cargo testpass (Rust 1.86) — 10/10 tests (config parse / idempotent migration / seed / argon2 roundtrip / key format+mask / healthz / login 200 / login 401 / api-keys create+list / no-bearer 401)cargo clippy --all-targets -- -D warningsclean,cargo fmt --checkcleanGET /healthz200; login correct → 200{api_key}, wrong → 401; POST/GET api-keys with Bearer; invalid/missing Bearer → 401; missing config → hint + exit 1feat/backend-p0a-skeleton, version v0.2.0, README status updatedRant reference (verbatim)
Progress on rant 22:21:52: P0-A done (PR #71); next P0 stages — gateway routing / usage tracking.