overview.html 21.5 KB
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>数据库结构总览 — llm-call-platform</title>
<style>
/* === Magic-Vision 设计系统 === */
:root {
  --color-primary: #2563eb; --color-primary-light: #dbeafe; --color-primary-dark: #1e40af;
  --color-success: #16a34a; --color-success-light: #dcfce7;
  --color-warning: #d97706; --color-warning-light: #fef3c7;
  --color-danger: #dc2626; --color-danger-light: #fee2e2;
  --color-pending: #6b7280; --color-pending-light: #f3f4f6;
  --color-bg: #ffffff; --color-bg-secondary: #f8fafc;
  --color-border: #e2e8f0; --color-text: #1e293b;
  --color-text-secondary: #64748b; --color-text-muted: #94a3b8;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  --radius: 8px; --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1); --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-family); background: var(--color-bg-secondary); color: var(--color-text); line-height: 1.6; min-height: 100vh; }
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* 通用组件 */
.badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; }
.badge-confirmed { background: var(--color-success-light); color: var(--color-success); }
.badge-pending { background: var(--color-pending-light); color: var(--color-pending); }
.badge-doubt { background: var(--color-warning-light); color: var(--color-warning); }
.priority { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 0.7rem; font-weight: 700; }
.priority-p0 { background: var(--color-danger-light); color: var(--color-danger); }
.priority-p1 { background: var(--color-warning-light); color: var(--color-warning); }
.priority-p2 { background: var(--color-primary-light); color: var(--color-primary); }
.card { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; background: var(--color-bg-secondary); border-bottom: 1px solid var(--color-border); }
.card-title { margin: 0; font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px; }
.accordion { border: 1px solid var(--color-border); border-radius: var(--radius); margin-bottom: 12px; }
.accordion-summary { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; cursor: pointer; font-weight: 600; background: var(--color-bg-secondary); list-style: none; }
.accordion-summary::-webkit-details-marker { display: none; }
.accordion[open] .accordion-summary { border-bottom: 1px solid var(--color-border); }
.accordion-content { padding: 20px; }
.tabs { margin-bottom: 24px; }
.tab-nav { display: flex; gap: 0; border-bottom: 2px solid var(--color-border); margin-bottom: 20px; }
.tab-btn { padding: 10px 20px; border: none; background: none; cursor: pointer; font-size: 0.9rem; font-weight: 500; color: var(--color-text-secondary); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.tab-btn:hover { color: var(--color-text); }
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th { padding: 12px 14px; text-align: left; font-weight: 600; background: var(--color-bg-secondary); border-bottom: 2px solid var(--color-border); font-size: 0.78rem; text-transform: uppercase; color: var(--color-text-secondary); }
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--color-bg-secondary); }
.stack-tag { display: inline-block; padding: 2px 8px; margin: 2px; background: var(--color-primary-light); color: var(--color-primary-dark); border-radius: 4px; font-size: 0.75rem; font-weight: 500; }
.tree { font-family: var(--font-mono); font-size: 0.875rem; line-height: 2; }
.tree-node { padding: 2px 0; }
.tree-children { padding-left: 24px; border-left: 1px dashed var(--color-border); margin-left: 8px; }
.tree-icon { margin-right: 6px; }
.tree-comment { color: var(--color-text-muted); font-size: 0.8rem; font-family: var(--font-family); margin-left: 8px; }

/* 顶部导航栏 */
.top-nav { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; background: var(--color-bg); border-bottom: 1px solid var(--color-border); box-shadow: var(--shadow); position: sticky; top: 0; z-index: 100; }
.nav-left { display: flex; align-items: center; gap: 8px; }
.nav-title { margin: 0; font-size: 1.25rem; }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-version { font-size: 0.85rem; color: var(--color-text-secondary); }
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-label { font-size: 0.8rem; color: var(--color-text-muted); }
.nav-link { padding: 4px 12px; border-radius: var(--radius-sm); text-decoration: none; font-size: 0.85rem; font-weight: 500; color: var(--color-primary); border: 1px solid var(--color-primary-light); transition: all 0.2s; }
.nav-link:hover { background: var(--color-primary-light); }
.back-link { color: var(--color-text-secondary); text-decoration: none; font-size: 0.85rem; padding: 4px 10px; border-radius: var(--radius-sm); transition: all 0.2s; }
.back-link:hover { color: var(--color-primary); background: var(--color-primary-light); }

/* Hero 标题卡片 */
.hero-card { display: flex; align-items: center; justify-content: space-between; padding: 24px; background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-bg) 100%); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-md); margin-bottom: 24px; }
.hero-title { margin: 0 0 8px; font-size: 1.5rem; }
.hero-goal { margin: 0; color: var(--color-text-secondary); font-size: 1rem; }

/* 页脚 */
.footer { text-align: center; padding: 32px; color: var(--color-text-muted); font-size: 0.8rem; }

/* 信息网格 */
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; margin-bottom: 24px; }
.info-item { display: flex; flex-direction: column; padding: 12px 16px; border-bottom: 1px solid var(--color-border); border-right: 1px solid var(--color-border); }
.info-item:nth-child(3n) { border-right: none; }
.info-full { grid-column: 1 / -1; border-right: none; }
.info-label { font-size: 0.72rem; text-transform: uppercase; color: var(--color-text-muted); margin-bottom: 4px; font-weight: 600; letter-spacing: 0.05em; }
.info-value { font-size: 0.9rem; }
.info-value code { font-family: var(--font-mono); background: var(--color-bg-secondary); padding: 1px 6px; border-radius: 3px; font-size: 0.85rem; }

/* 导航中心 */
.nav-card { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; transition: box-shadow 0.2s; }
.nav-card:hover { box-shadow: var(--shadow-md); }
.nav-card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; background: var(--color-bg-secondary); border-bottom: 1px solid var(--color-border); }
.nav-card-title { display: flex; align-items: center; gap: 10px; font-size: 1rem; font-weight: 600; }
.nav-card-icon { font-size: 1.2rem; }
.nav-card-date { font-size: 0.75rem; color: var(--color-text-muted); }
.nav-card-body { padding: 8px 0; }
.nav-card-body.empty { padding: 20px 24px; color: var(--color-text-muted); font-style: italic; text-align: center; }
.nav-file-link { display: flex; align-items: center; padding: 8px 24px; text-decoration: none; color: var(--color-text); font-size: 0.9rem; transition: background 0.15s; }
.nav-file-link:hover { background: var(--color-primary-light); color: var(--color-primary); }
.nav-file-link .file-icon { margin-right: 10px; font-size: 0.85rem; flex-shrink: 0; }
.nav-file-link .file-desc { margin-left: auto; font-size: 0.78rem; color: var(--color-text-muted); }

/* Toast */
.toast { position: fixed; bottom: 20px; right: 20px; background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 6px; font-size: 13px; opacity: 0; transition: opacity .2s; z-index: 200; }
.toast.show { opacity: 1; }

/* 交互图 */
.diagram-container { background: var(--color-bg-secondary); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; overflow-x: auto; }
.interaction-svg, .flow-svg, .dep-svg { width: 100%; height: auto; }
.node-box { fill: var(--color-bg); stroke-width: 2; }
.node-t01 { stroke: var(--color-primary); }
.node-t02 { stroke: var(--color-success); }
.node-db { stroke: var(--color-warning); }
.node-title { font-size: 0.85rem; font-weight: 700; fill: var(--color-text); }
.node-subtitle { font-size: 0.7rem; fill: var(--color-text-secondary); }
.edge { stroke: var(--color-text-muted); stroke-width: 2; }
.edge-label { font-size: 0.7rem; fill: var(--color-text-secondary); }

/* 技术栈卡片网格 */
.tech-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-bottom: 24px; }
.tech-card { position: relative; padding: 20px; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-bg); box-shadow: var(--shadow); border-top: 3px solid var(--color-pending); }
.tech-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.tech-card.dimension-frontend { border-top-color: var(--color-primary); }
.tech-card.dimension-backend { border-top-color: var(--color-success); }
.tech-card.dimension-database { border-top-color: var(--color-warning); }
.tech-card.dimension-cache { border-top-color: #e11d48; }
.tech-card.dimension-deploy { border-top-color: #7c3aed; }
.tech-card.dimension-disabled { opacity: 0.55; border-top-color: var(--color-border); }
.tech-card-icon { font-size: 1.5rem; margin-bottom: 8px; }
.tech-dimension { margin: 0 0 12px; font-size: 0.95rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-secondary); }
.tech-choice, .tech-reason, .tech-alt { font-size: 0.85rem; margin-bottom: 8px; color: var(--color-text); }
.tech-na { font-size: 0.85rem; color: var(--color-text-muted); font-style: italic; }
.tech-card .badge { position: absolute; top: 16px; right: 16px; }

.field-type { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 0.72rem; font-weight: 600; font-family: var(--font-mono); }
.type-pk { background: #fef3c7; color: #92400e; }
.type-uuid { background: #e0f2fe; color: #0369a1; }
.type-int { background: #f0fdf4; color: #166534; }
.type-varchar { background: #dbeafe; color: #1e40af; }
.type-text { background: #f3f4f6; color: #374151; }
.type-bool { background: #fce7f3; color: #9d174d; }
.type-ts { background: #ede9fe; color: #5b21b6; }
.type-json { background: #fff7ed; color: #9a3412; }
.constraint-tag { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 0.68rem; font-weight: 600; margin-right: 2px; }
.c-notnull { background: #fee2e2; color: #dc2626; }
.c-unique { background: #fef3c7; color: #92400e; }
.c-default { background: #f3f4f6; color: #6b7280; }
.relation-tag { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 0.72rem; font-weight: 600; }
.rel-11 { background: #dbeafe; color: #1e40af; }
.rel-1n { background: #dcfce7; color: #166534; }
.rel-nm { background: #f3e8ff; color: #6b21a8; }
.table-name { font-family: var(--font-mono); font-weight: 600; color: var(--color-primary); }
.field-name { font-family: var(--font-mono); font-size: 0.85rem; }
.row-pk { background: #fffbeb; }
.row-ts { opacity: 0.65; }
.table-ref { font-family: var(--font-mono); font-weight: 600; color: var(--color-primary); }
.er-table { fill: var(--color-bg); stroke-width: 2; }
.er-table-core { stroke: var(--color-primary); }
.er-table-normal { stroke: var(--color-success); }
.er-table-junction { stroke: var(--color-warning); stroke-dasharray: 6 3; }
</style>
</head>
<body>
<nav class="top-nav">
  <div class="nav-left">
    <a href="../index.html" class="back-link" title="返回文档导航中心">🏠 导航</a>
    <a href="../1-tech-implementation-plan/overview.html" class="back-link">← 技术方案</a>
    <a href="../2-detailed-design/planning-canvas.html" class="back-link">← 功能看板</a>
    <h1 class="nav-title">🗄️ llm-call-platform — 数据库表结构</h1>
  </div>
  <div class="nav-right">
    <span class="nav-version">v1.0</span>
  </div>
</nav>

<main class="container">
  <div class="tabs">
    <div class="tab-nav">
      <button class="tab-btn active" onclick="switchTab(event, 'tab-info')">文档信息</button>
      <button class="tab-btn" onclick="switchTab(event, 'tab-overview')">表总览</button>
      <button class="tab-btn" onclick="switchTab(event, 'tab-er')">ER 关系图</button>
    </div>

    <div class="tab-content active" id="tab-info">
      <div class="card">
        <div class="card-header"><h3 class="card-title">文档信息</h3></div>
        <div class="card-body">
          <table class="data-table">
            <tr><td style="width:120px;font-weight:600">项目名称</td><td>llm-call-platform</td></tr>
            <tr><td style="width:120px;font-weight:600">文档版本</td><td>v1.0</td></tr>
            <tr><td style="width:120px;font-weight:600">创建日期</td><td>2026-06-11</td></tr>
            <tr><td style="width:120px;font-weight:600">数据表总数</td><td>10</td></tr>
          </table>
        </div>
      </div>
    </div>

    <div class="tab-content" id="tab-overview">
      <table class="data-table">
        <thead><tr><th>表名</th><th>用途</th><th>关联功能</th><th>字段数</th><th>详情</th></tr></thead>
        <tbody><tr>
  <td><span class="table-name">ai_llmbase_model_providers</span></td>
  <td>模型供应商注册信息,记录支持的模型供应商元数据</td>
  <td>F-01</td>
  <td>11</td>
  <td><a href="M-01-ai_llmbase_model_providers.html" class="detail-link">详情</a></td>
</tr>
<tr>
  <td><span class="table-name">ai_llmbase_model_account_config</span></td>
  <td>模型账号配置,记录每个供应商的 API Key、Endpoint 等账号信息</td>
  <td>F-01</td>
  <td>13</td>
  <td><a href="M-02-ai_llmbase_model_account_config.html" class="detail-link">详情</a></td>
</tr>
<tr>
  <td><span class="table-name">ai_llmbase_call_strategy_config</span></td>
  <td>调用策略配置,管理每个模型/业务类型的策略链</td>
  <td>F-02</td>
  <td>17</td>
  <td><a href="M-03-ai_llmbase_call_strategy_config.html" class="detail-link">详情</a></td>
</tr>
<tr>
  <td><span class="table-name">ai_llmbase_prompt_templates</span></td>
  <td>提示词模板,管理 System/User Prompt 模板和版本</td>
  <td>F-03</td>
  <td>10</td>
  <td><a href="M-04-ai_llmbase_prompt_templates.html" class="detail-link">详情</a></td>
</tr>
<tr>
  <td><span class="table-name">ai_llmbase_call_records</span></td>
  <td>模型调用记录,记录每次模型调用的完整信息</td>
  <td>F-04</td>
  <td>16</td>
  <td><a href="M-05-ai_llmbase_call_records.html" class="detail-link">详情</a></td>
</tr>
<tr>
  <td><span class="table-name">ai_llmbase_async_tasks</span></td>
  <td>异步任务记录,跟踪 Celery 异步任务的状态和结果</td>
  <td>F-04</td>
  <td>10</td>
  <td><a href="M-06-ai_llmbase_async_tasks.html" class="detail-link">详情</a></td>
</tr>
<tr>
  <td><span class="table-name">ai_llmbase_call_statistics</span></td>
  <td>调用统计聚合,按小时/天预聚合的统计数据</td>
  <td>F-05</td>
  <td>18</td>
  <td><a href="M-07-ai_llmbase_call_statistics.html" class="detail-link">详情</a></td>
</tr>
<tr>
  <td><span class="table-name">ai_llmbase_users</span></td>
  <td>API 用户信息,管理 API 调用方账号</td>
  <td>F-06</td>
  <td>9</td>
  <td><a href="M-08-ai_llmbase_users.html" class="detail-link">详情</a></td>
</tr>
<tr>
  <td><span class="table-name">ai_llmbase_api_tokens</span></td>
  <td>API Token 管理,存储用户颁发的 JWT Token 和 API Key</td>
  <td>F-06</td>
  <td>8</td>
  <td><a href="M-09-ai_llmbase_api_tokens.html" class="detail-link">详情</a></td>
</tr>
<tr>
  <td><span class="table-name">ai_llmbase_word_bank</span></td>
  <td>敏感词库,管理敏感词列表和替换规则</td>
  <td>F-07</td>
  <td>7</td>
  <td><a href="M-10-ai_llmbase_word_bank.html" class="detail-link">详情</a></td>
</tr>
</tbody>
      </table>
    </div>

    <div class="tab-content" id="tab-er">
      <div class="diagram-container">
        <div class="diagram-container">
<svg viewBox="0 0 1100 700" xmlns="http://www.w3.org/2000/svg" class="interaction-svg">
  <!-- 核心表 -->
  <rect x="400" y="20" width="200" height="60" rx="8" class="node-box node-db"/>
  <text x="500" y="48" text-anchor="middle" class="node-title">ai_llmbase_call_records</text>
  <text x="500" y="66" text-anchor="middle" class="node-subtitle">调用记录(核心表)</text>

  <!-- 供应商 -->
  <rect x="50" y="20" width="200" height="60" rx="8" class="node-box node-t01"/>
  <text x="150" y="48" text-anchor="middle" class="node-title">ai_llmbase_model_providers</text>
  <text x="150" y="66" text-anchor="middle" class="node-subtitle">模型供应商</text>

  <!-- 账号配置 -->
  <rect x="50" y="150" width="200" height="60" rx="8" class="node-box node-t02"/>
  <text x="150" y="178" text-anchor="middle" class="node-title">ai_llmbase_model_account_config</text>
  <text x="150" y="196" text-anchor="middle" class="node-subtitle">模型账号配置</text>

  <!-- 策略配置 -->
  <rect x="50" y="280" width="200" height="60" rx="8" class="node-box node-t01"/>
  <text x="150" y="308" text-anchor="middle" class="node-title">ai_llmbase_call_strategy_config</text>
  <text x="150" y="326" text-anchor="middle" class="node-subtitle">调用策略配置</text>

  <!-- 提示词模板 -->
  <rect x="50" y="400" width="200" height="60" rx="8" class="node-box node-t02"/>
  <text x="150" y="428" text-anchor="middle" class="node-title">ai_llmbase_prompt_templates</text>
  <text x="150" y="446" text-anchor="middle" class="node-subtitle">提示词模板</text>

  <!-- 异步任务 -->
  <rect x="750" y="20" width="240" height="60" rx="8" class="node-box node-t02"/>
  <text x="870" y="48" text-anchor="middle" class="node-title">ai_llmbase_async_tasks</text>
  <text x="870" y="66" text-anchor="middle" class="node-subtitle">异步任务记录</text>

  <!-- 统计 -->
  <rect x="750" y="150" width="240" height="60" rx="8" class="node-box node-t01"/>
  <text x="870" y="178" text-anchor="middle" class="node-title">ai_llmbase_call_statistics</text>
  <text x="870" y="196" text-anchor="middle" class="node-subtitle">调用统计聚合</text>

  <!-- 用户 -->
  <rect x="400" y="400" width="200" height="60" rx="8" class="node-box node-t01"/>
  <text x="500" y="428" text-anchor="middle" class="node-title">ai_llmbase_users</text>
  <text x="500" y="446" text-anchor="middle" class="node-subtitle">用户</text>

  <!-- API Tokens -->
  <rect x="400" y="530" width="200" height="60" rx="8" class="node-box node-t02"/>
  <text x="500" y="558" text-anchor="middle" class="node-title">ai_llmbase_api_tokens</text>
  <text x="500" y="576" text-anchor="middle" class="node-subtitle">API Token</text>

  <!-- 敏感词库 -->
  <rect x="750" y="400" width="240" height="60" rx="8" class="node-box node-t02"/>
  <text x="870" y="428" text-anchor="middle" class="node-title">ai_llmbase_word_bank</text>
  <text x="870" y="446" text-anchor="middle" class="node-subtitle">敏感词库</text>

  <!-- 连线 -->
  <line x1="250" y1="50" x2="400" y2="50" class="edge"/>
  <text x="325" y="44" text-anchor="middle" class="edge-label">1:N</text>

  <line x1="250" y1="180" x2="400" y2="50" class="edge"/>
  <text x="325" y="118" text-anchor="middle" class="edge-label">1:N</text>

  <line x1="250" y1="310" x2="400" y2="50" class="edge"/>
  <text x="315" y="185" text-anchor="middle" class="edge-label">策略→调用</text>

  <line x1="250" y1="50" x2="250" y1="150" class="edge"/>
  <text x="140" y="110" text-anchor="middle" class="edge-label" fill="var(--color-text-muted)">1:N</text>

  <line x1="150" y1="210" x2="150" y1="280" class="edge"/>
  <text x="45" y="250" text-anchor="middle" class="edge-label" fill="var(--color-text-muted)">1:N</text>

  <line x1="600" y1="50" x2="750" y2="50" class="edge"/>
  <text x="675" y="44" text-anchor="middle" class="edge-label">1:N</text>

  <line x1="600" y1="50" x2="870" y2="150" class="edge"/>
  <text x="700" y="108" text-anchor="middle" class="edge-label">统计引用</text>

  <line x1="500" y1="80" x2="500" y2="400" class="edge"/>
  <text x="512" y="245" text-anchor="middle" class="edge-label" fill="var(--color-text-muted)">—</text>

  <line x1="500" y1="460" x2="500" y2="530" class="edge"/>
  <text x="400" y="500" text-anchor="middle" class="edge-label" fill="var(--color-text-muted)">1:N</text>
</svg>
</div>
      </div>
    </div>
  </div>
</main>
<footer class="footer">Magic-Vision-Spec · 数据库表结构 · v1.0</footer>

<script>
function switchTab(event, tabId) {
  document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active'));
  document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active'));
  event.target.classList.add('active');
  document.getElementById(tabId).classList.add('active');
}
</script>
</body>
</html>