← Kembali ke Dokumentasi
Contoh dokumentasi backend

erd.md

docs/04-database/erd.md

Contoh isi file untuk sistem antrian. Sesuaikan dengan implementasi proyek Anda.

# ERD

Contoh model lokal Antrian Service. user_id adalah referensi identitas lintas service, bukan foreign key langsung ke Identity DB.

```mermaid
erDiagram
  SERVICE ||--o{ ANTRIAN : receives
  SERVICE {
    string code PK
    int capacity
  }
  ANTRIAN {
    uuid id PK
    string service_code FK
    string user_id
    string status
    timestamp created_at
  }
  IDEMPOTENCY_REQUEST {
    string user_id PK
    string operation PK
    string key PK
    string payload_hash
    json response
    timestamp expires_at
  }
  OUTBOX_EVENT {
    uuid event_id PK
    uuid aggregate_id
    string event_type
    json payload
    timestamp published_at
  }
```

Pendaftaran menyimpan antrian, hasil idempotency, dan outbox dalam satu transaksi. Setiap perubahan tabel/index/constraint wajib migration versioned. Uji reservasi kapasitas dan unique constraint secara concurrent pada integration test.