Files
RAG/backend
YoVinchen cfd6d4cbad
Some checks failed
verify / verify (push) Has been cancelled
Expose a runnable backend without giving the ingress layer secrets
The backend can now be inspected through a loopback-only gateway while the database-aware API remains on the internal data network. A governed synthetic demo proves readiness, pgvector retrieval, reranking, and citation output through real HTTP without invoking cloud models.

Constraint: The previously exposed Bailian key is compromised and cannot be used for live validation

Constraint: The API must be locally reachable while retaining no internet egress

Rejected: Attach the API directly to the ingress network | a real socket test proved that configuration still had egress

Rejected: Publish a port from the internal-only network | Docker Desktop did not expose the host port

Confidence: high

Scope-risk: moderate

Reversibility: clean

Directive: Keep model and database credentials out of the gateway; do not relax the fixed demo identity/profile filters

Tested: make verify; 63 pytest tests; strict mypy; Ruff; Secret scan; Compose config; three backend image builds; API/DB/gateway healthy; migration exit 0; Swagger browser check; live/ready/meta/status/search HTTP; 20/20/20 index; API egress ENETUNREACH; empty gateway mounts and business environment

Not-tested: Live Bailian calls require a newly rotated key; full generated-answer flow and React UI are not implemented
2026-07-12 16:37:02 +08:00
..

Backend

Python/FastAPI 后端代码位于本目录。实现阶段采用模块化单体,同一代码镜像分别运行 API 与持久化任务 Worker。

规划边界:

backend/
├── app/
│   ├── api/v1/            HTTP/SSE 接口
│   ├── core/              配置、安全、日志、遥测
│   ├── domain/            领域实体与状态机
│   ├── ports/             外部能力协议(依赖倒置边界)
│   ├── services/          入库、检索、生成、评测用例
│   ├── adapters/          百炼、解析器、文件存储等外部适配器
│   ├── persistence/       SQLAlchemy 模型与仓储
│   ├── workers/           PostgreSQL 任务队列消费者
│   ├── tools/             模型探测、seed 与离线运维入口
│   └── prompts/           版本化提示词
└── tests/
    ├── unit/
    ├── integration/
    └── contract/

前端不得直接访问百炼API Key 读取逻辑只允许存在于后端配置层。