PersonalWeb

我如何构建 PersonalWeb

我同时把 PersonalWeb 当作中英双语作品集和一个持续维护的工程项目。公开页面由 Astro 生成,交互部分使用 React,AI Chat 由 Flask 后端提供,Nginx 让网站与 API 保持同源。仓库还记录了各部分如何测试、部署和维护。

项目由哪些部分组成

静态页面,按需交互

主要页面由 Astro 生成静态 HTML;导航、主题与语言切换、表单、证书信息和 Chat 等交互再由 React 负责,因此公开内容不依赖浏览器完成加载后才能阅读。

边界清楚的 AI Chat

独立 Chat 页面和首页浮动窗口使用同一个站内地址。导览问题只依据网站和公开仓库信息回答,浮动窗口的加载协议与模型请求分别维护。

可以重复执行的测试与交付

Vitest、Playwright 浏览器检查、Astro 构建、GitHub Actions,以及公开记录的 Nginx 与 CSP 约束,让每次变更都能被检查和重复执行。

查看具体实现

PersonalWeb

How I built PersonalWeb

I maintain PersonalWeb as both my bilingual portfolio and a working engineering project. Astro serves the public pages, React handles focused interactions, Flask powers Chat, and Nginx keeps the site and API on one origin. The repository also shows how I test, deploy, and document each part.

Inside the project

Static pages with focused interactivity

Astro renders the main pages as static HTML. React is reserved for navigation, theme and language controls, forms, certification details, and Chat, so public content remains readable before hydration.

Chat with a clear boundary

The direct Chat page and floating widget share the same-origin route. Guided questions use public information from this site and its repositories, while the iframe-ready protocol stays separate from model requests.

Repeatable checks and delivery

Vitest, Playwright browser checks, Astro builds, GitHub Actions, and documented Nginx and CSP constraints make changes inspectable and repeatable.

Inspect the implementation

张人大 · 轻量级网站


简介

Click here to view the English Version in Github

这是我维护的个人网站,也是一个持续演进的公开工程项目。它把中英双语作品集、AI 对话、 技术文档、测试和自动部署放在同一个可审查的代码库中。

网站链接: 🌐 www.rendazhang.com

公开页面也包含 SEO / GEO、结构化数据和 AI 摘要入口,方便搜索与阅读。

PersonalWeb 项目概览

我同时把 PersonalWeb 当作中英双语作品集和一个持续维护的工程项目。主要页面由 Astro 生成静态 HTML,导航、主题、语言、表单、证书信息和 Chat 等交互再由 React 负责。

AI Chat 提供独立页面和首页浮动窗口;两者通过同源地址连接 Flask 后端。导览问题只依据网站和 公开仓库信息回答,普通 Chat 仍保留原有请求方式。

Vitest、Playwright 浏览器检查、Astro 构建和 GitHub Actions 组成可重复执行的验证与发布流程。 仓库还记录了前端、后端、Nginx、CSP、目录所有权和运维命令之间的边界。

可以从以下入口继续了解:

PersonalWeb 是我持续维护的个人项目,不能说明高流量规模、私人客户系统或大型商业 SaaS。 公开仓库不会包含密钥、访客消息、表单内容、私人日志或服务器细节。

另一个公开仓库 📁 Renda Cloud LAB 聚焦云原生服务器架构,可用于查看与 PersonalWeb 不同的设计范围。


技术栈

分类 技术
前端 Astro, React, TypeScript
状态管理 React useStateuseContext(可扩展 Zustand 等)
构建工具 Astro 内置 (基于 Vite)
后端 Flask + OpenAI API
部署 GitHub Actions + Nginx

目录结构

src/
├── assets/
├── constants/           # 站点元信息、资源路径与应用设置
├── features/            # 按业务划分的模块
│   ├── chat/
│   │   ├── components/
│   │   ├── hooks/
│   │   └── services/
│   └── auth/
│       ├── components/
│       ├── hooks/
│       └── services/
├── hooks/               # 业务逻辑自定义 hooks
├── styles/
│   ├── core/               # 核心变量
│   │   ├── tokens.css      # 设计 Token(颜色、间距等)
│   │   └── _gradients.css  # 渐变系统
│   ├── components/         # 组件样式
│   ├── utilities/          # 工具类
│   └── theme.css           # 主入口文件
├── scripts/
├── utils/               # 通用工具函数
├── models/              # 领域模型
├── services/           # API interaction layer
└── components/
    ├── ui/
    ├── layouts/
    ├── forms/
    ├── chat/
    ├── sections/
    └── providers/

参考架构

ASCII 图示:

Web Application Architecture
============================

Frontend (
   Astro + React
   - 负责用户界面和交互
) → CI/CD (
   GitHub Actions 自动构建部署
) → Server (
   Ubuntu (操作系统)
   ↓
   Nginx (静态文件服务)
   ↓
   systemd 服务 (进程管理)
   ↓
   Gunicorn + Gevent (WSGI 服务器)
   ↓
   Backend: Flask App (处理业务逻辑和 API 请求)
)

Mermaid Flow 图示:

flowchart TD
    A[Web] --> B[Frontend: Astro + React]
    A --> C[Server]
    B -->|负责用户界面和交互| C

    subgraph Server
        direction TB
        D[Ubuntu: 操作系统] --> E[Nginx: 静态服务]
        E --> F[systemd 服务: 进程管理]
        F --> G[Gunicorn + Gevent: WSGI 服务器]
        G --> H[Backend: Flask App: 处理业务逻辑和 API 请求]
    end

前端

本仓库就是前端项目:📁 Renda Zhang WEB

架构说明

BaseLayout 组件设计说明

src/layouts/BaseLayout.astro 是站点的全局页面框架,用于设置 <head> 元信息、SEO 标签以及根级插槽。导航栏与汉堡菜单虽然依赖浏览器环境,但现在通过 client:load 先在服务端渲染静态结构,再在客户端水合以避免语言闪烁等问题。保留该文件为 Astro 组件的主要考虑如下:

只有在计划将站点全面迁移到 React,或需要在布局层共享复杂的 React 状态/上下文时,才考虑改写 BaseLayout.astro。在现阶段,维持 Astro 版本更简洁高效。

为满足 Nginx 的 CSP 限制并在 404/500 等纯静态页面中复用主题与语言逻辑,原有的内联初始化脚本已抽离为阻塞式外部脚本 /js/base-layout-init.js。该文件由 src/scripts/base-layout-init.ts 编译生成,并通过 data-theme-keydata-palette-keydata-lang-key 等属性向脚本传递存储键,在渲染前完成主题 mode、调色板和语言初始化。

本地开发和预览

  1. 安装依赖并启用 pre-commit:

    npm install
    pip install pre-commit
    pre-commit install
    
  2. 运行本地开发服务器:

    npm run dev
    
  3. 构建并预览生产版本:

    npm run build
    npm run preview
    
  4. 如需连接自定义后端接口,可在根目录 .env / .env.local 文件设置 PUBLIC_API_BASE_URL

    PUBLIC_API_BASE_URL=https://api.example.com
    
  5. Sentry 集成还需要以下变量:

    SENTRY_DSN=<server dsn>
    PUBLIC_SENTRY_DSN=<browser dsn>
    SENTRY_PROJECT=<your project>
    SENTRY_AUTH_TOKEN=<auth token>
    

    本地检查或提交前如需跳过 Sentry 上报,可临时添加环境变量:

    SKIP_SENTRY=true pre-commit run --all-files
    SKIP_SENTRY=true npm run astro -- check --incremental
    

    如需临时跳过 ESLint 检查以加快提交,可设置:

    SKIP_ESLINT=true pre-commit run --all-files
    
  6. 环境变量说明

    本地可以配置在 .env 或者 .env.local,并通过 src/utils/env.tsgetEnv() 读取:

    # 公开信息
    PUBLIC_SITE_BASE_URL = "https://www.rendazhang.com"
    PUBLIC_CDN_BASE="https://cdn.jsdelivr.net/gh/rendazhang/rendazhang@1.0.1/"
    PUBLIC_API_BASE_URL="/cloudchat"
    PUBLIC_SENTRY_DSN="https://e184a284f1b7342d197ee0a0151f8353@o4509770577543168.ingest.us.sentry.io/4509770780377088"
    PUBLIC_TAG_NAME="v1.0.1"
    NODE_ENV="production"
    PUBLIC_NODE_ENV="development" # 本地调试覆盖为 development
    SKIP_SENTRY="true" # 跳过 Sentry
    SKIP_ESLINT="true" # 跳过 ESLint 检查
    
    # 敏感配置(如下为示例)
    SENTRY_AUTH_TOKEN="sntrys_xxx"
    SENTRY_DSN="https://private-key@xxx.ingest.us.sentry.io/xxx"
    SENTRY_PROJECT="xxx"
    SENTRY_ORG="xxx"
    

执行 npm run build 后,dist/_astro 目录会生成带有哈希后缀的静态文件,方便浏览器长时间缓存。

浏览器访问 http://localhost:4321 查看效果。

构建后的静态文件可使用 npm run preview 验证。

GitHub Actions

Push 到 master 分支会触发 GitHub Actions 自动部署:

  1. 使用 actions/checkout@v5 检出代码。
  2. 使用 actions/setup-node@v6 安装 Node.js 24,并启用 npm 缓存。
  3. 执行 npm ci,以 package-lock.json 为准安装依赖。
  4. 构建前执行 npm run syncnpm run lintnpm run typechecknpm run checknpm run test:coverage
  5. 执行 npm run build 生成 dist/ 静态文件;生产环境会删除 source map。
  6. 通过 appleboy/scp-actiondist/ 内容上传到服务器指定目录(如 /var/www/html)。
  7. 发布 release 分支、重建版本标签、创建 GitHub Release,并尝试清理 jsDelivr 版本缓存。
  8. 部署完成后即可通过 Nginx 提供服务;静态站点不需要重启前端服务。

本地提交不会自动运行完整 Astro 检查,如需校验请手动执行:npm run check

需要在仓库 Secrets 中配置服务器 IP、SSH 用户和私钥等信息。详情见 📄 配置 GitHub Actions

使用说明

部署完成后可直接访问各模块页面。

如下是我的网站的每个页面的链接:

网站功能

关于网站的核心功能体系,请参考以下文档链接:📄 核心功能体系。该文档详细描述了网站的核心功能模块,包括功能设计和技术实现,是开发与维护的重要参考。

页面功能

各页面核心职责如下(均由 .astro 文件生成):

页面跳转

  1. 返回主页

    • 所有页面均包含导航栏中的“主页”按钮,点击后可返回主页。
  2. 导航栏菜单跳转

    • 导航栏与汉堡菜单在服务端输出静态标记,并通过 client:load 在客户端水合,既保留交互又避免 Hydration 报错。
    • 通过点击导航栏的“汉堡菜单”按钮,用户可选择跳转到以下页面:
      • 首页
      • AI 聊天页
      • 证书页
      • 技术文档页
      • 用户账号信息页(登录后可见)
  3. 登录页面跳转

    • 通过点击导航栏的“人像图标”按钮,用户可跳转到登录页面。

Mermaid Flow 图示:

flowchart TD
    A[主页] -->|汉堡菜单| B[AI 聊天页]
    A -->|汉堡菜单| C[证书页]
    A -->|汉堡菜单| D[技术文档页]
    A -->|汉堡菜单| F[账号信息页]
    A -->|人像图标| E[登录页面]
    B -->|主页按钮| A
    C -->|主页按钮| A
    D -->|主页按钮| A
    E -->|主页按钮| A
    F -->|主页按钮| A

    style A fill:#9f9,stroke:#333
    style B fill:#f9f,stroke:#333
    style C fill:#ff9,stroke:#333
    style D fill:#99f,stroke:#333
    style E fill:#f99,stroke:#333
    style F fill:#9ff,stroke:#333

页面内容

页面优化

自适应布局:优化页面在不同设备上的显示效果,减少不必要的资源加载和布局计算,从而提高性能。确保页面在不同屏幕尺寸(如桌面、平板、手机)上都能良好显示,提升用户体验。

懒加载:所有图片开启了懒加载 + Loading 动画,其中,针对高清图片采用 LQIP 懒加载优化(比如主页的 Hero 区域)

配色方案

项目的核心色彩使用 OKLCH 设计令牌并通过 color-mix 提供 sRGB 回退,以保证明暗模式下的感知一致性。

详情参考文档内容:📄 配色方案


后端

后端部署的具体步骤和配置,请参考以下项目:📁 Python Cloud Chat。该项目提供了完整的后端实现和部署指南,帮助您快速搭建和运行后端服务。


Nginx 服务器

前端项目通过 GitHub Actions 自动化构建后,会直接推送到服务器的 /var/www/html 目录,并由 Nginx 提供静态资源服务。

关于 Nginx 的详细配置和操作说明,请查看以下仓库:📁 Nginx Conf。该仓库包含了常用的 Nginx 配置文件和使用示例,方便您快速上手。

为充分利用构建生成的指纹文件,可在 Nginx 中为 /_astro/ 路径添加长效缓存配置:

location /_astro/ {
    access_log off;
    add_header Cache-Control "public, max-age=31536000, immutable";
}

如果您需要更重量级的服务器解决方案,可以参考我的云原生项目:📁 Renda Cloud LAB。该项目提供了基于云原生的完整架构设计,适用于大规模和高可用性场景。


文档说明

Git 分支与发布流程

项目采用 master/develop 双主线,并约定 featurehotfixexperiment 等分支的命名规范与合并策略,详见:📄 Git Workflow

CI/CD 工作流

deploy.yml 定义了推送到 master 时触发的自动部署流程,包括标签管理、发布分支与环境变量映射等,可参考:📄 CI / CD Pipeline

运维维护命令索引

前端验证、deploy run 检查、deploy log 噪声分类、依赖审计、后端/Nginx docs-only 同步规则、生产只读检查和本地 roadmap 维护命令见:📄 Operations Maintenance Guide

依赖与安全风险登记

当前 dependency audit / Dependabot 状态、npm audit fix --force 禁止原因、Astro 7 实施结果和安全补丁升级阈值见:📄 Dependency Security Risk Register

Astro 7 升级预检

Astro 7 的 Go/No-Go 结论、实施结果、目标包集合、Vite 8/Rolldown 风险、Sentry source-map、CSP、Chat Widget smoke 和回滚计划见:📄 Astro 7 Upgrade Precheck

Astro 6 迁移预检

Astro 6 升级前的当前基线、目标包集合、Node/Vite/Sentry 兼容性风险、验证清单和回滚策略见:📄 Astro 6 迁移预检

前端架构约定

Astro 页面、BaseLayout、React Islands、Hydration、服务层、工具函数、样式 Token、CSP 与 iframe 约束的当前约定见:📄 前端架构约定

前端目录所有权地图

src/componentssrc/servicessrc/utilssrc/stylessrc/contentsrc/storessrc/controllers 的目录职责边界见:📄 前端目录所有权地图

Chat Widget 协议说明

浮动 Chat Widget 与 /deepseek_chat/ 同源 iframe 的 postMessage ready 协议、origin/source 校验、加载生命周期和后续重构约束见:📄 Chat Widget 协议说明

前端体验平台 RFC

Phase 8 的浏览器 smoke、hydration 安全、主题 mode 与 palette/accent 分离、调色板切片顺序和交互标准规划见:📄 前端体验平台 RFC

交互组件标准

modal、popover/menu、toast/status、loading、disabled/empty/error state、键盘行为、focus 管理和 browser smoke 门禁见:📄 交互组件标准

人性化表达与个人风格

Phase 15 的中英文写作语气、第一人称表达、技术术语、CTA、证据边界、视觉个性和 owner 输入规则见:📄 Human Voice And Personal Expression

内容可信度与个人定位

Phase 10 的个人品牌内容、可信证明、PersonalWeb 项目证明、证书、工作/学习经历与 SEO/GEO 一致性规划见:📄 内容可信度与个人定位

Site Intelligence 与访客路径

Phase 11 的访客路径、隐私安全匿名事件、first-party telemetry 边界和 Chat Guide 公开内容范围见:📄 Site Intelligence And Visitor Journey

作品证明与访问转化

Phase 14 的作品证明、访问路径、PersonalWeb case-study surface、首页 proof path、Chat Guide 入口和浏览器/移动端转化 QA 规划见:📄 Portfolio Proof And Visitor Conversion

Chat Guide 质量架构

Phase 12 的 Chat Guide 公开知识边界、答案质量问题、后端公共知识包方案和后续切片顺序见:📄 Chat Guide Quality Architecture

SEO / GEO 维护说明

canonical host、sitemap、llms.txt/docs/ SSR 正文和 soft-404 验证规则见:📄 SEO / GEO 维护说明

BUG 记录

前端开发过程中遇到的 BUG 及其解决方案,请参考以下文档:📄 前端 BUG 跟踪数据库。该文档详细记录了 BUG 的描述、复现步骤、解决方案以及相关开发者的处理记录,帮助您快速定位和解决问题。

开发需求

项目的功能需求、优先级以及开发计划,请参考以下文档:📄 项目需求清单。该文档列出了当前版本的所有需求,并提供了需求的详细描述和开发状态,方便您了解项目进展和规划开发任务。

用户认证与密码重置规范

用户认证与密码重置的页面路由、API 契约、密码策略和安全注意事项等内容,请参考:📄 用户鉴权规范

原生到 Astro + React 升级

前端目前采用 Astro + React 的架构,基于分层设计理念,通过 GitHub Actions 实现自动化构建,并将构建产物部署到服务器 Nginx 的指定目录下。

具体的从原生前端升级的操作步骤,请参考以下文档内容:📄 升级计划。该文档详细描述了从旧版原生前端逐步迁移到基于 Astro 和 React 的新前端架构的完整计划与实施步骤。

开发环境准备的具体步骤,请参考以下文档内容:📄 环境准备。该文档详细说明了如何完成开发环境的配置以及 Astro 项目的初始化工作,确保您能够顺利开始后续的开发任务。

响应式图片系统维护

网站图片通过自动化脚本生成响应式版本并内置 LQIP 占位效果,方便在不同设备上快速加载。

详细操作流程与扩展指南请参阅:📄 通用响应式图片处理系统维护文档

错误跟踪

Sentry 用于收集运行时异常与网络错误。配置步骤请见 📄 错误跟踪集成.

工具函数参考文档

src/utils/env.tssrc/utils/langUtils.tssrc/utils/storage.tssrc/utils/logger.ts 提供统一的环境变量访问、语言解析、多后端存储方案与可扩展的日志接口。

文档详见:📄 工具函数参考文档.

预提交钩子综合指南

详细预提交钩子说明请参阅:预提交钩子综合指南

测试指南

项目使用 Vitest 进行单元测试。运行 npm test 即可执行所有测试;npm run test:watch 可在开发过程中持续监听;如需覆盖率报告,可使用 npm run test:coverage。测试文件需以 .test.ts.spec.ts 命名,通常与源码放在同一目录或 __tests__ 子目录下。更多示例与编写说明参见:测试指南

JS ➜ TS 迁移指南

汇总从 JavaScript 到 TypeScript 的完整迁移过程与经验,包括配置、分步策略和常见报错排查。详见:📄 JS ➜ TS 全量迁移实战指南

样式体系说明

介绍项目的 CSS 架构、基于 OKLCH 的设计 Token 体系与构建流程,展示 postcss-import 如何在编译阶段内联 theme.css 引用的核心与工具样式以减少运行时请求,详见:📄 样式说明


🤝 贡献指南

✅ 所有提交必须通过 pre-commit 检查;CI 会阻止不符合规范的 PR


🔒 开源许可证

本项目以 MIT 许可证 发布,你可以自由使用与修改。请在分发时保留原始许可证声明。


📬 联系方式

维护者:@张人大 — 如果本项目对你有帮助,请不要忘了点亮 ⭐️ Star 支持我们!

Renda Zhang · Lightweight Website


Introduction

点击这里查看 Github 上的中文版

This is my personal website and an evolving public engineering project. It brings a bilingual portfolio, AI Chat, technical documentation, tests, and automated delivery into one inspectable repository.

Live Site: 🌐 www.rendazhang.com

The public pages also include SEO/GEO, structured data, and an AI-summary entry point.

PersonalWeb Project Overview

I maintain PersonalWeb as both a bilingual portfolio and a working engineering project. Astro generates the main pages as static HTML, while React handles navigation, theme and language controls, forms, certification details, and Chat.

AI Chat is available as a direct page and as a floating homepage window. Both use a same-origin route to the Flask backend. Guided questions use public site and repository information, while ordinary Chat keeps its existing request path.

Vitest, Playwright browser checks, Astro builds, and GitHub Actions provide a repeatable validation and delivery path. The repository also documents the boundaries between the frontend, backend, Nginx, CSP, directory ownership, and routine operations.

Continue with:

PersonalWeb is a maintained personal project. It does not demonstrate high-traffic scale, private customer systems, or a large commercial SaaS. The public repository leaves out secrets, visitor messages, form contents, private logs, and server details.

Another public repository, 📁 Renda Cloud LAB, focuses on cloud-native server architecture and shows a different project scope from PersonalWeb.


Tech Stack

Category Technologies
Frontend Astro, React, TypeScript
State Management React useState, useContext (Zustand compatible)
Build Tools Astro built-in (Vite-based)
Backend Flask + OpenAI API
Deployment GitHub Actions + Nginx

Directory Structure

src/
├── assets/
├── constants/           # Site metadata, asset paths, and app settings
├── features/            # Feature-based modules
│   ├── chat/
│   │   ├── components/
│   │   ├── hooks/
│   │   └── services/
│   └── auth/
│       ├── components/
│       ├── hooks/
│       └── services/
├── hooks/               # Custom hooks for business logic
├── styles/
│   ├── core/               # Core variables
│   │   ├── tokens.css      # Design tokens (colors, spacing, etc.)
│   │   └── _gradients.css  # Gradient system
│   ├── components/         # Component styles
│   ├── utilities/          # Utility classes
│   └── theme.css           # Main entry file
├── scripts/
├── utils/               # Utility helpers
├── models/              # Domain models
├── services/           # API interaction layer
└── components/
    ├── ui/
    ├── layouts/
    ├── forms/
    ├── chat/
    ├── sections/
    └── providers/

Reference Architecture

ASCII Diagram:

Web Application Architecture
============================

Frontend (
   Astro + React
   - Handles UI and interactions
) → CI/CD (
   GitHub Actions auto-build & deploy
) → Server (
   Ubuntu (OS)
   ↓
   Nginx (static file serving)
   ↓
   systemd service (process management)
   ↓
   Gunicorn + Gevent (WSGI server)
   ↓
   Backend: Flask App (business logic & API handling)
)

Mermaid Flow Diagram:

flowchart TD
    A[Web] --> B[Frontend: Astro + React]
    A --> C[Server]
    B -->|Handles UI and interactions| C

    subgraph Server
        direction TB
        D[Ubuntu: OS] --> E[Nginx: Static serving]
        E --> F[systemd: Process management]
        F --> G[Gunicorn + Gevent: WSGI server]
        G --> H[Backend: Flask App: Business logic & APIs]
    end

Frontend

This repository contains the frontend project: 📁 Renda Zhang WEB

Architecture Overview

BaseLayout Component Design Notes

src/layouts/BaseLayout.astro serves as the global page framework for the site, responsible for setting <head> metadata, SEO tags, and root-level slots. The navigation bar and hamburger menu now render on the server and hydrate with client:load, avoiding language flicker while preserving interactivity. The primary reasons for keeping this file as an Astro component are as follows:

Consider rewriting BaseLayout.astro only if there are plans to fully migrate the site to React or if there is a need to share complex React state/context at the layout level. For now, maintaining the Astro version is more concise and efficient.

To satisfy Nginx CSP restrictions and allow static pages like 404/500 to reuse theme and language logic, the former inline initialization script has been moved to a blocking external script /js/base-layout-init.js. The file is generated from src/scripts/base-layout-init.ts and passes storage keys via data-theme-key, data-palette-key, and data-lang-key attributes so that theme mode, palette, and language are applied before the page renders.

Local Development & Preview

  1. Install dependencies and enable pre-commit:

    npm install
    pip install pre-commit
    pre-commit install
    
  2. Start local dev server:

    npm run dev
    
  3. Build and preview production version:

    npm run build
    npm run preview
    
  4. To connect to a custom backend API, set the PUBLIC_API_BASE_URL in the root directory's .env / .env.local file:

    PUBLIC_API_BASE_URL=https://api.example.com
    
  5. Sentry integration also requires:

    SENTRY_DSN=<server dsn>
    PUBLIC_SENTRY_DSN=<browser dsn>
    SENTRY_PROJECT=<your project>
    SENTRY_AUTH_TOKEN=<auth token>
    

    When running local checks or pre-commit without Sentry, prepend:

    SKIP_SENTRY=true pre-commit run --all-files
    SKIP_SENTRY=true npm run astro -- check --incremental
    

    To temporarily skip ESLint checks and speed up commits, use:

    SKIP_ESLINT=true pre-commit run --all-files
    
  6. Environment Variables Explanation

    Local configurations can be set in .env or .env.local, and read via the getEnv() function in src/utils/env.ts:

    # Public Information
    PUBLIC_SITE_BASE_URL = "https://www.rendazhang.com"
    PUBLIC_CDN_BASE="https://cdn.jsdelivr.net/gh/rendazhang/rendazhang@1.0.1/"
    PUBLIC_API_BASE_URL="/cloudchat"
    PUBLIC_SENTRY_DSN="https://e184a284f1b7342d197ee0a0151f8353@o4509770577543168.ingest.us.sentry.io/4509770780377088"
    PUBLIC_TAG_NAME="v1.0.1"
    NODE_ENV="production"
    PUBLIC_NODE_ENV="development" # Override to "development" for local debugging
    SKIP_SENTRY="true" # Skip Sentry
    SKIP_ESLINT="true" # Skip ESLint checks
    
    # Sensitive configurations (example values below)
    SENTRY_AUTH_TOKEN="sntrys_xxx"
    SENTRY_DSN="https://private-key@xxx.ingest.us.sentry.io/xxx"
    SENTRY_PROJECT="xxx"
    SENTRY_ORG="xxx"
    

After running npm run build, the dist/_astro directory will contain fingerprinted files with hash suffixes, allowing browsers to cache them long-term.

Access via http://localhost:4321.

Verify builds using npm run preview.

GitHub Actions

Pushing to master triggers GitHub Actions Auto-Deployment:

  1. Check out the code with actions/checkout@v5.
  2. Set up Node.js 24 with actions/setup-node@v6 and enable npm caching.
  3. Run npm ci so dependency installation is based on package-lock.json.
  4. Before building, run npm run sync, npm run lint, npm run typecheck, npm run check, and npm run test:coverage.
  5. Run npm run build to generate the dist/ static files; production builds remove source maps.
  6. Use appleboy/scp-action to upload the contents of dist/ to the server directory, such as /var/www/html.
  7. Publish the release branch, recreate the version tag, create the GitHub Release, and try to purge the jsDelivr version cache.
  8. After deployment, Nginx serves the static site; no frontend service restart is required.

Local commits do not automatically run the full Astro check. To validate manually, run: npm run check

Configure server IP, SSH user, and private key in Repository Secrets. Details: 📄 GitHub Actions Setup

Usage Guide

Access all modules post-deployment:

Website Features

For details on the core functionality system of the website, please refer to the following documentation link: 📄 Core Functionality System. This document provides a detailed description of the website's core functional modules, including feature design and technical implementation. It serves as an essential reference for development and maintenance.

Page Functionality

The core responsibilities of each page are as follows (all generated by .astro files):

Page Navigation

  1. Return to Homepage All pages have "Home" button in navigation

  2. Navigation Menu Redirection

    • The navigation bar and hamburger menu output static markup on the server side and are hydrated on the client side using client:load, ensuring interactivity while avoiding hydration errors.
    • By clicking the "Hamburger Menu" button in the navigation bar, users can choose to navigate to the following pages:
      • Homepage
      • AI Chat Page
      • Certifications Page
      • Technical Documentation Page
      • User Account Information Page (visible after login)
  3. Login Page Access Profile icon in nav redirects to login

flowchart TD
    A[Home] -->|Hamburger| B[AI Chat]
    A -->|Hamburger| C[Certifications]
    A -->|Hamburger| D[Tech Docs]
    A -->|Hamburger| F[Account Profile]
    A -->|Profile Icon| E[Login]
    B -->|Home Button| A
    C -->|Home Button| A
    D -->|Home Button| A
    E -->|Home Button| A
    F -->|Home Button| A

    style A fill:#9f9,stroke:#333
    style B fill:#f9f,stroke:#333
    style C fill:#ff9,stroke:#333
    style D fill:#99f,stroke:#333
    style E fill:#f99,stroke:#333
    style F fill:#9ff,stroke:#333

Page Content

Page Optimization

Adaptive Layout: Optimizes the display effect of the page on different devices, reduces unnecessary resource loading and layout calculations, and thereby improves performance. Ensures that the page displays well on various screen sizes (e.g., desktop, tablet, mobile), enhancing user experience.

Lazy Loading: All images have lazy loading enabled with a loading animation. For high-definition images, LQIP (Low-Quality Image Placeholder) lazy loading optimization is applied (e.g., the Hero section on the homepage).

Color Scheme

The core colors of the project are designed using OKLCH design tokens and provide sRGB fallback through color-mix to ensure perceptual consistency across light and dark modes.

For detailed information, refer to the documentation: 📄 Color Scheme.


Backend

For detailed steps and configurations on backend deployment, please refer to the following project: 📁 Python Cloud Chat. This project provides a complete backend implementation and deployment guide, helping you quickly set up and run backend services.


Nginx Server

The frontend project is automatically built via GitHub Actions and pushed to the /var/www/html directory on the server, where Nginx serves the static resources.

For detailed Nginx configurations and operational instructions, please check the following repository: 📁 Nginx Conf. This repository includes commonly used Nginx configuration files and examples, making it easy for you to get started.

To fully leverage the hashed assets under /_astro, add a long-term cache rule in Nginx:

location /_astro/ {
    access_log off;
    add_header Cache-Control "public, max-age=31536000, immutable";
}

If you need a more robust server solution, you can refer to my cloud-native project: 📁 Renda Cloud LAB. This project provides a complete cloud-native architecture design, suitable for large-scale and high-availability scenarios.


Documentation

Git Branching & Release Workflow

The project follows a master/develop dual-branch model with conventions for feature, hotfix, and experiment branches. Details: 📄 Git Workflow.

CI/CD Workflow

deploy.yml defines the deployment process triggered when code is pushed or merged into master, including tag management and environment variable mappings. See: 📄 CI / CD Pipeline.

Operations Maintenance Guide

Frontend validation, deploy-run inspection, deploy-log noise classification, dependency audits, backend/Nginx docs-only sync rules, production read-only checks, and local roadmap maintenance commands are documented in: 📄 Operations Maintenance Guide.

Dependency Security Risk Register

Current dependency audit / Dependabot residual risk, the reason npm audit fix --force is disallowed, Astro 7 upgrade boundaries, and security patch escalation thresholds are documented in: 📄 Dependency Security Risk Register.

Astro 7 Upgrade Precheck

The Astro 7 Go/No-Go decision, target package set, Vite 8/Rolldown risks, Sentry source-map checks, CSP gate, Chat Widget smoke scope, and rollback plan are documented in: 📄 Astro 7 Upgrade Precheck.

Astro 6 Migration Precheck

The current baseline, target package set, Node/Vite/Sentry compatibility risks, validation checklist, and rollback plan for the Astro 6 upgrade are documented in: 📄 Astro 6 Migration Precheck.

Frontend Architecture Conventions

Current conventions for Astro pages, BaseLayout, React Islands, hydration, service boundaries, utilities, style tokens, CSP, and iframe constraints are documented in: 📄 Frontend Architecture Conventions.

Frontend Directory Ownership Map

Directory ownership for src/components, src/services, src/utils, src/styles, src/content, src/stores, and src/controllers is documented in: 📄 Frontend Directory Ownership Map.

Chat Widget Protocol

The same-origin iframe postMessage ready protocol between the floating Chat Widget and /deepseek_chat/, including origin/source checks, loading lifecycle, and refactor constraints, is documented in: 📄 Chat Widget Protocol.

Frontend Experience Platform RFC

Phase 8 planning for browser smoke coverage, hydration safety, theme mode vs palette/accent separation, palette slice order, and interaction standards is documented in: 📄 Frontend Experience Platform RFC.

Interaction Component Standards

Modal, popover/menu, toast/status, loading, disabled/empty/error state, keyboard behavior, focus management, and browser smoke gates are documented in: 📄 Interaction Component Standards.

Human Voice And Personal Expression

Phase 15 rules for bilingual voice, first-person writing, technical terminology, CTAs, evidence boundaries, visual expression, and owner input are documented in: 📄 Human Voice And Personal Expression.

Content And Credibility Positioning

Phase 10 planning for personal-brand content, credibility proof, PersonalWeb project evidence, certifications, work/education narrative, and SEO/GEO alignment is documented in: 📄 Content And Credibility Positioning.

Site Intelligence And Visitor Journey

Phase 11 visitor journey, privacy-safe anonymous events, first-party telemetry boundaries, and Chat Guide public-content scope are documented in: 📄 Site Intelligence And Visitor Journey.

Portfolio Proof And Visitor Conversion

Phase 14 planning for portfolio proof, visitor proof paths, the PersonalWeb case-study surface, homepage proof flow, Chat Guide entry points, and browser/mobile conversion QA is documented in: 📄 Portfolio Proof And Visitor Conversion.

Chat Guide Quality Architecture

Phase 12 documents the Chat Guide public knowledge boundary, answer-quality architecture, backend-owned public knowledge package, and delivery sequence: 📄 Chat Guide Quality Architecture.

SEO / GEO Maintenance

Canonical host, sitemap, llms.txt, /docs/ SSR content, and soft-404 validation rules are documented in: 📄 SEO / GEO Maintenance.

BUG Tracking

For BUGs encountered during frontend development and their solutions, please refer to the following document: 📄 Frontend BUG Tracking Database. This document provides detailed records of BUG descriptions, reproduction steps, solutions, and developer notes, helping you quickly identify and resolve issues.

Development Requirements

For project feature requirements, priorities, and development plans, please refer to the following document: 📄 Project Requirements List. This document lists all requirements for the current version, along with detailed descriptions and development statuses, making it easy for you to track project progress and plan development tasks.

User Authentication and Password Reset Specification

For details on page routing, API contracts, password policies, and security considerations related to user authentication and password reset, please refer to: 📄 Authentication Specification.

Native to Astro + React Migration

The front-end currently adopts an architecture based on Astro + React, following a layered design philosophy. It utilizes GitHub Actions for automated builds and deploys the build artifacts to a specified directory on the server's Nginx.

For detailed steps on upgrading from native frontend, please refer to the following documentation: 📄 Upgrade Plan. This document provides a comprehensive plan and implementation steps for gradually migrating from the old native frontend to a new frontend architecture based on Astro and React.

For detailed steps on setting up the development environment, please refer to the following documentation: 📄 Environment Preparation. This document provides a comprehensive guide on configuring the development environment and initializing an Astro project, ensuring you can smoothly proceed with subsequent development tasks.

Responsive Image System Maintenance

The website uses an automated pipeline to generate responsive images with built-in LQIP placeholders. For maintenance and extension instructions, see 📄 Responsive Image System Maintenance

Error Tracking

Sentry collects runtime and network errors. See 📄 Error Tracking Integration for configuration.

Utilities Reference

src/utils/env.ts, src/utils/langUtils.ts, src/utils/storage.ts, and src/utils/logger.ts provide unified access to environment variables, language parsing, multi-backend storage solutions, and an extensible logging interface.

Docs: 📄 Utilities Reference.

Comprehensive Pre-Commit Guide

For a detailed explanation of the pre-commit hooks, refer to the Comprehensive Pre-Commit Guide.

Style System Description

Introduce the project's CSS architecture, the OKLCH-based design token system, and the build process. Demonstrate how postcss-import inlines the core and utility styles referenced by theme.css during the compilation phase to reduce runtime requests. For details, see: 📄 Style Guide.


🤝 Contribution Guide

✅ All commits must pass the pre-commit checks; CI will block PRs that do not meet the standards.


🔒 Open Source License

Released under MIT License - free for use and modification. Retain original license notices when redistributing.


📬 Contact

Maintainer: @RendaZhang — If this project helps you, please give it a ⭐️!