# alipppyy/sipandu architecture

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

- Interactive diagram: https://gitdiagram.com/alipppyy/sipandu
- Repository: https://github.com/alipppyy/sipandu

## Overview

SIPANDU is a web system for RW administration, resident self-service, and public information. The main workflow is staff or residents using a portal to access administrative and community-service features, with API routes enforcing roles and operating on PostgreSQL through Prisma. Major branches cover resident/family records, dues and payments, activities, letters, announcements, and WhatsApp reminders. The README documents these capabilities; sampled route and library excerpts show API-to-storage, authorization, audit, and messaging behavior. UI-to-route wiring is not established by the available excerpts, so those links are omitted.

Main entry points: [`src/lib/prisma.ts`](https://github.com/alipppyy/sipandu/blob/master/src/lib/prisma.ts) (PostgreSQL via Prisma), [`src/lib/wa.ts`](https://github.com/alipppyy/sipandu/blob/master/src/lib/wa.ts) (WhatsApp service), [`src/app/api/bills/route.ts`](https://github.com/alipppyy/sipandu/blob/master/src/app/api/bills/route.ts) (Bills and dues), [`src/app/api/residents/route.ts`](https://github.com/alipppyy/sipandu/blob/master/src/app/api/residents/route.ts) (Resident records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portals["Portals"]
  node_public["Public portal<br/>[page.tsx]"]
  node_lookup["Bill lookup<br/>[bill-lookup.tsx]"]
  node_residentportal["Resident portal<br/>[page.tsx]"]
  node_dashboard["Staff dashboard<br/>[page.tsx]"]
end

subgraph group_operations["Administration"]
  node_residentdata["Resident records<br/>[route.ts]"]
  node_families["Family records<br/>[route.ts]"]
  node_territories["RT management<br/>[route.ts]"]
  node_users["User management<br/>[route.ts]"]
  node_statistics["Statistics<br/>[route.ts]"]
end

subgraph group_services["Community Services"]
  node_dues["Bills and dues<br/>[route.ts]"]
  node_payments["Payments<br/>[route.ts]"]
  node_receipts["Payment receipts<br/>[page.tsx]"]
  node_activities["Activities<br/>[route.ts]"]
  node_letters["Letters<br/>[route.ts]"]
  node_announcements["Announcements<br/>[route.ts]"]
  node_waapi["WhatsApp operations<br/>[route.ts]"]
end

subgraph group_runtime["Runtime Services"]
  node_auth["Auth and roles<br/>[auth.ts]"]
  node_apihelpers["API handling<br/>[api.ts]"]
  node_audit["Audit logging<br/>[audit.ts]"]
  node_scheduler["Reminder scheduler<br/>[scheduler.ts]"]
  node_whatsapp["WhatsApp service<br/>[wa.ts]"]
  node_database[("PostgreSQL via Prisma<br/>[prisma.ts]")]
end

node_staff(("Staff"))
node_residents(("Residents"))
node_whatsappgateway["WhatsApp gateway"]

node_staff -->|"manage services"| node_dashboard
node_residents -->|"view personal services"| node_residentportal
node_residents -->|"view public information"| node_public
node_public -->|"check bills"| node_lookup
node_residentdata -->|"checks access"| node_auth
node_residentdata -->|"wraps handlers"| node_apihelpers
node_residentdata -->|"records changes"| node_audit
node_residentdata -->|"reads and writes"| node_database
node_dues -->|"checks access"| node_auth
node_dues -->|"wraps handlers"| node_apihelpers
node_dues -->|"records changes"| node_audit
node_dues -->|"reads and writes"| node_database
node_activities -->|"checks access"| node_auth
node_activities -->|"wraps handlers"| node_apihelpers
node_activities -->|"records changes"| node_audit
node_activities -->|"reads and writes"| node_database
node_statistics -->|"gets message stats"| node_whatsapp
node_statistics -->|"queries metrics"| node_database
node_waapi -->|"sends messages"| node_whatsapp
node_waapi -->|"checks access"| node_auth
node_waapi -->|"uses stored data"| node_database
node_families -->|"reads and writes"| node_database
node_territories -->|"reads and writes"| node_database
node_users -->|"reads and writes"| node_database
node_payments -->|"reads and writes"| node_database
node_letters -->|"reads and writes"| node_database
node_announcements -->|"reads and writes"| node_database
node_scheduler -->|"uses messaging"| node_whatsapp
node_scheduler -->|"queries reminders"| node_database
node_whatsapp -->|"stores message state"| node_database
node_whatsapp -->|"delivers messages"| node_whatsappgateway
node_dues -->|"supports receipts"| node_receipts
node_whatsapp -.->|"supports gateway providers"| node_whatsappgateway

click node_public "https://github.com/alipppyy/sipandu/blob/master/src/app/page.tsx"
click node_lookup "https://github.com/alipppyy/sipandu/blob/master/src/components/public/bill-lookup.tsx"
click node_residentportal "https://github.com/alipppyy/sipandu/blob/master/src/app/(warga)/warga/page.tsx"
click node_dashboard "https://github.com/alipppyy/sipandu/blob/master/src/app/(app)/dashboard/page.tsx"
click node_residentdata "https://github.com/alipppyy/sipandu/blob/master/src/app/api/residents/route.ts"
click node_families "https://github.com/alipppyy/sipandu/blob/master/src/app/api/families/route.ts"
click node_territories "https://github.com/alipppyy/sipandu/blob/master/src/app/api/rt/route.ts"
click node_users "https://github.com/alipppyy/sipandu/blob/master/src/app/api/users/route.ts"
click node_statistics "https://github.com/alipppyy/sipandu/blob/master/src/app/api/stats/route.ts"
click node_dues "https://github.com/alipppyy/sipandu/blob/master/src/app/api/bills/route.ts"
click node_payments "https://github.com/alipppyy/sipandu/blob/master/src/app/api/payments/route.ts"
click node_receipts "https://github.com/alipppyy/sipandu/blob/master/src/app/kwitansi/%5Bid%5D/page.tsx"
click node_activities "https://github.com/alipppyy/sipandu/blob/master/src/app/api/activities/route.ts"
click node_letters "https://github.com/alipppyy/sipandu/blob/master/src/app/api/letters/route.ts"
click node_announcements "https://github.com/alipppyy/sipandu/blob/master/src/app/api/announcements/route.ts"
click node_waapi "https://github.com/alipppyy/sipandu/blob/master/src/app/api/wa/send/route.ts"
click node_auth "https://github.com/alipppyy/sipandu/blob/master/src/lib/auth.ts"
click node_apihelpers "https://github.com/alipppyy/sipandu/blob/master/src/lib/api.ts"
click node_audit "https://github.com/alipppyy/sipandu/blob/master/src/lib/audit.ts"
click node_scheduler "https://github.com/alipppyy/sipandu/blob/master/src/lib/scheduler.ts"
click node_whatsapp "https://github.com/alipppyy/sipandu/blob/master/src/lib/wa.ts"
click node_database "https://github.com/alipppyy/sipandu/blob/master/src/lib/prisma.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_public,node_lookup,node_residentportal,node_dashboard toneBlue
class node_residentdata,node_families,node_territories,node_users,node_statistics toneAmber
class node_dues,node_payments,node_receipts,node_activities,node_letters,node_announcements,node_waapi toneMint
class node_auth,node_apihelpers,node_audit,node_scheduler,node_whatsapp,node_database toneRose
class node_staff,node_residents,node_whatsappgateway toneIndigo
```

## Components

### Portals

- [Public portal](https://github.com/alipppyy/sipandu/blob/master/src/app/page.tsx): `src/app/page.tsx`
- [Bill lookup](https://github.com/alipppyy/sipandu/blob/master/src/components/public/bill-lookup.tsx): `src/components/public/bill-lookup.tsx`
- [Resident portal](https://github.com/alipppyy/sipandu/blob/master/src/app/(warga)/warga/page.tsx): `src/app/(warga)/warga/page.tsx`
- [Staff dashboard](https://github.com/alipppyy/sipandu/blob/master/src/app/(app)/dashboard/page.tsx): `src/app/(app)/dashboard/page.tsx`

### Administration

- [Resident records](https://github.com/alipppyy/sipandu/blob/master/src/app/api/residents/route.ts): `src/app/api/residents/route.ts`
- [Family records](https://github.com/alipppyy/sipandu/blob/master/src/app/api/families/route.ts): `src/app/api/families/route.ts`
- [RT management](https://github.com/alipppyy/sipandu/blob/master/src/app/api/rt/route.ts): `src/app/api/rt/route.ts`
- [User management](https://github.com/alipppyy/sipandu/blob/master/src/app/api/users/route.ts): `src/app/api/users/route.ts`
- [Statistics](https://github.com/alipppyy/sipandu/blob/master/src/app/api/stats/route.ts): `src/app/api/stats/route.ts`

### Community Services

- [Bills and dues](https://github.com/alipppyy/sipandu/blob/master/src/app/api/bills/route.ts): `src/app/api/bills/route.ts`
- [Payments](https://github.com/alipppyy/sipandu/blob/master/src/app/api/payments/route.ts): `src/app/api/payments/route.ts`
- [Payment receipts](https://github.com/alipppyy/sipandu/blob/master/src/app/kwitansi/%5Bid%5D/page.tsx): `src/app/kwitansi/[id]/page.tsx`
- [Activities](https://github.com/alipppyy/sipandu/blob/master/src/app/api/activities/route.ts): `src/app/api/activities/route.ts`
- [Letters](https://github.com/alipppyy/sipandu/blob/master/src/app/api/letters/route.ts): `src/app/api/letters/route.ts`
- [Announcements](https://github.com/alipppyy/sipandu/blob/master/src/app/api/announcements/route.ts): `src/app/api/announcements/route.ts`
- [WhatsApp operations](https://github.com/alipppyy/sipandu/blob/master/src/app/api/wa/send/route.ts): `src/app/api/wa/send/route.ts`

### Runtime Services

- [Auth and roles](https://github.com/alipppyy/sipandu/blob/master/src/lib/auth.ts): `src/lib/auth.ts`
- [API handling](https://github.com/alipppyy/sipandu/blob/master/src/lib/api.ts): `src/lib/api.ts`
- [Audit logging](https://github.com/alipppyy/sipandu/blob/master/src/lib/audit.ts): `src/lib/audit.ts`
- [Reminder scheduler](https://github.com/alipppyy/sipandu/blob/master/src/lib/scheduler.ts): `src/lib/scheduler.ts`
- [WhatsApp service](https://github.com/alipppyy/sipandu/blob/master/src/lib/wa.ts): `src/lib/wa.ts`
- [PostgreSQL via Prisma](https://github.com/alipppyy/sipandu/blob/master/src/lib/prisma.ts): `src/lib/prisma.ts`

### Other components

- **Staff**
- **Residents**
- **WhatsApp gateway**

## Connections

- Staff → Staff dashboard: manage services (evidence: `README.md`)
- Residents → Resident portal: view personal services (evidence: `README.md`)
- Residents → Public portal: view public information (evidence: `README.md`)
- Public portal → Bill lookup: check bills (evidence: `README.md`)
- Resident records → Auth and roles: checks access (evidence: `src/app/api/residents/route.ts`)
- Resident records → API handling: wraps handlers (evidence: `src/app/api/residents/route.ts`)
- Resident records → Audit logging: records changes (evidence: `src/app/api/residents/route.ts`)
- Resident records → PostgreSQL via Prisma: reads and writes (evidence: `src/app/api/residents/route.ts`)
- Bills and dues → Auth and roles: checks access (evidence: `src/app/api/bills/route.ts`)
- Bills and dues → API handling: wraps handlers (evidence: `src/app/api/bills/route.ts`)
- Bills and dues → Audit logging: records changes (evidence: `src/app/api/bills/route.ts`)
- Bills and dues → PostgreSQL via Prisma: reads and writes (evidence: `src/app/api/bills/route.ts`)
- Activities → Auth and roles: checks access (evidence: `src/app/api/activities/route.ts`)
- Activities → API handling: wraps handlers (evidence: `src/app/api/activities/route.ts`)
- Activities → Audit logging: records changes (evidence: `src/app/api/activities/route.ts`)
- Activities → PostgreSQL via Prisma: reads and writes (evidence: `src/app/api/activities/route.ts`)
- Statistics → WhatsApp service: gets message stats (evidence: `src/app/api/stats/route.ts`)
- Statistics → PostgreSQL via Prisma: queries metrics (evidence: `src/app/api/stats/route.ts`)
- WhatsApp operations → WhatsApp service: sends messages (evidence: `src/app/api/wa/send/route.ts`)
- WhatsApp operations → Auth and roles: checks access (evidence: `src/app/api/wa/send/route.ts`)
- WhatsApp operations → PostgreSQL via Prisma: uses stored data (evidence: `src/app/api/wa/send/route.ts`)
- Family records → PostgreSQL via Prisma: reads and writes (evidence: `src/app/api/families/route.ts`)
- RT management → PostgreSQL via Prisma: reads and writes (evidence: `src/app/api/rt/route.ts`)
- User management → PostgreSQL via Prisma: reads and writes (evidence: `src/app/api/users/route.ts`)
- Payments → PostgreSQL via Prisma: reads and writes (evidence: `src/app/api/payments/route.ts`)
- Letters → PostgreSQL via Prisma: reads and writes (evidence: `src/app/api/letters/route.ts`)
- Announcements → PostgreSQL via Prisma: reads and writes (evidence: `src/app/api/announcements/route.ts`)
- Reminder scheduler → WhatsApp service: uses messaging (evidence: `src/lib/scheduler.ts`)
- Reminder scheduler → PostgreSQL via Prisma: queries reminders (evidence: `src/lib/scheduler.ts`)
- WhatsApp service → PostgreSQL via Prisma: stores message state (evidence: `src/lib/wa.ts`)
- WhatsApp service → WhatsApp gateway: delivers messages (evidence: `README.md`)
- Bills and dues → Payment receipts: supports receipts (evidence: `README.md`)
- WhatsApp service → WhatsApp gateway: supports gateway providers (evidence: `README.md`)
