Production-grade Casino Platform Generator Built with Bash + PHP + React + Docker + Kubernetes
ไม่ใช่แค่ deploy ได้ แต่ สร้างซ้ำได้ / audit ได้ / คุมเงินจริงได้
Meta-Master คือ Platform Generator ไม่ใช่ repo ธรรมดา
มันทำหน้าที่:
- สร้าง backend / frontend / infra
- บังคับโครงสร้าง production
- ป้องกันเงินจริงพังจาก callback / retry / fraud
- แพ็ก release พร้อม checksum + signature
┌─────────────┐
│ Frontend │ React (Player / Admin)
└─────┬───────┘
│ JWT
┌─────▼───────┐
│ Backend │ PHP (Wallet / Auth / Providers)
└─────┬───────┘
│ Atomic TX
┌─────▼───────┐
│ Database │ MySQL (Ledger / Audit)
└─────┬───────┘
│ Callback
┌─────▼───────┐
│ Game Provider│ Pragmatic / PG Soft
└─────────────┘
Infra:
- Docker / Docker Compose
- Reverse proxy and ingress (generated in infra phase)
- Cloudflare (HTTPS / WAF)
- Kubernetes (
infra/kubernetes/, Helm / multi-env)
zGaming/
├── backend/ # PHP backend (wallet, auth, callbacks)
├── frontend-player/ # React player UI
├── frontend-admin/ # React admin UI
├── apps/frontend-wallet/ # Wallet frontend workspace app
├── infra/kubernetes/ # Kubernetes manifests (Helm / Kustomize)
├── generator/
│ ├── meta-master.sh # Master controller
│ ├── phases/ # Phase-by-phase generators
│ └── lib/assert.sh # Environment guard
├── docker-compose.yml
└── README.md
ต้องการแผนเชิงระบบแบบละเอียด (meta-architecture + roadmap + VMware/Gitea/Cloudflared):
- ดู
docs/master-meta-blueprint.md - ดู
docs/codex-master-meta-prompt-template-2026.md(prompt template สำหรับสั่งงาน Codex แบบ production/compliance-first)
ทุกอย่างถูกแบ่งเป็น Phase แต่ละ phase:
- deterministic (รันซ้ำได้)
- fail-fast
- audit-friendly
| Phase | Description |
|---|---|
| 00 | Guard / Env validation |
| 10 | Backend core |
| 20 | Auth / JWT / Roles |
| 30 | Wallet / Ledger |
| 40 | Provider launch |
| 50 | Provider callbacks (idempotent) |
| 60 | Frontend (Player / Admin) |
| 70 | NGINX reverse proxy |
| 80 | Security hardening |
| 90 | Cloudflare / HTTPS |
| 95 | Kubernetes (Helm, multi-env) |
| 99 | Final release / signing |
| 107 | Meta orchestrator scaffold (core/modules/api/obs) |
Phase 107-meta-orchestrator.sh injects a production-oriented modular scaffold aligned with docs/master-meta-blueprint.md:
core/orchestrator/kernel.ts(event-driven module lifecycle kernel)core/plugin-loader/loader.ts(hot-load plugin discovery)api/gateway/server.ts(Fastify gateway with JWT + rate limit + Zod validation)observability/tracing/README.md(tracing rollout checklist)scripts/healthcheck.sh(runtime health probe helper)
Run only this scaffold phase:
./generator/meta-master.sh phase 107-meta-orchestrator.shใช้ตัวติดตั้งใหม่ที่รวม deterministic install + metadata extraction + compliance report + SBOM-lite:
./installer/zgaming-ultra-installer.sh quick
./installer/zgaming-ultra-installer.sh full
./installer/zgaming-ultra-installer.sh full-project
./installer/zgaming-ultra-installer.sh no-cost
./installer/zgaming-ultra-installer.sh plan
./generator/meta-master.sh clean-installer fullสิ่งที่ installer ทำแบบอัตโนมัติ:
- ตรวจสอบ dependency/runtime (docker, git, bash, rg, curl)
- รัน
meta-master doctorเพื่อยืนยัน baseline - สแกนไฟล์ทั้ง repo และสร้าง
installer/artifacts/repo-manifest.sha256 - สร้างรายงาน compliance:
installer/reports/compliance-report.json - สร้าง SBOM-lite (SPDX JSON):
installer/artifacts/sbom-lite.spdx.json - รองรับ diagnostics mode สำหรับ container/network health
- มีโหมด
full-projectสำหรับ hardening checks + vulnerability scan + release packaging - มีโหมด
no-costสำหรับสร้าง metadata/compliance/release artifacts โดยไม่บังคับ Docker runtime และไม่บังคับสร้าง release bundle.zip - สร้าง audit report แบบ structured (
installer/reports/audit-report.json) และ workflow plan (installer/artifacts/workflow-plan.txt) - สร้าง infrastructure inventory อัตโนมัติ (
installer/artifacts/infrastructure-inventory.json) สำหรับ baseline host + Ubuntu environments
Pseudo-workflow:
clean_install(mode):
verify required binaries + runtime
doctor-check deterministic platform baseline
scan repository files => hash manifest
evaluate compliance baselines => structured report
emit infrastructure inventory for host/vm/subsystem
generate SPDX-lite SBOM artifact
if mode == full: run full meta-master installer + diagnostics
Repository now includes workspace orchestration files:
pnpm-workspace.yamlturbo.json- root
package.jsonscripts for build/lint/test/scan
This is the migration baseline for clean architecture separation across apps/, services/, packages/, and factory/ modules.
ขั้นต่ำ:
- Linux / WSL2 (Ubuntu 22.04+)
- Docker ≥ 25
- Docker Compose v2
- OpenSSL
- Bash ≥ 5
ตรวจสอบ environment:
./generator/meta-master.sh doctorโหมดการรันหลัก:
./generator/meta-master.sh all
./generator/meta-master.sh final # alias ของ all
./generator/meta-master.sh installer
./generator/meta-master.sh upgrade
./generator/meta-master.sh test # run phase 110 (go-live test/report)
./generator/meta-master.sh list
./generator/meta-master.sh status
./generator/meta-master.sh scan # generate full logic scan + upgrade plan
./generator/meta-master.sh phase 60-frontend.shรองรับการ run แบบช่วง phase (resume/retry-safe):
MM_FROM_PHASE=60-frontend.sh ./generator/meta-master.sh upgrade
MM_FROM_PHASE=90-cloudflare.sh MM_TO_PHASE=108-release.sh ./generator/meta-master.sh allสั่งสแกน logic ทั้ง repo แบบ deterministic พร้อมแผน upgrade ที่พร้อม audit:
./generator/meta-master.sh scanArtifacts ที่จะถูกสร้าง:
reports/logic-scan-report.json(structured check results)reports/logic-scan-upgrade-plan.md(prioritized remediation plan)
git clone <repo>
cd zGaming
chmod +x generator/meta-master.sh
./generator/meta-master.sh allสิ่งที่เกิดขึ้น:
- Generate code ทุกส่วน
- Build frontend / backend
- เตรียม infra
- Pack release
docker compose up -d --buildAccess:
- Player UI → http://localhost/
- Admin UI → http://localhost/admin
- API → http://localhost/api/
- JWT (HMAC-SHA256)
- Roles:
player,admin - Audit log ทุก login
Login API:
POST /api/login.php
Header:
Authorization: Bearer <JWT>
- Atomic DB transaction
- Ledger-based (ไม่ update balance ตรง)
- Idempotent provider callbacks
- Double callback safe
เงินไม่หาย แม้ provider ยิงซ้ำ
รองรับ:
- Pragmatic Play
- PG Soft
คุณสมบัติ:
- Signature verification
- Unique transaction guard
- Retry / timeout safe
- Provider-specific response mapping
- Login
- Lobby
- Game launcher (iframe)
- User list
- Wallet overview
- Audit-ready
Build ด้วย:
- React 18
- Vite
- Static serving via NGINX
- OWASP baseline
- Rate limiting (NGINX)
- JWT validation
- Secret validation (assert)
- Cloudflare WAF ready
รองรับ:
- HTTPS (Full / Strict)
- Origin IP allowlist
- WAF rules
- Rate limiting
Config:
cloudflare/
- Helm chart
- Multi-env (
dev / staging / prod) - ConfigMap / Secret separation
- Health check + readiness
Deploy ตัวอย่าง:
helm install casino k8s/helm/casino -f values-prod.yamlPhase 99 จะ:
- Build immutable artifacts
- Export Docker images
- Create source archive
- Generate
SHA256SUMS - Sign release
- Pack ZIP สำหรับ handover
Verify:
openssl dgst -sha256 \
-verify release.pub \
-signature SHA256SUMS.sig \
SHA256SUMSรองรับ:
- Auth audit
- Wallet ledger
- Provider callback log
- Traceable transaction ID
เหมาะกับ:
- Regulator
- Investor due-diligence
- Internal audit
ออกแบบให้รับมือ:
- Double callback
- Retry storm
- Provider latency
- Partial failure
(Phase Chaos สามารถเพิ่มได้)
Casino system ไม่พังเพราะ code สวย แต่พังเพราะ state + money + callback
Meta-Master ถูกออกแบบมาเพื่อ:
- คุม state
- คุมเงินจริง
- คุมความซับซ้อน
หัวข้อที่เคยอยู่ในแผนต่อขยาย ได้ถูกยกระดับเข้าเป็น phase มาตรฐานแล้ว:
- ✅ Multi-currency / FX (
35-fx.sh,36-fx-live.sh,37-currency-lock.sh,38-multi-wallet.sh) - ✅ Live reconciliation (
100-bank-reconciliation.sh,93-settlement-engine.sh) - ✅ DR / backup / restore (
85-backup.sh,86-restore.sh,87-dr-test.sh,88-offsite.sh,91-hot-standby.sh) - ✅ ISO27001 / PCI mapping (
80-security.sh,105-compliance-dashboard.sh,106-auditor-handover.sh) - ✅ Chaos testing phase (
30-wallet.sh,110-runtest-report.sh,scripts/chaos-callback-storm.sh)
สามารถ run ผ่าน ./generator/meta-master.sh upgrade หรือ run แบบ phase-by-phase ได้ทันที
Meta-Master Casino Platform Built to survive production, not demos.
Added production-oriented modules for deterministic gaming and multi-chain wallet orchestration:
modules/game-engine/(cascade slot engine, provably-fair seed utilities, bounded RTP controller)modules/wallet/(stateless signer abstraction + ETH/SOL wallet adapters)modules/ledger/ledger.ts(serializable + idempotent transfer primitive)infra/kubernetes/api-deployment.yaml(gateway deployment baseline).github/workflows/deploy.yml(container build/push/deploy path)docs/ultra-meta-implementation-plan.md(pseudo-flow, compliance checklist, layer mapping)
หมายเหตุ: wallet signer ใน scaffold เป็น development provider เท่านั้น ต้องเปลี่ยนเป็น KMS/HSM ก่อน production จริง.
- Backend auth hardening:
backend/api/login.phpnow validates canonical wallet intent, nonce format, signature, and emits short-lived JWT claims. - Multi-chain orchestration:
modules/wallet/enforces chainId allow-lists for ETH/SOL adapters and exposes human-readable transaction intent. - Audit-ready ledger:
modules/ledger/ledger.tsnow returns immutable hash and duplicate-detection status for provider callback idempotency. - Kubernetes hardening:
infra/kubernetes/api-deployment.yamlincludes ConfigMap/Secret split, HPA, Service, and NetworkPolicy baseline. - Observability + chaos:
scripts/healthcheck.shvalidates app + trace endpoint;scripts/chaos-callback-storm.shsimulates callback storms. - Immutable artifacts: installer now emits
SHA256SUMSandSHA256SUMS.sigunderinstaller/artifacts/release/.
Additional documentation:
docs/compliance-checklist.mddocs/architecture-diagram.md
- Wallet integration upgraded with strict chain validation and deterministic pre-submit simulation in
modules/wallet/*. - Typed client bootstrap for Wagmi + Viem is available in
modules/wallet/wagmi-viem.ts. - Autonomous Content Factory modules are isolated into
factory/scout,factory/render, andfactory/publisherwith stateless orchestration primitives. - Publisher now supports resumable uploads via chunked coordinator (
factory/publisher/resumable-upload.ts). - Render farm includes deterministic dispatch + HPA tuning contract (
factory/render/stateless-render-farm.ts).
pnpm run setup:codexThis command enforces:
pnpm installnpx playwright install- Multi-chain isolation and anomaly guardrail checks (
scripts/verify-ops-guardrails.sh)