# tarafk1972-abcd/wjw architecture

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

- Interactive diagram: https://gitdiagram.com/tarafk1972-abcd/wjw
- Repository: https://github.com/tarafk1972-abcd/wjw

## Overview

Warga Jaga Warga is a mobile-first, multilingual community-safety PWA with a server API. Its documented primary workflow is a resident raising an emergency, the server routing it within the same community and recording its lifecycle, and an authorized responder updating the incident until resolution. The graph also preserves membership administration, community operations, and subscription capabilities. Some server subsystems are represented by their exact tree paths but were not sampled; their links are included only where the README or server entry-point references support them.

Main entry points: [`src/App.tsx`](https://github.com/tarafk1972-abcd/wjw/blob/main/src/App.tsx) (App routing), [`src/lib/api.ts`](https://github.com/tarafk1972-abcd/wjw/blob/main/src/lib/api.ts) (HTTP API client), [`server/index.ts`](https://github.com/tarafk1972-abcd/wjw/blob/main/server/index.ts) (API routes), [`src/lib/sync.ts`](https://github.com/tarafk1972-abcd/wjw/blob/main/src/lib/sync.ts) (State synchronization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Resident app"]
  node_app["App routing<br/>[App.tsx]"]
end

subgraph group_safety["Safety operations"]
  node_panic["Emergency reporting<br/>[Panic.tsx]"]
  node_profile["Emergency profile"]
  node_reports["Incident reports<br/>[Reports.tsx]"]
  node_patrol["Patrol and checkpoints<br/>[Patrol.tsx]"]
  node_guests["Visitor records<br/>[Guests.tsx]"]
  node_broadcast["Broadcast and safety checks<br/>[Broadcast.tsx]"]
  node_incidents["Incident handling<br/>[incidents.ts]"]
end

subgraph group_community["Community services"]
  node_community_ui["Community management<br/>[Community.tsx]"]
  node_admin["Membership administration<br/>[Admin.tsx]"]
  node_dues["Community dues<br/>[Dues.tsx]"]
  node_billing["Subscriptions and billing<br/>[Billing.tsx]"]
  node_assistant["AI assistance<br/>[Assistant.tsx]"]
  node_support["Support and console<br/>[Support.tsx]"]
  node_hub["Community hub<br/>[community-hub.ts]"]
  node_population["Member and population data<br/>[population.ts]"]
end

subgraph group_platform["API and state"]
  node_client_state["App state<br/>[store.tsx]"]
  node_client_db[("Local cache<br/>[db.ts]")]
  node_sync["State synchronization<br/>[sync.ts]"]
  node_api_client["HTTP API client<br/>[api.ts]"]
  node_server["API routes<br/>[index.ts]"]
  node_server_db[("Server database<br/>[db.ts]")]
  node_realtime["Realtime events<br/>[events.ts]"]
end

node_resident(("Resident"))

node_resident -->|"uses"| node_app
node_app -->|"routes to"| node_panic
node_app -->|"routes to"| node_profile
node_app -->|"routes to"| node_reports
node_app -->|"routes to"| node_patrol
node_app -->|"routes to"| node_guests
node_app -->|"routes to"| node_broadcast
node_app -->|"routes to"| node_admin
node_app -->|"routes to"| node_community_ui
node_app -->|"routes to"| node_dues
node_app -->|"routes to"| node_billing
node_app -->|"routes to"| node_assistant
node_app -->|"routes to"| node_support
node_panic -->|"submits alert"| node_api_client
node_api_client -->|"requests"| node_server
node_server -->|"dispatches incidents"| node_incidents
node_server -->|"dispatches hub routes"| node_hub
node_server -->|"dispatches population routes"| node_population
node_incidents -.->|"persists incident"| node_server_db
node_server -->|"signals updates"| node_realtime
node_server -->|"uses database"| node_server_db
node_client_state -->|"synchronizes state"| node_sync
node_sync -->|"fetches state"| node_api_client
node_sync -->|"starts realtime"| node_realtime
node_sync -->|"refreshes cache"| node_client_db
node_reports -->|"uses API"| node_api_client
node_admin -->|"uses API"| node_api_client
node_dues -->|"uses API"| node_api_client
node_billing -->|"uses API"| node_api_client
node_community_ui -->|"uses API"| node_api_client
node_assistant -.->|"uses API"| node_api_client
node_support -.->|"uses API"| node_api_client
node_reports -->|"shows incident status"| node_resident

click node_app "https://github.com/tarafk1972-abcd/wjw/blob/main/src/App.tsx"
click node_panic "https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Panic.tsx"
click node_profile "https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/EmergencyProfile.tsx"
click node_reports "https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Reports.tsx"
click node_patrol "https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Patrol.tsx"
click node_guests "https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Guests.tsx"
click node_broadcast "https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Broadcast.tsx"
click node_community_ui "https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Community.tsx"
click node_admin "https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Admin.tsx"
click node_dues "https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Dues.tsx"
click node_billing "https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Billing.tsx"
click node_assistant "https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Assistant.tsx"
click node_support "https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Support.tsx"
click node_client_state "https://github.com/tarafk1972-abcd/wjw/blob/main/src/lib/store.tsx"
click node_client_db "https://github.com/tarafk1972-abcd/wjw/blob/main/src/lib/db.ts"
click node_sync "https://github.com/tarafk1972-abcd/wjw/blob/main/src/lib/sync.ts"
click node_api_client "https://github.com/tarafk1972-abcd/wjw/blob/main/src/lib/api.ts"
click node_server "https://github.com/tarafk1972-abcd/wjw/blob/main/server/index.ts"
click node_incidents "https://github.com/tarafk1972-abcd/wjw/blob/main/server/incidents.ts"
click node_hub "https://github.com/tarafk1972-abcd/wjw/blob/main/server/community-hub.ts"
click node_population "https://github.com/tarafk1972-abcd/wjw/blob/main/server/population.ts"
click node_server_db "https://github.com/tarafk1972-abcd/wjw/blob/main/server/db.ts"
click node_realtime "https://github.com/tarafk1972-abcd/wjw/blob/main/server/events.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_app toneBlue
class node_panic,node_profile,node_reports,node_patrol,node_guests,node_broadcast,node_incidents toneAmber
class node_community_ui,node_admin,node_dues,node_billing,node_assistant,node_support,node_hub,node_population toneMint
class node_client_state,node_client_db,node_sync,node_api_client,node_server,node_server_db,node_realtime toneRose
class node_resident toneIndigo
```

## Components

### Resident app

- [App routing](https://github.com/tarafk1972-abcd/wjw/blob/main/src/App.tsx): `src/App.tsx`

### Safety operations

- [Emergency reporting](https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Panic.tsx): `src/pages/Panic.tsx`
- [Emergency profile](https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/EmergencyProfile.tsx): `src/pages/EmergencyProfile.tsx`
- [Incident reports](https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Reports.tsx): `src/pages/Reports.tsx`
- [Patrol and checkpoints](https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Patrol.tsx): `src/pages/Patrol.tsx`
- [Visitor records](https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Guests.tsx): `src/pages/Guests.tsx`
- [Broadcast and safety checks](https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Broadcast.tsx): `src/pages/Broadcast.tsx`
- [Incident handling](https://github.com/tarafk1972-abcd/wjw/blob/main/server/incidents.ts): `server/incidents.ts`

### Community services

- [Community management](https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Community.tsx): `src/pages/Community.tsx`
- [Membership administration](https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Admin.tsx): `src/pages/Admin.tsx`
- [Community dues](https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Dues.tsx): `src/pages/Dues.tsx`
- [Subscriptions and billing](https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Billing.tsx): `src/pages/Billing.tsx`
- [AI assistance](https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Assistant.tsx): `src/pages/Assistant.tsx`
- [Support and console](https://github.com/tarafk1972-abcd/wjw/blob/main/src/pages/Support.tsx): `src/pages/Support.tsx`
- [Community hub](https://github.com/tarafk1972-abcd/wjw/blob/main/server/community-hub.ts): `server/community-hub.ts`
- [Member and population data](https://github.com/tarafk1972-abcd/wjw/blob/main/server/population.ts): `server/population.ts`

### API and state

- [App state](https://github.com/tarafk1972-abcd/wjw/blob/main/src/lib/store.tsx): `src/lib/store.tsx`
- [Local cache](https://github.com/tarafk1972-abcd/wjw/blob/main/src/lib/db.ts): `src/lib/db.ts`
- [State synchronization](https://github.com/tarafk1972-abcd/wjw/blob/main/src/lib/sync.ts): `src/lib/sync.ts`
- [HTTP API client](https://github.com/tarafk1972-abcd/wjw/blob/main/src/lib/api.ts): `src/lib/api.ts`
- [API routes](https://github.com/tarafk1972-abcd/wjw/blob/main/server/index.ts): `server/index.ts`
- [Server database](https://github.com/tarafk1972-abcd/wjw/blob/main/server/db.ts): `server/db.ts`
- [Realtime events](https://github.com/tarafk1972-abcd/wjw/blob/main/server/events.ts): `server/events.ts`

### Other components

- **Resident**

## Connections

- Resident → App routing: uses
- App routing → Emergency reporting: routes to (evidence: `src/App.tsx`)
- App routing → Emergency profile: routes to (evidence: `src/App.tsx`)
- App routing → Incident reports: routes to (evidence: `src/App.tsx`)
- App routing → Patrol and checkpoints: routes to (evidence: `src/App.tsx`)
- App routing → Visitor records: routes to (evidence: `src/App.tsx`)
- App routing → Broadcast and safety checks: routes to (evidence: `src/App.tsx`)
- App routing → Membership administration: routes to (evidence: `src/App.tsx`)
- App routing → Community management: routes to (evidence: `src/App.tsx`)
- App routing → Community dues: routes to (evidence: `src/App.tsx`)
- App routing → Subscriptions and billing: routes to (evidence: `src/App.tsx`)
- App routing → AI assistance: routes to (evidence: `src/App.tsx`)
- App routing → Support and console: routes to (evidence: `src/App.tsx`)
- Emergency reporting → HTTP API client: submits alert
- HTTP API client → API routes: requests (evidence: `src/lib/api.ts`)
- API routes → Incident handling: dispatches incidents (evidence: `server/index.ts`)
- API routes → Community hub: dispatches hub routes (evidence: `server/index.ts`)
- API routes → Member and population data: dispatches population routes (evidence: `server/index.ts`)
- Incident handling → Server database: persists incident
- API routes → Realtime events: signals updates (evidence: `server/index.ts`)
- API routes → Server database: uses database (evidence: `server/index.ts`)
- App state → State synchronization: synchronizes state (evidence: `src/lib/store.tsx`)
- State synchronization → HTTP API client: fetches state (evidence: `src/lib/sync.ts`)
- State synchronization → Realtime events: starts realtime (evidence: `src/lib/sync.ts`)
- State synchronization → Local cache: refreshes cache (evidence: `src/lib/sync.ts`)
- Incident reports → HTTP API client: uses API (evidence: `src/pages/Reports.tsx`)
- Membership administration → HTTP API client: uses API (evidence: `src/pages/Admin.tsx`)
- Community dues → HTTP API client: uses API (evidence: `src/pages/Dues.tsx`)
- Subscriptions and billing → HTTP API client: uses API (evidence: `src/lib/api.ts`)
- Community management → HTTP API client: uses API (evidence: `src/pages/Community.tsx`)
- AI assistance → HTTP API client: uses API
- Support and console → HTTP API client: uses API
- Incident reports → Resident: shows incident status
