feat: SaaS foundation for CrowdSight

Elevate MiroFish/CrowdSight from single-container dev to a SaaS foundation:

- Local memory backend (Zep-compatible): memory services/models, local graph
  builder + updater, AgentActivity seam, import-boundary isolation; Zep stays
  default, local is opt-in behind MEMORY_BACKEND. Semantic parity not yet proven.
- Durable product persistence: projects/simulations/reports schema (migration
  0007) + tenant/owner-scoped ProductRepository + dual-write + scoped_project
  read-first + ArtifactStore abstraction; durable JobQueue + worker.py.
- SaaS hardening: durable RateLimiter (wired to login), UsageService (LLM
  accounting), redacted AuditService, idempotency, CORS allowlist, safe API
  errors, single-use PasswordResetService + endpoints (covers invite-pending).
- Exactly 3 roles (super_admin/admin/user) with tenant authz policy.
- Admin UI: GET/POST/PATCH /api/admin/users + GET/PUT /api/admin/settings
  (super-admin only, encrypted/masked); AdminView.vue + SettingsView.vue with
  admin/super-admin route guards, th/en i18n.
- Production deploy topology: multi-stage Dockerfile (frontend build + gunicorn
  wsgi + nginx SPA-proxy + supervisord worker), backend/wsgi.py, gunicorn dep.

Backend 197 passed; frontend 10 tests + build green. ruff unavailable (gap).
No commit of credentials; secrets handled via env/.env.example.
Deferred: Zep semantic A/B parity, object storage cutover, mobile QA, EasyPanel
container build of deploy topology.
This commit is contained in:
Kunthawat Greethong committed 2026-08-31 13:05:21 +07:00
1 parent 89d04e795b
commit 8b84378fe1
165 files changed
+15884 -4001

No files matched your search

+14 -7
View File
@@ -1,8 +1,14 @@
# ================================================================
# CrowdSight 环境变量配置
# CrowdSight environment configuration
# ================================================================
# 复制此文件为 .env 并填入你的 API 密钥:
# Copy this file to .env and fill in deployment secrets:
# cp .env.example .env
#
# Security (generate a unique value for every deployment)
SECRET_KEY=replace_with_a_long_random_secret
SESSION_COOKIE_SECURE=true
CORS_ALLOWED_ORIGINS=https://your-frontend.example.com
#
# LLM 配置支持两种方式:
# 方式1(推荐):设置 LLM_PROVIDER,只需提供 API Key
@@ -61,11 +67,12 @@ LLM_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
LLM_MODEL_NAME=qwen-plus
# ================================================================
# Zep 记忆图谱配置(必需)
# ================================================================
# 每月免费额度即可支撑简单使用
# 获取地址: https://app.getzep.com/
# Memory backend migration switch:
# zep = legacy Zep runtime (current default)
# local = local SQLAlchemy memory repository (requires imported memory graphs)
MEMORY_BACKEND=zep
# Legacy Zep credential; remove only after all consumers are cut over.
ZEP_API_KEY=your_zep_api_key_here