Documentation Index
Fetch the complete documentation index at: https://mintlify.com/AdriP-maker/JAAR_Antigravity/llms.txt
Use this file to discover all available pages before exploring further.
Why offline-first?
Rural water board collectors — cobradores — operate across mountain communities in Panama where cell signal is unreliable or entirely absent. A collector visiting Sector Caballero Arriba on a Sunday morning cannot wait for a 4G connection to record a $3.00 monthly payment. The system must work on the device, in the field, right now. SIMAP Digital solves this with an offline-first architecture: the local IndexedDB database is the primary source of truth at all times. The cloud (Supabase) is a sync target, not a dependency.How it works
Every user action follows the same path regardless of whether the device is online or offline:- Write to IndexedDB first. All creates and updates go directly to the local Dexie database — never blocked by network status.
- Queue the change. A record is added to the
pendingSynctable marking the operation as outstanding. - Detect connectivity. The
useOnlinehook continuously monitors the browser’sonline/offlineevents. - Push to Supabase. When connectivity is restored,
syncServicereads the queue and pushes each pending record to the Supabase REST API. - Confirm and clear. Successfully synced records are marked
sincronizadoand removed from the queue.
The pendingSync table
Every pending cloud operation is tracked as a row in pendingSync:
| Field | Type | Description |
|---|---|---|
id | auto-increment integer | Local primary key |
type | string | Operation type — e.g. "pago", "gasto", "jornal" |
data | object | Full payload to be sent to Supabase |
timestamp | string (ISO 8601) | When the local record was created |
The useOnline hook
useOnline is a lightweight React hook that wraps the browser’s native connectivity events and exposes a reactive boolean:
What works offline
The following operations are fully available with zero internet:| Feature | Module |
|---|---|
| Recording monthly payment cobros | pagosService.js |
| Partial, multi-month, and advance payments | pagosService.js |
| Logging community work jornales | jornalesService.js |
| Registering expenses (gastos) | gastosService.js |
| Browsing and creating community forum posts | foroService.js |
| Generating PDF and Excel reports | reportesService.js (SheetJS, bundled) |
| Viewing a client’s payment history | db.pagos |
| Checking and updating system configuration | db.config |
What requires internet
A small number of operations depend on a live Supabase connection:| Operation | Reason |
|---|---|
| Initial login | Supabase Auth validates credentials and issues a session token |
| First sync after login | syncFromSupabase() downloads all users, pagos, saldos, and gastos to seed the local cache |
| Cloud backup / multi-device sync | Pending records in pendingSync are flushed to PostgreSQL |
| New junta B2B registration | registerJunta() creates rows in Supabase juntas table |
Sync lifecycle
User performs an action offline
The cobrador records a payment.
pagosService writes the record to db.pagos and adds a corresponding entry to db.pendingSync with type: "pago" and the full pago payload.Device detects connectivity
useOnline fires the online event handler and sets isOnline = true. The UI removes the “Sin Red” indicator.syncService flushes the queue
pushToSupabase() in syncService.js iterates over all pending records and calls supabase.from('pagos').insert(...) for each one, mapping local field names (e.g. mesTarget) to Supabase column names (e.g. mes_target).Supabase confirms the write
On success, the record is marked
sincronizado. On failure (e.g. network dropped mid-sync), it remains in pendingSync and will be retried on the next connectivity event.Security on logout. When a user calls This ensures that no personally identifiable financial data persists in the browser’s IndexedDB after the session ends — important when cobradores share devices or work in shared community spaces.
logout(), SIMAP Digital clears the three most sensitive local tables before ending the session: