# soraou/mogpog-waterworks architecture

> Architecture diagram of the GitHub repository soraou/mogpog-waterworks, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/soraou/mogpog-waterworks
- Repository: https://github.com/soraou/mogpog-waterworks

## Overview

Mogpog Waterworks is a mobile water-utility app for managing barangays, subscriber accounts, monthly meter readings and bills. Staff browse or search accounts, record readings and review account history or receipts; they can also import the official Excel workbook and export workbook data. SQLite backs the operational records and settings, while shared billing logic computes charges. The graph follows documented imports and sampled call sites; several screen and database details are only partially excerpted, so uncertain links are omitted.

Main entry points: [`db/queries.ts`](https://github.com/soraou/mogpog-waterworks/blob/main/db/queries.ts) (Record queries), [`app/(tabs)/index.tsx`](https://github.com/soraou/mogpog-waterworks/blob/main/app/(tabs)/index.tsx) (Account search), [`lib/billing.ts`](https://github.com/soraou/mogpog-waterworks/blob/main/lib/billing.ts) (Tariff calculations), [`app/account/[id].tsx`](https://github.com/soraou/mogpog-waterworks/blob/main/app/account/%5Bid%5D.tsx) (Account details)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Utility workflows"]
  node_home["Account search<br/>[index.tsx]"]
  node_account["Account details<br/>[&#91;id&#93;.tsx]"]
  node_addaccount["Add account<br/>[add.tsx]"]
  node_barangay["Barangay details<br/>[&#91;id&#93;.tsx]"]
  node_reading["Meter reading<br/>[&#91;id&#93;.tsx]"]
  node_receipt["Receipt view<br/>[&#91;id&#93;.tsx]"]
  node_settings["Settings<br/>[index.tsx]"]
  node_rowaccount["Account row<br/>[AccountRow.tsx]"]
  node_rowbarangay["Barangay row<br/>[BarangayRow.tsx]"]
  node_statusdot["Status indicator<br/>[StatusDot.tsx]"]
  node_receiptcomponent["Receipt layout<br/>[Receipt.tsx]"]
  node_theme["Theme constants<br/>[theme.ts]"]
end

subgraph group_data["Local records"]
  node_store[("SQLite database<br/>[schema.ts]")]
  node_queries["Record queries<br/>[queries.ts]"]
  node_officialimport["Import application<br/>[officialImport.ts]"]
end

subgraph group_billing["Billing logic"]
  node_billing["Tariff calculations<br/>[billing.ts]"]
end

subgraph group_excel["Workbook exchange"]
  node_importscreen["Workbook import screen<br/>[import.tsx]"]
  node_exportscreen["Workbook export screen<br/>[export.tsx]"]
  node_parser["Workbook parser<br/>[importParser.ts]"]
  node_plan["Import planner<br/>[importPlan.ts]"]
  node_format["Workbook format rules<br/>[format.ts]"]
  node_base64["Base64 conversion<br/>[base64.ts]"]
  node_exportworkbook["Workbook exporter<br/>[exportWorkbook.ts]"]
  node_template["Workbook template"]
end

node_staff(("Utility staff"))

node_staff -->|"browses"| node_home
node_home -->|"searches accounts"| node_queries
node_home -->|"renders"| node_rowaccount
node_home -.->|"renders"| node_rowbarangay
node_rowaccount -->|"renders"| node_statusdot
node_home -->|"opens account"| node_account
node_staff -->|"records reading"| node_reading
node_account -->|"loads and updates"| node_queries
node_reading -->|"reads and saves"| node_queries
node_reading -->|"calculates charges"| node_billing
node_account -->|"shows bill status"| node_billing
node_account -.->|"opens receipt"| node_receipt
node_receipt -->|"loads receipt data"| node_queries
node_receipt -->|"uses bill logic"| node_billing
node_receipt -->|"renders"| node_receiptcomponent
node_staff -->|"adds account"| node_addaccount
node_addaccount -->|"saves account"| node_queries
node_barangay -->|"loads accounts"| node_queries
node_settings -->|"reads settings"| node_queries
node_queries -->|"reads and writes"| node_store
node_queries -->|"derives bill status"| node_billing
node_staff -->|"imports workbook"| node_importscreen
node_importscreen -->|"parses workbook"| node_parser
node_importscreen -->|"builds import plan"| node_plan
node_importscreen -->|"applies import"| node_officialimport
node_parser -->|"decodes bytes"| node_base64
node_parser -->|"normalizes cells"| node_format
node_plan -->|"uses parsed data"| node_parser
node_plan -->|"uses format rules"| node_format
node_officialimport -->|"writes imported records"| node_store
node_officialimport -->|"normalizes values"| node_format
node_officialimport -->|"checks bill status"| node_billing
node_staff -->|"exports workbook"| node_exportscreen
node_exportscreen -->|"loads records"| node_queries
node_exportscreen -->|"creates workbook"| node_exportworkbook
node_exportscreen -->|"encodes file"| node_base64
node_exportworkbook -->|"reads export data"| node_queries
node_exportworkbook -->|"formats workbook"| node_format
node_exportworkbook -.->|"encodes workbook"| node_base64
node_exportworkbook -->|"uses template"| node_template
node_format -->|"calculates workbook amounts"| node_billing
node_home -->|"uses styling"| node_theme
node_account -->|"uses styling"| node_theme
node_rowaccount -->|"uses styling"| node_theme
node_rowbarangay -->|"uses styling"| node_theme
node_statusdot -->|"uses styling"| node_theme

click node_home "https://github.com/soraou/mogpog-waterworks/blob/main/app/(tabs)/index.tsx"
click node_account "https://github.com/soraou/mogpog-waterworks/blob/main/app/account/%5Bid%5D.tsx"
click node_addaccount "https://github.com/soraou/mogpog-waterworks/blob/main/app/account/add.tsx"
click node_barangay "https://github.com/soraou/mogpog-waterworks/blob/main/app/barangay/%5Bid%5D.tsx"
click node_reading "https://github.com/soraou/mogpog-waterworks/blob/main/app/reading/%5Bid%5D.tsx"
click node_receipt "https://github.com/soraou/mogpog-waterworks/blob/main/app/receipt/%5Bid%5D.tsx"
click node_settings "https://github.com/soraou/mogpog-waterworks/blob/main/app/settings/index.tsx"
click node_rowaccount "https://github.com/soraou/mogpog-waterworks/blob/main/components/AccountRow.tsx"
click node_rowbarangay "https://github.com/soraou/mogpog-waterworks/blob/main/components/BarangayRow.tsx"
click node_statusdot "https://github.com/soraou/mogpog-waterworks/blob/main/components/StatusDot.tsx"
click node_receiptcomponent "https://github.com/soraou/mogpog-waterworks/blob/main/components/Receipt.tsx"
click node_theme "https://github.com/soraou/mogpog-waterworks/blob/main/constants/theme.ts"
click node_store "https://github.com/soraou/mogpog-waterworks/blob/main/db/schema.ts"
click node_queries "https://github.com/soraou/mogpog-waterworks/blob/main/db/queries.ts"
click node_officialimport "https://github.com/soraou/mogpog-waterworks/blob/main/db/officialImport.ts"
click node_billing "https://github.com/soraou/mogpog-waterworks/blob/main/lib/billing.ts"
click node_importscreen "https://github.com/soraou/mogpog-waterworks/blob/main/app/(tabs)/import.tsx"
click node_exportscreen "https://github.com/soraou/mogpog-waterworks/blob/main/app/(tabs)/export.tsx"
click node_parser "https://github.com/soraou/mogpog-waterworks/blob/main/excel/importParser.ts"
click node_plan "https://github.com/soraou/mogpog-waterworks/blob/main/excel/importPlan.ts"
click node_format "https://github.com/soraou/mogpog-waterworks/blob/main/excel/format.ts"
click node_base64 "https://github.com/soraou/mogpog-waterworks/blob/main/excel/base64.ts"
click node_exportworkbook "https://github.com/soraou/mogpog-waterworks/blob/main/excel/exportWorkbook.ts"
click node_template "https://github.com/soraou/mogpog-waterworks/blob/main/excel/templateSkeleton.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_home,node_account,node_addaccount,node_barangay,node_reading,node_receipt,node_settings,node_rowaccount,node_rowbarangay,node_statusdot,node_receiptcomponent,node_theme toneBlue
class node_store,node_queries,node_officialimport toneAmber
class node_billing toneMint
class node_importscreen,node_exportscreen,node_parser,node_plan,node_format,node_base64,node_exportworkbook,node_template toneRose
class node_staff toneIndigo
```

## Components

### Utility workflows

- [Account search](https://github.com/soraou/mogpog-waterworks/blob/main/app/(tabs)/index.tsx): `app/(tabs)/index.tsx`
- [Account details](https://github.com/soraou/mogpog-waterworks/blob/main/app/account/%5Bid%5D.tsx): `app/account/[id].tsx`
- [Add account](https://github.com/soraou/mogpog-waterworks/blob/main/app/account/add.tsx): `app/account/add.tsx`
- [Barangay details](https://github.com/soraou/mogpog-waterworks/blob/main/app/barangay/%5Bid%5D.tsx): `app/barangay/[id].tsx`
- [Meter reading](https://github.com/soraou/mogpog-waterworks/blob/main/app/reading/%5Bid%5D.tsx): `app/reading/[id].tsx`
- [Receipt view](https://github.com/soraou/mogpog-waterworks/blob/main/app/receipt/%5Bid%5D.tsx): `app/receipt/[id].tsx`
- [Settings](https://github.com/soraou/mogpog-waterworks/blob/main/app/settings/index.tsx): `app/settings/index.tsx`
- [Account row](https://github.com/soraou/mogpog-waterworks/blob/main/components/AccountRow.tsx): `components/AccountRow.tsx`
- [Barangay row](https://github.com/soraou/mogpog-waterworks/blob/main/components/BarangayRow.tsx): `components/BarangayRow.tsx`
- [Status indicator](https://github.com/soraou/mogpog-waterworks/blob/main/components/StatusDot.tsx): `components/StatusDot.tsx`
- [Receipt layout](https://github.com/soraou/mogpog-waterworks/blob/main/components/Receipt.tsx): `components/Receipt.tsx`
- [Theme constants](https://github.com/soraou/mogpog-waterworks/blob/main/constants/theme.ts): `constants/theme.ts`

### Local records

- [SQLite database](https://github.com/soraou/mogpog-waterworks/blob/main/db/schema.ts): `db/schema.ts`
- [Record queries](https://github.com/soraou/mogpog-waterworks/blob/main/db/queries.ts): `db/queries.ts`
- [Import application](https://github.com/soraou/mogpog-waterworks/blob/main/db/officialImport.ts): `db/officialImport.ts`

### Billing logic

- [Tariff calculations](https://github.com/soraou/mogpog-waterworks/blob/main/lib/billing.ts): `lib/billing.ts`

### Workbook exchange

- [Workbook import screen](https://github.com/soraou/mogpog-waterworks/blob/main/app/(tabs)/import.tsx): `app/(tabs)/import.tsx`
- [Workbook export screen](https://github.com/soraou/mogpog-waterworks/blob/main/app/(tabs)/export.tsx): `app/(tabs)/export.tsx`
- [Workbook parser](https://github.com/soraou/mogpog-waterworks/blob/main/excel/importParser.ts): `excel/importParser.ts`
- [Import planner](https://github.com/soraou/mogpog-waterworks/blob/main/excel/importPlan.ts): `excel/importPlan.ts`
- [Workbook format rules](https://github.com/soraou/mogpog-waterworks/blob/main/excel/format.ts): `excel/format.ts`
- [Base64 conversion](https://github.com/soraou/mogpog-waterworks/blob/main/excel/base64.ts): `excel/base64.ts`
- [Workbook exporter](https://github.com/soraou/mogpog-waterworks/blob/main/excel/exportWorkbook.ts): `excel/exportWorkbook.ts`
- [Workbook template](https://github.com/soraou/mogpog-waterworks/blob/main/excel/templateSkeleton.ts): `excel/templateSkeleton.ts`

### Other components

- **Utility staff**

## Connections

- Utility staff → Account search: browses
- Account search → Record queries: searches accounts (evidence: `app/(tabs)/index.tsx`)
- Account search → Account row: renders (evidence: `app/(tabs)/index.tsx`)
- Account search → Barangay row: renders (evidence: `app/(tabs)/index.tsx`)
- Account row → Status indicator: renders (evidence: `components/AccountRow.tsx`)
- Account search → Account details: opens account (evidence: `app/(tabs)/index.tsx`)
- Utility staff → Meter reading: records reading
- Account details → Record queries: loads and updates (evidence: `app/account/[id].tsx`)
- Meter reading → Record queries: reads and saves (evidence: `app/reading/[id].tsx`)
- Meter reading → Tariff calculations: calculates charges (evidence: `app/reading/[id].tsx`)
- Account details → Tariff calculations: shows bill status (evidence: `app/account/[id].tsx`)
- Account details → Receipt view: opens receipt
- Receipt view → Record queries: loads receipt data (evidence: `app/receipt/[id].tsx`)
- Receipt view → Tariff calculations: uses bill logic (evidence: `app/receipt/[id].tsx`)
- Receipt view → Receipt layout: renders (evidence: `app/receipt/[id].tsx`)
- Utility staff → Add account: adds account
- Add account → Record queries: saves account (evidence: `app/account/add.tsx`)
- Barangay details → Record queries: loads accounts (evidence: `app/barangay/[id].tsx`)
- Settings → Record queries: reads settings (evidence: `app/settings/index.tsx`)
- Record queries → SQLite database: reads and writes (evidence: `db/queries.ts`)
- Record queries → Tariff calculations: derives bill status (evidence: `db/queries.ts`)
- Utility staff → Workbook import screen: imports workbook
- Workbook import screen → Workbook parser: parses workbook (evidence: `app/(tabs)/import.tsx`)
- Workbook import screen → Import planner: builds import plan (evidence: `app/(tabs)/import.tsx`)
- Workbook import screen → Import application: applies import (evidence: `app/(tabs)/import.tsx`)
- Workbook parser → Base64 conversion: decodes bytes (evidence: `excel/importParser.ts`)
- Workbook parser → Workbook format rules: normalizes cells (evidence: `excel/importParser.ts`)
- Import planner → Workbook parser: uses parsed data (evidence: `excel/importPlan.ts`)
- Import planner → Workbook format rules: uses format rules (evidence: `excel/importPlan.ts`)
- Import application → SQLite database: writes imported records (evidence: `db/officialImport.ts`)
- Import application → Workbook format rules: normalizes values (evidence: `db/officialImport.ts`)
- Import application → Tariff calculations: checks bill status (evidence: `db/officialImport.ts`)
- Utility staff → Workbook export screen: exports workbook
- Workbook export screen → Record queries: loads records (evidence: `app/(tabs)/export.tsx`)
- Workbook export screen → Workbook exporter: creates workbook (evidence: `app/(tabs)/export.tsx`)
- Workbook export screen → Base64 conversion: encodes file (evidence: `app/(tabs)/export.tsx`)
- Workbook exporter → Record queries: reads export data (evidence: `excel/exportWorkbook.ts`)
- Workbook exporter → Workbook format rules: formats workbook (evidence: `excel/exportWorkbook.ts`)
- Workbook exporter → Base64 conversion: encodes workbook (evidence: `excel/exportWorkbook.ts`)
- Workbook exporter → Workbook template: uses template (evidence: `excel/exportWorkbook.ts`)
- Workbook format rules → Tariff calculations: calculates workbook amounts (evidence: `excel/format.ts`)
- Account search → Theme constants: uses styling (evidence: `app/(tabs)/index.tsx`)
- Account details → Theme constants: uses styling (evidence: `app/account/[id].tsx`)
- Account row → Theme constants: uses styling (evidence: `components/AccountRow.tsx`)
- Barangay row → Theme constants: uses styling (evidence: `components/BarangayRow.tsx`)
- Status indicator → Theme constants: uses styling (evidence: `components/StatusDot.tsx`)
