> For the complete documentation index, see [llms.txt](https://payana-saas.gitbook.io/payana-saas-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://payana-saas.gitbook.io/payana-saas-docs/arsitektur/indexer.md).

# Lapisan Indexer

Dibangun dengan [Ponder](https://ponder.sh/) — kerangka kerja indexing blockchain yang mendengarkan event kontrak secara real-time dan memasukkannya ke PostgreSQL dengan skema yang sepenuhnya type-safe.

## Kenapa dibutuhkan

Tanpa indexer, setiap halaman yang menampilkan "riwayat klaim gaji karyawan ini" harus memanggil node RPC berulang kali untuk membaca event lama satu per satu — lambat, mahal, dan tidak scalable. Ponder memindahkan pekerjaan itu ke proses background yang berjalan sekali, terus menerus, dan menyimpan hasilnya ke database biasa yang bisa di-query secepat query SQL apa pun.

## Bagaimana ia menemukan vault

Karena setiap perusahaan punya `CompanyVault`-nya sendiri (dideploy dinamis oleh `PayrollFactory`), Ponder tidak mengawasi satu alamat tetap. Sebagai gantinya, ia memakai pola **factory-based address discovery**: mengawasi event `VaultDeployed` dari `PayrollFactory`, lalu otomatis mulai mengindeks setiap alamat vault baru yang muncul dari event itu — tanpa perlu dikonfigurasi ulang setiap ada perusahaan baru mendaftar.

## Apa yang diindeks

| Tabel                   | Isi                              |
| ----------------------- | -------------------------------- |
| `company`               | Data perusahaan dari factory     |
| `employeeStream`        | Status stream gaji tiap karyawan |
| `salaryClaim`           | Riwayat setiap klaim EWA         |
| `salaryAdvance`         | Riwayat kasbon                   |
| `cliffVest`             | Bonus dengan jadwal vesting      |
| `severanceVault`        | Data pesangon                    |
| `terminationProposal`   | Proposal & status PHK            |
| `complianceVault`       | Akumulasi potongan BPJS/PPh21    |
| `employmentCertificate` | Data SBT                         |
| `platformFeePayment`    | Pembayaran fee ke platform       |
| `lowBalanceAlert`       | Alert saldo vault menipis        |
| `vaultWithdrawal`       | Penarikan dana perusahaan        |
| `roleChange`            | Perubahan HR\_ROLE/LEGAL\_ROLE   |

Yang **tidak** diindeks: event `Transfer` generik dari token ERC-20 (IDRX) — riwayat transfer di luar konteks payroll ditangani terpisah oleh backend bila diperlukan.

## API yang diekspos

Ponder menjalankan server HTTP (dibangun dengan [Hono](https://hono.dev/)) yang diquery langsung oleh `payana-frontend` untuk data yang sudah terindeks, dan juga dibaca langsung dari PostgreSQL oleh `payana-backend` (lewat client `postgres` dengan `search_path` diarahkan ke skema indexer) untuk fitur seperti compliance reporting yang butuh join dengan data off-chain.

## Ketika kontrak di-generasi ulang

Setiap kali `payana-contract` di-redeploy dengan alamat `PayrollFactory` baru (generasi baru), indexer harus dikonfigurasi ulang dengan alamat dan blok awal (`PAYROLL_START_BLOCK`) yang baru, lalu diindeks dari nol — vault dari generasi factory sebelumnya menjadi "orphaned" (tidak lagi terhubung ke factory aktif), bukan otomatis dimigrasikan.

Detail skema lengkap: [Skema Indexer](/payana-saas-docs/dokumentasi-teknis/skema-indexer.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://payana-saas.gitbook.io/payana-saas-docs/arsitektur/indexer.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
