A privacy-first reference app for closing factory safety hazards—from report to verified resolution.
Factory Safety Loop turns a commonly scattered process—reporting hazards, assigning owners, rectifying problems, verifying results and closing cases—into one small, inspectable workflow. It includes a runnable React dashboard, an Express API, domain rules, tests and an optional Feishu adapter.
The repository is a clean-room reference implementation. Every record is synthetic; no production database, chat history, attachment, log, company configuration or real credential is included.
- A complete loop, not a form demo. Status transitions make ownership and verification explicit.
- Useful without cloud accounts. Mock mode runs locally and never calls Feishu.
- Integration stays optional. Domain rules do not depend on a collaboration platform.
- Privacy checks travel with the code.
npm run verifyruns tests and a repository privacy scan. - Small enough to learn from. The monorepo separates the web app, API, domain core and adapter.
- Hazard registration with location, risk level, description and due date
- State machine: open → assigned → rectifying → verifying → closed
- Dashboard metrics for open, overdue, pending verification and closure rate
- React + Vite dashboard with local fallback data
- Express REST API backed by an in-memory demonstration store
- Optional Feishu SSO and group-notification adapter boundaries
- Synthetic demo fixtures, CI, tests, privacy guidance and threat model
Requirements: Node.js 20.19 or newer.
git clone https://github.com/changhaoting1998-star/factory-safety-loop.git
cd factory-safety-loop
cp .env.example .env
npm install
npm run dev:apiIn a second terminal:
npm run dev:webOpen http://localhost:5173. The default FEISHU_MODE=mock does not access any external service.
stateDiagram-v2
[*] --> OPEN: report
OPEN --> ASSIGNED: assign owner
ASSIGNED --> RECTIFYING: start work
RECTIFYING --> VERIFYING: submit evidence
VERIFYING --> CLOSED: approve
VERIFYING --> RECTIFYING: request changes
CLOSED --> [*]
flowchart LR
Web[React dashboard] --> API[Express API]
API --> Core[Workflow core]
API --> Demo[(Synthetic demo store)]
API -. optional .-> Feishu[Feishu adapter]
apps/web React + Vite dashboard
apps/api Express HTTP API
packages/core Hazard state machine and metrics
packages/feishu-adapter Mock/real integration boundary
data/demo Synthetic fixtures only
docs Integration, privacy and threat-model notes
tests Domain and adapter tests
npm run verify
npm --workspace @factory-safety/web run buildverify runs the business-rule tests and privacy scanner. Before a public deployment, also run dependency and license audits, review the code manually and follow the threat model.
Mock mode is the safe default. The adapter exposes integration points for SSO and group notifications without coupling the workflow core to Feishu. See the integration guide.
Real App IDs, App Secrets, group IDs and callback URLs belong in the deployment environment and must never be committed. Feishu is a third-party product name; this project is not affiliated with or endorsed by Feishu.
Read PRIVACY.md, the desensitization guide and the threat model before importing organizational data.
This release is a reference app for local evaluation and secondary development. A production deployment still needs durable storage, authentication, RBAC, rate limits, security headers, safe attachment handling, audit-log controls, backups and an organization-specific legal review.
- PostgreSQL persistence example
- Role-based permissions and session hardening
- Evidence attachment validation
- Inspection-plan module
- Feishu message-card examples
- Docker Compose quick start
这是一个面向中小工厂的安全隐患闭环管理参考实现,覆盖隐患上报、责任分派、整改、复核和关闭。项目可在纯本地模拟模式运行,也预留了飞书登录与群消息通知适配层。
仓库只含虚构演示数据,不含生产数据库、真实人员、聊天记录、附件、企业配置或凭证。接入真实组织数据前,请先完成合法性评估、权限设计和脱敏检查。
Bug reports, workflow examples, documentation improvements and focused pull requests are welcome. Start with CONTRIBUTING.md and report security issues through SECURITY.md.
If this reference saves you time, consider starring the repository—it helps more manufacturing teams find it.
