abczsl520

Node.js Project Architecture

開發程式設計v1.1.0
作者:abczsl520更新於 2026-05-18共 2 個版本 · 最新版本釋出於 2026-03-06nodejs-project-arch@clawhub_abczsl520/nodejs-project-arch
程式碼生成指令碼工具#Sdk

據 AlphaMoat 統計,截至 2026-09,Node.js Project Architecture 累計下載 1,729 次、獲 0 個星標,在全部 5,078 個 AI 技能中排名第 4,627 位,在「開發程式設計」分類(577 個)中排名第 546 位。

累計安裝
304
累計下載
1729
星標
-
全站排名
#4,627
全站前 92% · 「開發程式設計」前 95%
平台累計安裝累計下載星標評論
ClawHub ↗401729--
SkillHub ↗3041692-—

各平台的計數口徑不同,統計時間不一致。

這個技能是做什麼的

拆分路由、共享服務、資料庫訪問和前端資源,提供執行配置與管理編輯模式,示例涵蓋遊戲、工具和庫。共享配置不含秘密,只公開白名單值,並在生產採用前校驗已認證管理變更。

資料釋出於 2026-10-27

可以用來做什麼

  • 重構大型 Node.js 專案

什麼時候用

  • 模組與配置需要清楚邊界時

示例提示詞

以下是根據技能文件生成的示例,不代表實際執行結果。

提出模組佈局,審查公開配置和秘密的劃分。

月度資料趨勢

累計下載1729
559118818162026-03 · 累計下載 6462026-05 · 累計下載 8862026-06 · 累計下載 10572026-07 · 累計下載 12942026-08 · 累計下載 15422026-09 · 累計下載 172926-0326-09
星標-
0112026-03 · 星標 -2026-05 · 星標 -2026-06 · 星標 -2026-07 · 星標 -2026-08 · 星標 -2026-09 · 星標 -26-0326-09

2026-09 起統計方法調整:同名技能按作者分別統計,並覆蓋全部技能。圖中虛線為調整前的月份,與之後的資料不直接比較,也不計算跨越調整的增長。

月份累計下載環比星標
2026-091729—-
2026-081542+19.2%-
2026-071294+22.4%-
2026-061057+19.3%-
2026-05886—-
2026-03646—-

SKILL.md 原文

以下是作者釋出的原始檔案,按純文字顯示,本站未做修改或稽核;其中的連結不可點選,命令請核實後再執行。抓取於 2026-10-23。

3.4 KB · ClawHub v1.1.0
---
name: nodejs-project-arch
description: Node.js project architecture standards for AI-assisted development. Enforces file splitting (<400 lines), config externalization, route modularization, and admin dashboards. Use when creating new Node.js projects, refactoring large single-file codebases, or when AI context window is being consumed by oversized files. Covers H5 games (Canvas/Phaser/Matter.js), data tools (crawlers/scrapers), content platforms, monitoring dashboards, API services, and SDK libraries.
---

# Node.js Project Architecture for AI-Friendly Development

Architecture standards that keep files small enough for AI agents to read/edit without blowing the context window.

## Core Rules
展開全部(共 76 行)

- Single file max **400 lines**, `index.html` max **200 lines**, `server.js` entry max **100 lines**
- All tunable values in `config.json`, loaded at runtime, editable via admin dashboard
- Backend: `routes/` by domain, `services/` for shared logic, `db.js` for database
- Frontend: HTML skeleton only, JS/CSS in separate files
- Every project gets `admin.html` + `routes/admin.js` for config hot-reload

## Project Type Selection

Determine project type, then read the corresponding reference:

| Type | Signals | Reference |
|------|---------|-----------|
| **H5 Game** | Canvas, Phaser, Matter.js, game loop, sprites | [references/game.md](references/game.md) |
| **Data Tool** | Crawler, scraper, scheduler, data sync, analytics | [references/tool.md](references/tool.md) |
| **Content/Utility** | Generator, library, publisher, file processing | [references/tool.md](references/tool.md) |
| **Dashboard/Monitor** | Charts, real-time, alerts, metrics | [references/tool.md](references/tool.md) |
| **API Service** | REST endpoints, middleware, microservice | [references/tool.md](references/tool.md) |
| **SDK/Library** | Shared module, build step, multi-consumer | [references/sdk.md](references/sdk.md) |

## Quick Start (All Types)

1. Identify project type from table above
2. Read the corresponding reference file
3. Create directory structure per the reference
4. Extract hardcoded values → `config.json`
5. Split large files by function (each <400 lines)
6. Add `routes/admin.js` + `admin.html`
7. Frontend: `config.js` fetches `/api/config` at startup, code reads `GAME_CONFIG.xxx` or `APP_CONFIG.xxx`
8. Test locally → backup → deploy

## config.json Pattern (Universal)

```javascript
// Server: load and serve config
const config = JSON.parse(fs.readFileSync('./config.json', 'utf8'));
app.get('/api/config', (req, res) => {
  const safe = { ...config };
  delete safe.admin; // strip secrets
  res.json(safe);
});

// Admin: hot-reload
app.post('/admin/config', requireAdmin, (req, res) => {
  fs.writeFileSync('./config.json.bak', fs.readFileSync('./config.json'));
  fs.writeFileSync('./config.json', JSON.stringify(req.body, null, 2));
  Object.assign(config, req.body);
  res.json({ ok: true });
});
```

## Admin Dashboard Pattern (Universal)

`admin.html` auto-generates form from config structure:
- Password login (`x-admin-password` header)
- Visual config editor with save + hot-reload
- Stats overview (users/data/uptime)
- Config backup history + restore

## Why This Matters

Large single files consume massive context tokens when AI reads them:
- 3000-line file → ~40K tokens per read (20% of 200K window)
- 200-line module → ~2.7K tokens per read (1.3% of window)
- **Result: 10-15 productive rounds vs 3-5 before context compression**

「開發程式設計」分類下的熱門技能

資料月份:2026-09 · 下載/星標/安裝數聚合自公開技能註冊庫(ClawHub、SkillHub),按月更新。口徑說明見資料方法。