⚡ AI-built · end-to-end case study⚡ AI 协作开发 · 端到端案例

Policy Intel

能见 — China Energy Policy Intelligence

A platform that automatically scrapes energy-storage & power-market policy from official Chinese government sources, runs every item through an LLM quality gate for relevance and classification, and turns it into a searchable, visual dashboard — refreshed daily. 一个自动从官方政府源抓取储能与电力市场政策、用 LLM 质量闸做相关性判定与分类、 再呈现为可搜索可视化看板的平台 —— 每日自动更新。

FastAPI · Python Claude (LLM gate)Claude(LLM 闸) React · esbuild SQLite Brave Search API Docker · Railway
Designed & built by Kejing Yan 闫可菁 & Weijie Cao 曹炜杰 — a two-person, AI-assisted (agentic) project.由 闫可菁 Kejing Yan 与 曹炜杰 Weijie Cao 共同打造 —— 二人协作、以 AI(agentic)方式构建。
530+
policies indexed收录政策
150+
from official gov.cn URLs官方 gov.cn 真实链接
30+
provinces covered覆盖省份
Daily每日
auto-scrape + LLM gate自动抓取 + LLM 闸
The Idea思路
Policy is the product's weather — and it was scattered everywhere政策就是产品的"天气",却散落在各处

China's new-energy-storage and power-market policy moves fast and lives scattered across 30+ provincial government sites, several ministries, and a fog of industry media. For anyone in the energy-storage business — station developers, system integrators, investors — a missed subsidy window, capacity-pricing rule, or provincial project list is a real cost. Yet there was no single, reliable, structured feed of it. 中国新型储能与电力市场政策更新极快,且散落在 30+ 个省级政府网站、多个部委、以及一团行业媒体里。 对储能行业的人 —— 电站开发商、系统集成商、投资方 —— 错过一个补贴窗口、容量电价规则或省级项目清单,都是真金白银的成本。 但此前没有一个统一、可靠、结构化的信息源。

“During my internship at LG Energy Solution Vertech — LGES's energy-storage system-integration arm — I saw first-hand how much the business depends on staying ahead of policy. The intelligence existed, but gathering it was manual and unreliable. I wanted to make it automatic, trustworthy, and visual.” "在 LG Energy Solution Vertech(LGES 的储能系统集成业务)实习时,我亲眼看到业务有多依赖 '走在政策前面'。情报是存在的,但收集它全靠人工、且不可靠。我想把它做成自动、可信、可视化的。"

So I made a bet: pair reliable official-source scraping with an LLM quality gate — a strict filter that decides whether each candidate is genuinely relevant, a real policy document (not news or commentary), and tags it accurately. Reliability comes from the source; signal comes from the gate. 于是我下了个判断:把可靠的官方源抓取和一个 LLM 质量闸结合 —— 由它严格判定每条候选是否真正相关、是否是真实政策原文(而非新闻或评论),并精准打标。可靠性来自来源,信号来自质量闸。

What it does内容与用法
From raw government pages to decision-ready intelligence从原始政府网页,到可决策的情报
🗺️

Province heat map省份热力地图

A real choropleth of China colored by per-province policy density — see where the action is at a glance.真实的中国省界填色地图,按各省政策密度着色 —— 一眼看清热点在哪。

🤖

LLM quality gateLLM 质量闸

Every policy is auto-judged for relevance & authenticity and tagged into a consistent taxonomy by a cheap, fast LLM.每条政策由便宜快速的 LLM 自动判定相关性与真实性,并打上统一分类标签。

🔍

Search & multi-filter搜索与多维筛选

Filter by province, document type, topic tag, time range, status — or full-text (fuzzy) search title, summary & doc number.按省份、文件类型、主题标签、时间范围、状态筛选,或对标题/摘要/文号做全文(模糊)搜索。

📊

Live dashboard实时看板

Monthly trend, category mix, source coverage and document-status breakdowns, updated as new policy lands.月度趋势、分类占比、来源覆盖、文件状态分布,随新政策入库实时更新。

🔔

Watch & subscribe关注与订阅

Set watch-keywords and subscriptions; get in-app (and email) alerts when a new policy matches your interests.设置关注词与订阅;新政策命中时通过站内(及邮件)提醒你。

⚖️

Province comparison省份对比

Compare policy activity and mechanisms side-by-side across provinces.把多个省份的政策数量、分类与机制并排对比。

🕐

Version & diff tracking版本与 Diff 追踪

When a policy is revised, the change is captured — with a line diff of what moved.政策被修订时自动记录版本,并给出条款级 diff。

📰

Digests & reports速报与周报

Auto-generated weekly summaries and exportable reports of what changed.自动生成每周汇总与可导出的报告。

🔗

Always source-linked始终链接原文

Official entries link straight to the primary gov.cn document — flagged so you know what's first-hand.官方条目直接链接到 gov.cn 原文,并标注哪些是一手来源。

See it在线体验
The live dashboard实时看板

Running in production on Railway. Open it directly, or interact with the public view below.已部署在 Railway 生产环境。可直接打开,或在下方与公开视图交互。

policy-intel-production.up.railway.app
Open full app in a new tab ↗在新标签打开完整应用 ↗
How it's built技术架构
A small, sharp pipeline — source → gate → store → serve一条精炼的流水线:源 → 闸 → 存 → 服务
🏛️
Official sources官方源
gov.cn ministries & provincial bureaus, found via Brave site:gov.cn search部委与省级单位,经 Brave site:gov.cn 搜索定位
→
🕸️
Scraper爬虫
requests + BeautifulSoup, generic content extraction, deduprequests + BeautifulSoup,通用正文抽取、去重
→
🧠
LLM quality gateLLM 质量闸
Claude Haiku via tool-use: relevant? real policy? category & tagsClaude Haiku(tool-use):相关?真政策?分类与标签
→
🗄️
SQLite
versioned items on a Railway volume; daily refresh带版本的条目,存于 Railway 持久卷;每日刷新
→
⚡
FastAPI + SPAFastAPI + SPA
JSON API → precompiled React dashboardJSON API → 预编译 React 看板

🐍 Backend🐍 后端

FastAPI + SQLite, deployed as a single Docker service on Railway. Fail-closed config guards, a background scheduler thread, and a /healthz check.FastAPI + SQLite,以单个 Docker 服务部署在 Railway。含 fail-closed 配置守卫、后台定时线程、/healthz 健康检查。

🛰️ Data pipeline🛰️ 数据管道

Search-driven discovery of primary gov.cn documents, generic article extraction, then the LLM gate — only relevant, real policy enters the DB.搜索驱动定位一手 gov.cn 文档,通用正文抽取,再过 LLM 闸 —— 只有相关、真实的政策才入库。

🎨 Frontend🎨 前端

React 18 SPA precompiled with esbuild and self-hosted (no in-browser Babel, no CDN). SVG charts + a self-hosted GeoJSON choropleth.React 18 SPA 用 esbuild 预编译并自托管(无浏览器内 Babel、无 CDN)。SVG 图表 + 自托管 GeoJSON 填色地图。

Engineering highlights工程亮点
The hard parts I'm proud of我引以为傲的几个难点
01
SIGNAL FROM NOISE从噪音里提信号

An LLM “quality gate” instead of brittle keyword rules用 LLM"质量闸"取代脆弱的关键词规则

Official sites publish everything — licences, coal, statistics — and the original keyword filter let it all in. I replaced it with a Claude-Haiku gate that uses tool-use / structured output (guaranteed-valid JSON, enum-constrained categories) to decide relevant?, real policy? and assign tags. A diagnostic pass showed the legacy dataset was largely off-topic or unreliable; the gate turned 552 mixed entries into a clean, accurately-tagged corpus — for a few cents. 官方网站什么都发 —— 许可证、煤电、统计 —— 原来的关键词过滤全放了进来。我换成一个 Claude-Haiku 质量闸,用 tool-use / 结构化输出(保证合法 JSON、enum 约束分类)来判定是否相关、是否真政策并打标。一次诊断显示旧库大半是跑题或不可靠的;质量闸把 552 条混杂数据变成干净、精准打标的语料 —— 只花了几分钱。

02
RELIABILITY可靠性

Search-driven scraping when per-site scrapers were a dead end逐站爬虫走不通时,改用搜索驱动

Provincial government sites are JS-rendered, inconsistent, and often block direct scraping — writing a parser per province was a losing game. I pivoted to search-driven discovery: Brave site:gov.cn queries across the full energy/power scope (storage, new-energy, power market, pricing, virtual power plants), ~24 provinces plus the National Energy Administration, all feeding the same LLM gate — with PDF-attachment text extraction so policies published only as PDFs aren't silently lost. When coverage looked thin I audited the gate adversarially — re-running already-accepted policies and live candidates through it — and it correctly passed real policies while rejecting only Q&A / explainer pieces. That proved the gap was in discovery, not the gate, so I widened the net to match the gate's scope. 省级政府站多为 JS 渲染、结构各异、常拒绝直接抓取 —— 逐省写解析是个输的游戏。我转向搜索驱动:用 Brave site:gov.cn 覆盖整个能源/电力域(储能、新能源、电力市场、电价、虚拟电厂)、约 24 个省 + 国家能源局,统一喂给同一个 LLM 闸 —— 并做 PDF 附件正文抽取,让只发 PDF 的政策不再被悄悄漏掉。当覆盖看起来偏少时,我对质量闸做了对抗性审计 —— 把已入库政策和实时候选重新过闸 —— 它正确放行真政策、只挡掉答记者问/解读类,证明缺口在发现环节而非闸本身,于是我把搜索范围拓宽到与闸一致。

03
PERFORMANCE性能

Killing a multi-second blank screen by precompiling the SPA预编译 SPA,消灭数秒白屏

The first version compiled 3,300 lines of JSX in the browser with Babel-standalone and loaded React from a CDN — which meant slow first paint and a fully blank page on slow or blocked networks (a real failure in-region). I extracted the source, precompiled it with esbuild, self-hosted React, and shipped a static bundle. Instant render, no external dependency. 第一版在浏览器里用 Babel-standalone 实时编译 3300 行 JSX、并从 CDN 加载 React —— 导致首屏慢、在慢网或被墙网络下整页白屏(在国内是真实的失败)。我抽出源码,用 esbuild 预编译、自托管 React、发布静态 bundle。瞬间渲染,无外部依赖。

04
DATA VIZ数据可视化

A real choropleth map, not a cloud of bubbles真·省界填色地图,而非一堆气泡

The map silently fell back to fixed-position bubbles whenever its CDN GeoJSON failed. I self-hosted China's province boundaries and rendered a true SVG choropleth with a cold→warm heat scale (blue → teal → green → amber → red), normalized so the province scale isn't flattened by the national bucket. 原地图一旦 CDN 的 GeoJSON 加载失败,就静默退回固定位置的气泡。我自托管了中国省界,渲染真正的 SVG 填色地图,配冷→暖色阶(蓝→青→绿→橙→红),并做归一化,避免省级色阶被"全国"桶压平。

05
PRODUCTION-GRADE产品级

Hardening it from “runs” to “runs reliably”从"能跑"到"可靠地跑"

Fail-closed secret & DB-persistence guards (refuse to boot misconfigured rather than lose data silently), blocking LLM calls moved off the event loop into a threadpool, SQLite busy-timeout, structured logging, a versioned-seed mechanism for clean data rollouts, and a daily scheduler pinned to a fixed time so restarts don't drift. fail-closed 的密钥与持久化守卫(配置错就拒绝启动,而不是悄悄丢数据)、把阻塞的 LLM 调用挪出事件循环进线程池、SQLite busy-timeout、结构化日志、带版本号的 seed 机制以干净地发布新数据、以及固定时间的每日定时器(重启不漂移)。

The journey迭代路线
How it iterated它是怎么迭代出来的

Built in tight loops — diagnose, fix, verify, ship — each phase grounded in what the running app actually did wrong.在紧凑的循环里构建 —— 诊断、修复、验证、上线 —— 每个阶段都基于运行中的应用真实暴露的问题。

PHASE 1 · Prototype原型

Get a real, deployed dashboard先有一个真实、已部署的看板

A working FastAPI + React app on Railway with policy data, filters, and a dashboard — but with in-browser-Babel blank-screens and noisy, unreliable data.一个能跑的 FastAPI + React 应用,有政策数据、筛选和看板 —— 但有浏览器内 Babel 白屏、数据嘈杂不可靠。

PHASE 2 · Product-grade hardening产品级硬化

Make it trustworthy & fast让它可信、变快

Precompiled the frontend, added fail-closed security & DB-persistence guards, a health check, and wired the latent “empty-shell” features (bookmarks, version diff, project scope) to real storage.预编译前端,加 fail-closed 安全与持久化守卫、健康检查,并把"空壳"功能(收藏夹、版本 diff、项目配置)接到真实存储。

PHASE 3 · Data quality数据质量

Build the LLM quality gate构建 LLM 质量闸

Diagnosed that most stored entries were off-topic or fake-URL media digests, then rebuilt ingestion around a strict LLM relevance/authenticity gate and accurate classification.诊断出大部分库存是跑题或假 URL 的媒体摘要,随后围绕严格的 LLM 相关性/真实性闸和精准分类重建了入库流程。

PHASE 4 · Reliable sourcing可靠来源

Search-driven official scraping搜索驱动的官方抓取

Replaced media-aggregator scraping with Brave-powered site:gov.cn discovery feeding the gate, then put it on a daily fixed-time scheduler with broadened energy + power-market scope.用 Brave 的 site:gov.cn 定位喂给质量闸,取代媒体聚合抓取,再放上每日固定时间的定时器,并把范围放宽到能源 + 电力市场。

PHASE 5 · UX & polish体验打磨

Make it a product把它做成产品

Real choropleth map, a consistent dashboard layout, genuinely working time/category/pagination filters, fuzzy search, and clearer labeling (publication vs. ingestion date).真填色地图、一致的看板布局、真正生效的时间/分类/分页筛选、模糊搜索,以及更清晰的标注(发布日期 vs 收录日期)。

Stack技术栈
Tools used所用工具
Python FastAPI · Uvicorn SQLite (WAL) React 18 esbuild Claude Haiku · Anthropic SDK Brave Search API BeautifulSoup · requests SVG + GeoJSON Docker Railway HMAC cookie auth