Operating Model¶
Current reality¶
ExzenTCG does not have one system of record. Several systems overlap:
- Shopee and Lazada are the upstream truth for marketplace orders and fulfillment readiness.
exzen-coreis the production commerce bridge and Telegram operating console.- Google Sheets + Apps Script are the practical inventory, landed-cost, allocation, finance, and consolidated-order system.
- Otto is the production waybill/download/print agent.
- n8n handles bank-email ingestion, Calendar glue, Otto waybill archival, and experimental SPX automation.
tcg-platformis the staging replacement platform, not production authority yet.
Main architectural issue¶
Multiple writers and local state stores create the risk. No single durable event or ownership boundary ties them together.
Current source-of-truth map¶
| Domain | Current practical source of truth | Other copies/projections | Note |
|---|---|---|---|
| Marketplace order status | Shopee/Lazada APIs | exzen-core, Sheets, Otto, tcg-platform staging |
No single internal order ledger owns all sources. |
| Telegram/Mini App orders | exzen-core SQLite, then Google Orders |
Telegram messages and admin/customer UI | Auto-approval is enabled. |
| Product/SKU catalog | Google Inventory/ProductName, plus marketplace catalogs |
exzen-core cache; tcg-platform imported catalog |
Same SKU exists across Sheets, marketplaces, SQLite, Postgres. |
| On-hand stock | Google Imports.Quantity Remaining and Inventory formulas |
Marketplace stock; tcg-platform snapshot |
Google remains authoritative today. |
| Landed cost/import batches | Google Imports and Import Fees |
tcg-platform PO/import model |
Opening-stock migration preserved existing Sheet cost basis. |
| Order allocation | Apps Script mutation of Google rows | Sheet status fields | Non-transactional; vulnerable to row drift/races. |
| Waybill/printing | Marketplace state + Otto SQLite | n8n Drive archive and printer queue | Otto owns physical label workflow. |
| Bank transactions | Gmail labels/messages → n8n → Google Transactions |
Telegram notifications | Current n8n queue behavior is fragile. |
| Finance/P&L | Google Finance/PnL formulas and external Sheets |
tcg-platform finance modules |
Real month-end parity remains a migration gap. |
Target operating model¶
tcg-platformPostgreSQL becomes the sole internal source of truth for catalog, stock, imports, orders, fulfillment state, COGS, and finance facts.- Marketplace connectors become adapters/projections, not independent truth stores.
- Telegram Mini App and operator bot should call
tcg-platformAPIs instead of writing SQLite/Sheets. - Otto can start as a specialized edge agent and receive durable fulfillment tasks from
tcg-platform. - Google Sheets should become read-only exports and reporting, not a transactional writer.
- n8n should stay non-critical glue unless a workflow has durable queue/replay semantics.