Files
tiku-backend.net/docs/assets/tiku-backend-architecture.svg

237 lines
14 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<svg xmlns="http://www.w3.org/2000/svg" width="1600" height="1080" viewBox="0 0 1600 1080" role="img" aria-labelledby="title desc">
<title id="title">TIKU Backend 当前技术架构图</title>
<desc id="desc">TIKU Backend 是 ASP.NET Core 模块化单体。API、Worker 和 DbMigrator 共享 Application 契约、Infrastructure 实现以及 PostgreSQL、Redis、RabbitMQ 和外部服务。</desc>
<defs>
<marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto">
<path d="M0 0L10 5L0 10Z" fill="#334155"/>
</marker>
<marker id="arrowBlue" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto">
<path d="M0 0L10 5L0 10Z" fill="#1686d9"/>
</marker>
<style>
text { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif; letter-spacing: 0; }
.bg { fill: #fff; }
.title { fill: #172033; font-size: 34px; font-weight: 700; }
.subtitle { fill: #5f6b7a; font-size: 16px; font-weight: 400; }
.group { fill: #fbfdff; stroke: #1686d9; stroke-width: 2; stroke-dasharray: 10 8; }
.group-title { fill: #e11d2e; font-size: 22px; font-weight: 700; }
.node { fill: #fff; stroke: #cbd5e1; stroke-width: 1.5; }
.node-blue { fill: #edf7ff; stroke: #69aee0; stroke-width: 1.5; }
.node-green { fill: #effaf3; stroke: #78bc8b; stroke-width: 1.5; }
.node-amber { fill: #fff8e8; stroke: #d5ad52; stroke-width: 1.5; }
.node-violet { fill: #f7f1fb; stroke: #ae8bc3; stroke-width: 1.5; }
.node-title { fill: #172033; font-size: 17px; font-weight: 700; }
.node-text { fill: #526070; font-size: 13px; font-weight: 400; }
.node-tiny { fill: #64748b; font-size: 12px; font-weight: 400; }
.badge { fill: #1686d9; }
.badge-text { fill: #fff; font-size: 16px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.edge { fill: none; stroke: #334155; stroke-width: 1.8; marker-end: url(#arrow); }
.edge-blue { fill: none; stroke: #1686d9; stroke-width: 2; marker-end: url(#arrowBlue); }
.edge-dash { fill: none; stroke: #64748b; stroke-width: 1.6; stroke-dasharray: 7 6; marker-end: url(#arrow); }
.edge-label { fill: #475569; font-size: 13px; font-weight: 500; }
.boundary { fill: #fffdf4; stroke: #d2ad3e; stroke-width: 1.5; stroke-dasharray: 8 6; }
.boundary-text { fill: #614d11; font-size: 14px; font-weight: 500; }
</style>
</defs>
<rect class="bg" width="1600" height="1080"/>
<text class="title" x="56" y="54">TIKU Backend 当前技术架构</text>
<text class="subtitle" x="57" y="82">ASP.NET Core 模块化单体 · Application 定义契约与上下文 · Infrastructure 提供业务、持久化和 Provider 实现</text>
<!-- Clients -->
<text class="group-title" x="48" y="129">访问端</text>
<rect class="group" x="40" y="145" width="230" height="570" rx="4"/>
<rect class="node-blue" x="66" y="180" width="178" height="92" rx="6"/>
<circle class="badge" cx="96" cy="211" r="18"/>
<text class="badge-text" x="96" y="211">P</text>
<text class="node-title" x="124" y="207">平台管理端</text>
<text class="node-text" x="84" y="239">/platform-admin 静态原型</text>
<text class="node-tiny" x="84" y="258">平台账号 · SaaS 运营</text>
<rect class="node-blue" x="66" y="307" width="178" height="92" rx="6"/>
<circle class="badge" cx="96" cy="338" r="18"/>
<text class="badge-text" x="96" y="338">T</text>
<text class="node-title" x="124" y="334">租户管理端</text>
<text class="node-text" x="84" y="366">内容与业务运营</text>
<text class="node-tiny" x="84" y="385">租户 Realm · RBAC</text>
<rect class="node-blue" x="66" y="434" width="178" height="92" rx="6"/>
<circle class="badge" cx="96" cy="465" r="18"/>
<text class="badge-text" x="96" y="465">H5</text>
<text class="node-title" x="124" y="461">学员端</text>
<text class="node-text" x="84" y="493">H5 / 小程序 / App</text>
<text class="node-tiny" x="84" y="512">学习 · 题库 · 商城</text>
<rect class="node-blue" x="66" y="561" width="178" height="92" rx="6"/>
<circle class="badge" cx="96" cy="592" r="18"/>
<text class="badge-text" x="96" y="592"></text>
<text class="node-title" x="124" y="588">外部回调</text>
<text class="node-text" x="84" y="620">微信 / 支付通知</text>
<text class="node-tiny" x="84" y="639">签名校验 · 幂等处理</text>
<!-- API -->
<text class="group-title" x="318" y="129">HTTP 接入与安全管线</text>
<rect class="group" x="310" y="145" width="355" height="570" rx="4"/>
<rect class="node-blue" x="338" y="180" width="299" height="92" rx="6"/>
<circle class="badge" cx="371" cy="211" r="18"/>
<text class="badge-text" x="371" y="211">API</text>
<text class="node-title" x="402" y="207">Tiku.Api</text>
<text class="node-text" x="356" y="239">ASP.NET Core Controller API</text>
<text class="node-tiny" x="356" y="258">OpenAPI / Scalar · 静态文件</text>
<rect class="node" x="338" y="307" width="299" height="184" rx="6"/>
<text class="node-title" x="358" y="337">请求管线(按执行顺序)</text>
<text class="node-text" x="358" y="367">1 日志 / 异常 / Forwarded Headers / HTTPS</text>
<text class="node-text" x="358" y="393">2 Static / Routing / CORS</text>
<text class="node-text" x="358" y="419">3 可信 Host 租户解析 / Browser CSRF</text>
<text class="node-text" x="358" y="445">4 JWT / 认证分区限流 / Rate Limiter</text>
<text class="node-text" x="358" y="471">5 CurrentPrincipal / Authorization / Feature</text>
<rect class="node-green" x="338" y="526" width="299" height="127" rx="6"/>
<text class="node-title" x="358" y="556">Controller 边界</text>
<text class="node-text" x="358" y="584">平台 SaaS 管理 · 租户后台</text>
<text class="node-text" x="358" y="608">题库内容学习 · 商城增长</text>
<text class="node-text" x="358" y="632">认证运行时 · 支付回调 · 后台任务</text>
<path class="edge-blue" d="M244 226H338"/>
<path class="edge-blue" d="M244 353H338"/>
<path class="edge-blue" d="M244 480H338"/>
<path class="edge-blue" d="M244 607H338"/>
<text class="edge-label" x="272" y="214">HTTPS</text>
<!-- Modular monolith -->
<text class="group-title" x="713" y="129">模块化单体业务核心</text>
<rect class="group" x="705" y="145" width="565" height="570" rx="4"/>
<rect class="node-green" x="733" y="180" width="509" height="98" rx="6"/>
<text class="node-title" x="755" y="210">Tiku.Application契约与执行上下文</text>
<text class="node-text" x="755" y="239">用例接口 / Provider 接口 · TenantContext · CurrentUser</text>
<text class="node-tiny" x="755" y="261">仅引用 Domain不包含 EF Core 与第三方 SDK</text>
<rect class="node-amber" x="733" y="307" width="509" height="92" rx="6"/>
<text class="node-title" x="755" y="337">Tiku.Domain领域模型</text>
<text class="node-text" x="755" y="366">Identity · Tenant · Catalog · QuestionBank · Content</text>
<text class="node-tiny" x="755" y="387">Learning · Commerce · Growth · Operations · Platform</text>
<rect class="node-violet" x="733" y="428" width="509" height="225" rx="6"/>
<text class="node-title" x="755" y="458">Tiku.Infrastructure当前业务实现与适配器</text>
<rect class="node" x="755" y="480" width="144" height="142" rx="5"/>
<text class="node-title" x="773" y="508">平台底座</text>
<text class="node-text" x="773" y="535">身份认证</text>
<text class="node-text" x="773" y="558">租户 / 域名</text>
<text class="node-text" x="773" y="581">RBAC / Feature</text>
<text class="node-text" x="773" y="604">SaaS / 审计</text>
<rect class="node" x="915" y="480" width="144" height="142" rx="5"/>
<text class="node-title" x="933" y="508">教育业务</text>
<text class="node-text" x="933" y="535">分类 / 内容</text>
<text class="node-text" x="933" y="558">题库 / 视频</text>
<text class="node-text" x="933" y="581">学习 / 分数线</text>
<text class="node-text" x="933" y="604">档案 / 资源</text>
<rect class="node" x="1075" y="480" width="144" height="142" rx="5"/>
<text class="node-title" x="1093" y="508">交易增长</text>
<text class="node-text" x="1093" y="535">订单 / 支付</text>
<text class="node-text" x="1093" y="558">积分 / 推荐</text>
<text class="node-text" x="1093" y="581">CRM / 佣金</text>
<text class="node-text" x="1093" y="604">平台账务</text>
<path class="edge-blue" d="M637 589H733"/>
<text class="edge-label" x="658" y="577">调用契约</text>
<path class="edge" d="M987 278V307"/>
<text class="edge-label" x="997" y="298">引用</text>
<path class="edge-dash" d="M827 428V399"/>
<path class="edge-dash" d="M1147 428C1147 412 1110 407 1050 399"/>
<text class="edge-label" x="844" y="418">实现 Application 接口并操作 Domain</text>
<!-- Processes -->
<text class="group-title" x="1318" y="129">独立运行入口</text>
<rect class="group" x="1310" y="145" width="250" height="570" rx="4"/>
<rect class="node-green" x="1336" y="180" width="198" height="192" rx="6"/>
<circle class="badge" cx="1368" cy="211" r="18"/>
<text class="badge-text" x="1368" y="211">W</text>
<text class="node-title" x="1398" y="207">Tiku.Worker</text>
<text class="node-text" x="1354" y="242">域名 DNS / TLS 生命周期</text>
<text class="node-text" x="1354" y="269">SaaS 订阅生命周期</text>
<text class="node-text" x="1354" y="296">Feature 用量校准</text>
<text class="node-text" x="1354" y="323">后台任务租约执行</text>
<text class="node-text" x="1354" y="350">RabbitMQ 消费者</text>
<rect class="node-amber" x="1336" y="408" width="198" height="144" rx="6"/>
<circle class="badge" cx="1368" cy="439" r="18"/>
<text class="badge-text" x="1368" y="439">DB</text>
<text class="node-title" x="1398" y="435">Tiku.DbMigrator</text>
<text class="node-text" x="1354" y="471">EF Core Migrate</text>
<text class="node-text" x="1354" y="498">Development Seed</text>
<text class="node-text" x="1354" y="525">平台管理员安全引导</text>
<rect class="node" x="1336" y="588" width="198" height="65" rx="6"/>
<text class="node-title" x="1354" y="616">共享组合方式</text>
<text class="node-tiny" x="1354" y="638">Application + Infrastructure</text>
<path class="edge-dash" d="M1336 276H1242"/>
<path class="edge-dash" d="M1336 480H1242"/>
<!-- Data and external systems -->
<text class="group-title" x="48" y="773">数据、消息与外部服务</text>
<rect class="group" x="40" y="790" width="1520" height="212" rx="4"/>
<rect class="node-violet" x="70" y="826" width="270" height="138" rx="6"/>
<circle class="badge" cx="105" cy="859" r="20"/>
<text class="badge-text" x="105" y="859">PG</text>
<text class="node-title" x="139" y="854">PostgreSQL</text>
<text class="node-text" x="92" y="892">EF Core 实体 / Identity / AuthSession</text>
<text class="node-text" x="92" y="917">业务数据 / BackgroundJob / Outbox</text>
<text class="node-tiny" x="92" y="944">Query Filter · 写入拦截 · 数据库 Guard</text>
<rect class="node-violet" x="372" y="826" width="205" height="138" rx="6"/>
<circle class="badge" cx="407" cy="859" r="20"/>
<text class="badge-text" x="407" y="859">R</text>
<text class="node-title" x="441" y="854">Redis</text>
<text class="node-text" x="394" y="892">安全状态与失效广播</text>
<text class="node-text" x="394" y="917">分布式缓存</text>
<text class="node-tiny" x="394" y="944">Production 必需</text>
<rect class="node-violet" x="609" y="826" width="225" height="138" rx="6"/>
<circle class="badge" cx="644" cy="859" r="20"/>
<text class="badge-text" x="644" y="859">MQ</text>
<text class="node-title" x="678" y="854">RabbitMQ</text>
<text class="node-text" x="631" y="892">MassTransit + EF Outbox</text>
<text class="node-text" x="631" y="917">安全状态 / 后台任务消息</text>
<text class="node-tiny" x="631" y="944">API 发布 · Worker 消费</text>
<rect class="node-blue" x="866" y="826" width="205" height="138" rx="6"/>
<text class="node-title" x="890" y="856">对象存储</text>
<text class="node-text" x="890" y="892">Alibaba Cloud OSS</text>
<text class="node-text" x="890" y="917">预签名上传 / 资源访问</text>
<text class="node-tiny" x="890" y="944">IObjectStorageService</text>
<rect class="node-blue" x="1103" y="826" width="205" height="138" rx="6"/>
<text class="node-title" x="1127" y="856">通信与支付</text>
<text class="node-text" x="1127" y="892">阿里云短信 · 微信 OAuth</text>
<text class="node-text" x="1127" y="917">微信支付 · 支付宝</text>
<text class="node-tiny" x="1127" y="944">租户级配置与加密 Secret</text>
<rect class="node-blue" x="1340" y="826" width="190" height="138" rx="6"/>
<text class="node-title" x="1364" y="856">域名基础设施</text>
<text class="node-text" x="1364" y="892">DNS 所有权校验</text>
<text class="node-text" x="1364" y="917">HTTP 网关开通</text>
<text class="node-tiny" x="1364" y="944">自定义域名生命周期</text>
<path class="edge" d="M850 715C850 766 205 768 205 826"/>
<path class="edge" d="M930 715C930 774 474 770 474 826"/>
<path class="edge" d="M1010 715C1010 780 721 774 721 826"/>
<path class="edge" d="M1070 715C1070 766 968 770 968 826"/>
<path class="edge" d="M1130 715C1130 765 1205 770 1205 826"/>
<path class="edge" d="M1190 715C1190 756 1435 766 1435 826"/>
<path class="edge-dash" d="M1435 653V748C1435 778 721 784 721 826"/>
<!-- Project dependency direction -->
<rect class="boundary" x="40" y="1025" width="1520" height="38" rx="4"/>
<text class="boundary-text" x="61" y="1050">项目依赖方向Api → Application + Infrastructure Worker → Application + Infrastructure DbMigrator → Infrastructure Infrastructure → Application + Domain + Contracts Application → Domain</text>
</svg>