# whansel007/pawtner architecture

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

- Interactive diagram: https://gitdiagram.com/whansel007/pawtner
- Repository: https://github.com/whansel007/pawtner

## Overview

Pawtner is a phone-first medication-adherence companion: seniors record doses, blood pressure and walks, while a caretaker can review activity and escalation settings. The mobile app and caretaker pages use the API for documented live workflows; API handlers delegate to a PostgreSQL repository, which applies deterministic shared rules and assembles results. The graph also retains the prototype’s medication, proof, reminder and companion-dog experiences. Some screen-to-API details and repository internals are unsampled, so those links rely on README statements rather than inferred call chains.

Main entry points: [`mobile/src/App.tsx`](https://github.com/whansel007/pawtner/blob/main/mobile/src/App.tsx) (Phone app), [`api/repository.ts`](https://github.com/whansel007/pawtner/blob/main/api/repository.ts) (Domain repository), [`mobile/src/lib/api.ts`](https://github.com/whansel007/pawtner/blob/main/mobile/src/lib/api.ts) (API client), [`mobile/src/care/CareApp.tsx`](https://github.com/whansel007/pawtner/blob/main/mobile/src/care/CareApp.tsx) (Caretaker app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Senior companion"]
  node_phone["Phone app<br/>[App.tsx]"]
  node_screens["Care routines"]
  node_medication["Medication setup"]
  node_proof["Dose proof<br/>[ProofScreen.tsx]"]
  node_dog["Dog companion<br/>[scene.ts]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_care["Caretaker view"]
  node_careapp["Caretaker app<br/>[CareApp.tsx]"]
  node_caredata["Caretaker data<br/>[useCareData.ts]"]
end

subgraph group_api["API and persistence"]
  node_api_entry["API routes<br/>[&#91;...path&#93;.ts]"]
  node_handlers["Request handlers<br/>[handlers.ts]"]
  node_repository["Domain repository<br/>[repository.ts]"]
  node_postgres[("PostgreSQL")]
end

subgraph group_decision["Shared decisions"]
  node_selectors["Input selectors<br/>[selectors.ts]"]
  node_rules["Decision rules<br/>[rules.ts]"]
  node_wording["Safe wording<br/>[wording.ts]"]
  node_templates["Decision templates<br/>[templates.ts]"]
end

node_senior(("Senior"))
node_caretaker(("Caretaker"))

node_senior -->|"uses"| node_phone
node_phone -->|"renders"| node_screens
node_phone -->|"renders"| node_medication
node_phone -->|"renders"| node_proof
node_phone -->|"configures"| node_dog
node_phone -->|"requests data"| node_api_client
node_caretaker -->|"uses"| node_careapp
node_careapp -->|"loads"| node_caredata
node_caredata -->|"requests data"| node_api_client
node_api_client -->|"calls"| node_api_entry
node_api_entry -->|"dispatches"| node_handlers
node_handlers -->|"delegates"| node_repository
node_repository -->|"reads and writes"| node_postgres
node_repository -->|"builds inputs"| node_selectors
node_repository -->|"evaluates"| node_rules
node_repository -->|"applies wording"| node_wording
node_rules -->|"uses"| node_templates

click node_phone "https://github.com/whansel007/pawtner/blob/main/mobile/src/App.tsx"
click node_screens "https://github.com/whansel007/pawtner/tree/main/mobile/src/screens"
click node_medication "https://github.com/whansel007/pawtner/blob/main/mobile/src/screens/PrescriptionScreen.tsx"
click node_proof "https://github.com/whansel007/pawtner/blob/main/mobile/src/screens/ProofScreen.tsx"
click node_dog "https://github.com/whansel007/pawtner/blob/main/mobile/src/config/scene.ts"
click node_careapp "https://github.com/whansel007/pawtner/blob/main/mobile/src/care/CareApp.tsx"
click node_caredata "https://github.com/whansel007/pawtner/blob/main/mobile/src/care/hooks/useCareData.ts"
click node_api_client "https://github.com/whansel007/pawtner/blob/main/mobile/src/lib/api.ts"
click node_api_entry "https://github.com/whansel007/pawtner/blob/main/api/%5B...path%5D.ts"
click node_handlers "https://github.com/whansel007/pawtner/blob/main/api/handlers.ts"
click node_repository "https://github.com/whansel007/pawtner/blob/main/api/repository.ts"
click node_selectors "https://github.com/whansel007/pawtner/blob/main/shared/selectors.ts"
click node_rules "https://github.com/whansel007/pawtner/blob/main/shared/rules.ts"
click node_wording "https://github.com/whansel007/pawtner/blob/main/shared/wording.ts"
click node_templates "https://github.com/whansel007/pawtner/blob/main/shared/templates.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_phone,node_screens,node_medication,node_proof,node_dog,node_api_client toneBlue
class node_careapp,node_caredata toneAmber
class node_api_entry,node_handlers,node_repository,node_postgres toneMint
class node_selectors,node_rules,node_wording,node_templates toneRose
class node_senior,node_caretaker toneIndigo
```

## Components

### Senior companion

- [Phone app](https://github.com/whansel007/pawtner/blob/main/mobile/src/App.tsx): `mobile/src/App.tsx`
- [Care routines](https://github.com/whansel007/pawtner/tree/main/mobile/src/screens): `mobile/src/screens`
- [Medication setup](https://github.com/whansel007/pawtner/blob/main/mobile/src/screens/PrescriptionScreen.tsx): `mobile/src/screens/PrescriptionScreen.tsx`
- [Dose proof](https://github.com/whansel007/pawtner/blob/main/mobile/src/screens/ProofScreen.tsx): `mobile/src/screens/ProofScreen.tsx`
- [Dog companion](https://github.com/whansel007/pawtner/blob/main/mobile/src/config/scene.ts): `mobile/src/config/scene.ts`
- [API client](https://github.com/whansel007/pawtner/blob/main/mobile/src/lib/api.ts): `mobile/src/lib/api.ts`

### Caretaker view

- [Caretaker app](https://github.com/whansel007/pawtner/blob/main/mobile/src/care/CareApp.tsx): `mobile/src/care/CareApp.tsx`
- [Caretaker data](https://github.com/whansel007/pawtner/blob/main/mobile/src/care/hooks/useCareData.ts): `mobile/src/care/hooks/useCareData.ts`

### API and persistence

- [API routes](https://github.com/whansel007/pawtner/blob/main/api/%5B...path%5D.ts): `api/[...path].ts`
- [Request handlers](https://github.com/whansel007/pawtner/blob/main/api/handlers.ts): `api/handlers.ts`
- [Domain repository](https://github.com/whansel007/pawtner/blob/main/api/repository.ts): `api/repository.ts`
- **PostgreSQL**

### Shared decisions

- [Input selectors](https://github.com/whansel007/pawtner/blob/main/shared/selectors.ts): `shared/selectors.ts`
- [Decision rules](https://github.com/whansel007/pawtner/blob/main/shared/rules.ts): `shared/rules.ts`
- [Safe wording](https://github.com/whansel007/pawtner/blob/main/shared/wording.ts): `shared/wording.ts`
- [Decision templates](https://github.com/whansel007/pawtner/blob/main/shared/templates.ts): `shared/templates.ts`

### Other components

- **Senior**
- **Caretaker**

## Connections

- Senior → Phone app: uses (evidence: `README.md`)
- Phone app → Care routines: renders (evidence: `mobile/src/App.tsx`)
- Phone app → Medication setup: renders (evidence: `mobile/src/App.tsx`)
- Phone app → Dose proof: renders (evidence: `mobile/src/App.tsx`)
- Phone app → Dog companion: configures (evidence: `mobile/src/config/scene.ts`)
- Phone app → API client: requests data (evidence: `README.md`)
- Caretaker → Caretaker app: uses (evidence: `README.md`)
- Caretaker app → Caretaker data: loads (evidence: `mobile/src/care/CareApp.tsx`)
- Caretaker data → API client: requests data (evidence: `mobile/src/care/hooks/useCareData.ts`)
- API client → API routes: calls (evidence: `README.md`)
- API routes → Request handlers: dispatches (evidence: `api/[...path].ts`)
- Request handlers → Domain repository: delegates (evidence: `api/handlers.ts`)
- Domain repository → PostgreSQL: reads and writes (evidence: `api/repository.ts`)
- Domain repository → Input selectors: builds inputs (evidence: `api/repository.ts`)
- Domain repository → Decision rules: evaluates (evidence: `api/repository.ts`)
- Domain repository → Safe wording: applies wording (evidence: `api/repository.ts`)
- Decision rules → Decision templates: uses (evidence: `shared/rules.ts`)
