📂 Fail MD
📄 api-spec.md
📄 architecture.md
📄 compound-rules.md
📄 council-sync.md
📄 data-model.md
📄 money-ledger.md
📄 parking-rules.md
Sedang mengedit: council-sync.md
# Smart Parking — Council Sync How the backend shares data with each council (MBPP, MBSP). Several details are pending a council meeting and are marked TBD. ## Direction - **Backend → Council (push).** The backend pushes each council's own data into the council's **local database**. - Primary purpose stated by councils: **backup** / having the data on their side. ``` AWS EC2 (main DB) │ Council Sync (push, per tenant) ┌─────┴─────┐ ▼ ▼ MBPP local DB MBSP local DB (MBPP data) (MBSP data) ``` ## Data Scope (per tenant) Each council receives **only its own** (`tenant_id`) data: - **Compounds (saman)** — issued, status, payments - **Payments / revenue** — recognized revenue records - **Vehicles** — vehicles related to that council's activity - **Users** — users related to that council's transactions > Note on global entities: users and vehicles are global in the main system, but only the **subset related to the council's transactions** is pushed to that council. ## Diagram ```mermaid flowchart LR subgraph AWS["AWS EC2 — Main DB"] Core[("Primary / Replica")] SyncSvc["Council Sync Service<br/>(per-tenant push)"] Core --> SyncSvc end subgraph MBPP["🏛️ MBPP"] PPDB[("Local DB")] end subgraph MBSP["🏛️ MBSP"] SPDB[("Local DB")] end SyncSvc -->|"push MBPP data: compounds, payments, vehicles, users"| PPDB SyncSvc -->|"push MBSP data: compounds, payments, vehicles, users"| SPDB ``` ## Open Items (TBD — council meeting) 1. **Where apps read from** — do council-side apps/reports read from the **local DB** or directly from **AWS EC2**? Depends on council infrastructure decision. 2. **Sync mode** — live (event-driven), scheduled push (batch), or pull on demand. 3. **Frequency** — real-time vs hourly/daily batch. 4. **Transport/format** — API push, DB replication, or file exchange; payload schema. 5. **Offline handling** — retry/queue when a council's local DB is unreachable. 6. **Conflict/ownership** — backend is source of truth; local DB is a downstream copy (read-only on council side, assumed). ## Principles (regardless of final mode) - Strict **per-tenant isolation** — a council never receives another council's data. - **Idempotent** pushes — re-sending the same record must not duplicate. - **Auditable** — every sync run logged (what, when, how many records, success/fail). - Backend remains the **single source of truth**.
Simpan Perubahan