building-data-apps

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Building Data Applications

构建数据应用

Architect high-quality data dashboards and interactive reports. You MUST select the appropriate framework before implementation.
打造高质量的数据仪表盘和交互式报表。实施前必须选择合适的框架。

Step 0: Framework Selection

步骤0:框架选择

You MUST select the framework based on the user's maintenance requirements and data ecosystem.
必须根据用户的维护需求和数据生态系统选择框架。

Choice: Streamlit

选项:Streamlit

  • User Profile: Data Scientists / Python users.
  • Logic Complexity: High Python dependency (Pandas, NumPy, local data processing).
  • Deployment: Single-file Python script.
  • Customization: Standard layout (fast boilerplate).
  • 用户画像:数据科学家 / Python 用户。
  • 逻辑复杂度:高度依赖Python(Pandas、NumPy、本地数据处理)。
  • 部署方式:单文件Python脚本。
  • 自定义程度:标准布局(快速生成模板)。

Choice: React + Vite

选项:React + Vite

  • User Profile: Web Developers / Full-stack teams.
  • Logic Complexity: High UI and Interactivity requirements (e.g., drag-and-drop, interactive maps).
  • Deployment: Standalone Frontend + Backend API.
  • Customization: Infinite (Custom CSS, specialized JS libraries).
  • 用户画像:Web开发人员 / 全栈团队。
  • 逻辑复杂度:对UI和交互性要求高(例如拖拽、交互式地图)。
  • 部署方式:独立前端 + 后端API。
  • 自定义程度:无限自定义(自定义CSS、专用JS库)。

Guidance:

指导原则:

  • Check for existing stack first: ALWAYS prefer the framework the user is already using in their project (e.g., if you see a
    package.json
    with React dependencies, use React; if you see existing Streamlit files, use Streamlit).
  • Default to React + Vite for production-grade applications that require complex client-side state, custom branding, or integration into a larger web ecosystem.
  • Default to Streamlit if the user specifically mentions "Python dashboard", needs to iterate on complex local Python data processing, or requires a single-script deployment.
  • 优先检查现有技术栈:始终优先选择用户项目中已在使用的框架(例如,如果发现包含React依赖的
    package.json
    ,则使用React;如果存在现有Streamlit文件,则使用Streamlit)。
  • 生产级应用默认选择React + Vite:如果需要复杂的客户端状态管理、自定义品牌标识,或需集成到更大的Web生态系统中,默认使用React + Vite。
  • 特定场景默认选择Streamlit:如果用户明确提到“Python仪表盘”,需要对复杂的本地Python数据处理进行迭代,或要求单脚本部署,则默认使用Streamlit。

Step 1: Implementation Plan

步骤1:实施计划

You MUST propose a plan to the user that specifies the chosen framework and justifies the choice based on the criteria above.

必须向用户提交一份计划,明确所选框架,并根据上述标准说明选择理由。

Shared Design Standards

通用设计标准

Regardless of framework, you MUST follow the principles in
resources/shared_design_system.md
.
  • Visual Style: Minimal chrome, zinc color palette, and card-based layouts.
  • Typography:
    DM Sans
    for content,
    JetBrains Mono
    for data.

无论选择哪种框架,都必须遵循
resources/shared_design_system.md
中的原则。
  • 视觉风格:极简边框、锌色调色板、卡片式布局。
  • 字体:内容使用
    DM Sans
    ,数据使用
    JetBrains Mono

Framework Implementation

框架实施

If using Streamlit:

若使用Streamlit:

  1. Read
    resources/streamlit_framework.md
    for detailed CSS and component patterns.
  2. Follow the "Checklist for New Dashboards" in that file.
  1. 阅读
    resources/streamlit_framework.md
    获取详细的CSS和组件模式。
  2. 遵循该文件中的“新仪表盘检查清单”。

If using React + Vite:

若使用React + Vite:

  1. Read
    resources/react_framework.md
    for Tailwind and ECharts setup.
  2. Follow the detailed component guidelines for KPI cards, Tables, and Panels.

  1. 阅读
    resources/react_framework.md
    了解Tailwind和ECharts的设置方法。
  2. 遵循KPI卡片、表格和面板的详细组件指南。

AI Chat Interface (Optional Feature)

AI聊天界面(可选功能)

> [!IMPORTANT]
>
> If the user does not explicitly request a chat interface, you SHOULD
> proactively ask them: "Would you like to include a Gemini-powered chat
> interface to enable natural language queries against your data?" OR if
> there is an implementation plan: "Would you like to include a
> Gemini-powered chat interface to enable natural language queries against
> your data? Let me know and I'll update the plan!".
If the user requests or agrees to the chat interface:
> [!CAUTION]
>
> Adding the chat interface is a significant change. Implicit approval of
> the implementation plan for including the chat interface MUST never be
> assumed.
  1. Gather Technical Details: You MUST read
    resources/chat_integration.md
    for the technical requirements.
  2. Update the implementation plan: If and only if there is an implementation plan, you MUST update the implementation plan. This is a significant change so the user must explicitly approve the updated plan.
  3. Verify Prerequisites: Ensure the user has the Gemini Data Analytics API enabled and data exists in BigQuery.
  4. Reference Examples: Adapt the patterns in
    examples/react_chat_panel.jsx
    and either
    examples/fastapi_chat.py
    or
    examples/express_chat.ts
    .
> [!IMPORTANT]
>
> 如果用户未明确要求聊天界面,应主动询问用户:“是否需要集成由Gemini驱动的聊天界面,以支持对数据进行自然语言查询?” 若已有实施计划,则询问:“是否需要集成由Gemini驱动的聊天界面,以支持对数据进行自然语言查询?如需,我将更新计划!”
如果用户要求或同意添加聊天界面:
> [!CAUTION]
>
> 添加聊天界面是一项重大变更。绝不能默认用户已同意包含聊天界面的实施计划。
  1. 收集技术细节:必须阅读
    resources/chat_integration.md
    了解技术要求。
  2. 更新实施计划:仅当已有实施计划时,才需更新计划。由于这是重大变更,用户必须明确批准更新后的计划。
  3. 验证前提条件:确保用户已启用Gemini Data Analytics API,且BigQuery中存在数据。
  4. 参考示例:参考
    examples/react_chat_panel.jsx
    以及
    examples/fastapi_chat.py
    examples/express_chat.ts
    中的模式进行适配。

Acceptance Criteria

验收标准

[!CAUTION]
If available, you MUST use browser testing capabilities (such as
browser_subagent
, Puppeteer, Playwright, or an equivalent available tool) to visually verify the frontend application is working correctly before notifying the user that the task is complete.
[!IMPORTANT]
The following checklist represents the strict requirements for this task. You must include these items in whatever format you use to track your work (e.g., your task list, implementation plan, or internal checklist).
  • Are CSS hover transitions smooth?
  • Are date fields formatted readably? (e.g.,
    MMM dd, yyyy
    )
  • Do z-indexes stack correctly so dropdowns appear above table headers? (
    relative z-30
    )
  • Do all interactive form/button inputs handle loading/disabled states?
  • Is the application responsive and does the layout adapt well to different screen sizes?
  • Are API calls for data fetching successful, and is there appropriate error handling?
  • Does the dark mode toggle function correctly and apply styles consistently?
  • Do all visualizations render correctly and are they interactive where expected?
  • Is the dashboard visually appealing?
[!CAUTION]
如果可用,必须使用浏览器测试功能(如
browser_subagent
、Puppeteer、Playwright或其他等效工具),在通知用户任务完成前,可视化验证前端应用运行正常。
[!IMPORTANT]
以下检查清单代表了本任务的严格要求。必须将这些项纳入工作跟踪格式中(例如任务列表、实施计划或内部检查清单)。
  • CSS悬浮过渡是否流畅?
  • 日期字段格式是否易读?(例如
    MMM dd, yyyy
  • z-index堆叠是否正确,确保下拉菜单显示在表格标题上方?(
    relative z-30
  • 所有交互式表单/按钮输入是否处理加载/禁用状态?
  • 应用是否响应式,布局能否良好适配不同屏幕尺寸?
  • 数据获取的API调用是否成功,是否有适当的错误处理?
  • 暗黑模式切换是否功能正常,样式应用是否一致?
  • 所有可视化内容是否渲染正确,且在预期场景下具备交互性?
  • 仪表盘是否视觉美观?