# johanprise/restok-app architecture

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

- Interactive diagram: https://gitdiagram.com/johanprise/restok-app
- Repository: https://github.com/johanprise/restok-app

## Overview

Restock is a shared household inventory app. A member uses the mobile shelf, shopping list, or recipe screens; persisted/offline queries call the authenticated NestJS API, which applies group permissions and updates inventory state in PostgreSQL. Missing stock feeds shopping, while recipes are searchable from Wikibooks and ranked client-side against cached items. Item actions dispatch events to the shared journal and notifications. The tree and README document these integrations; several service internals were not sampled, so those links remain intentionally broad.

Main entry points: [`mobile/src/api/query-client.ts`](https://github.com/johanprise/restok-app/blob/main/mobile/src/api/query-client.ts) (Query cache), [`mobile/app`](https://github.com/johanprise/restok-app/tree/main/mobile/app) (Mobile screens), [`backend/src/items/items.controller.ts`](https://github.com/johanprise/restok-app/blob/main/backend/src/items/items.controller.ts) (Inventory actions), [`backend/src/auth/auth.service.ts`](https://github.com/johanprise/restok-app/blob/main/backend/src/auth/auth.service.ts) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile app"]
  node_mobile_ui["Mobile screens"]
  node_query_cache["Query cache<br/>[query-client.ts]"]
  node_client_logic["Client logic"]
  node_localization["Localization"]
end

subgraph group_identity["Identity and groups"]
  node_auth["Authentication<br/>[auth.service.ts]"]
  node_groups_members["Groups and members"]
end

subgraph group_inventory["Inventory and shopping"]
  node_inventory_api["Inventory actions"]
  node_shopping_api["Shopping list"]
end

subgraph group_recipes_audit["Recipes and audit"]
  node_recipes_api["Recipe service"]
  node_event_bus["Domain events<br/>[app.module.ts]"]
  node_history_api["Action journal"]
end

subgraph group_delivery["Notifications and mail"]
  node_notifications["Push notifications"]
  node_mail["Mail delivery<br/>[mail.module.ts]"]
end

node_member(("Member"))
node_postgres[("PostgreSQL")]
node_wikibooks["Wikibooks catalogue"]
node_expo_push["Expo push API"]

node_member -->|"uses"| node_mobile_ui
node_mobile_ui -->|"reads and writes"| node_query_cache
node_mobile_ui -->|"renders text"| node_localization
node_query_cache -->|"HTTPS requests"| node_auth
node_query_cache -->|"HTTPS requests"| node_groups_members
node_query_cache -->|"HTTPS requests"| node_inventory_api
node_query_cache -->|"HTTPS requests"| node_shopping_api
node_query_cache -->|"HTTPS requests"| node_recipes_api
node_query_cache -->|"HTTPS requests"| node_history_api
node_query_cache -->|"provides cache"| node_client_logic
node_client_logic -->|"returns feasibility"| node_mobile_ui
node_auth -->|"reads and writes"| node_postgres
node_groups_members -->|"reads and writes"| node_postgres
node_inventory_api -->|"reads and writes"| node_postgres
node_shopping_api -->|"reads and writes"| node_postgres
node_recipes_api -->|"reads and writes"| node_postgres
node_shopping_api -->|"reads stock"| node_inventory_api
node_recipes_api -.->|"searches catalogue"| node_wikibooks
node_inventory_api -->|"dispatches events"| node_event_bus
node_event_bus -->|"records actions"| node_history_api
node_event_bus -->|"dispatches alerts"| node_notifications
node_notifications -.->|"sends pushes"| node_expo_push
node_auth -.->|"sends reset code"| node_mail

click node_mobile_ui "https://github.com/johanprise/restok-app/tree/main/mobile/app"
click node_query_cache "https://github.com/johanprise/restok-app/blob/main/mobile/src/api/query-client.ts"
click node_client_logic "https://github.com/johanprise/restok-app/tree/main/mobile/src/lib"
click node_localization "https://github.com/johanprise/restok-app/tree/main/mobile/src/i18n"
click node_auth "https://github.com/johanprise/restok-app/blob/main/backend/src/auth/auth.service.ts"
click node_groups_members "https://github.com/johanprise/restok-app/blob/main/backend/src/groups/groups.controller.ts"
click node_inventory_api "https://github.com/johanprise/restok-app/blob/main/backend/src/items/items.controller.ts"
click node_shopping_api "https://github.com/johanprise/restok-app/blob/main/backend/src/shopping/shopping.controller.ts"
click node_recipes_api "https://github.com/johanprise/restok-app/blob/main/backend/src/recipes/recipes.controller.ts"
click node_event_bus "https://github.com/johanprise/restok-app/blob/main/backend/src/app.module.ts"
click node_history_api "https://github.com/johanprise/restok-app/blob/main/backend/src/action-history/action-history.controller.ts"
click node_notifications "https://github.com/johanprise/restok-app/blob/main/backend/src/notifications/notifications.module.ts"
click node_mail "https://github.com/johanprise/restok-app/blob/main/backend/src/mail/mail.module.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_mobile_ui,node_query_cache,node_client_logic,node_localization toneBlue
class node_auth,node_groups_members,node_postgres toneAmber
class node_inventory_api,node_shopping_api,node_expo_push toneMint
class node_recipes_api,node_event_bus,node_history_api toneRose
class node_notifications,node_mail,node_member,node_wikibooks toneIndigo
```

## Components

### Mobile app

- [Mobile screens](https://github.com/johanprise/restok-app/tree/main/mobile/app): `mobile/app`
- [Query cache](https://github.com/johanprise/restok-app/blob/main/mobile/src/api/query-client.ts): `mobile/src/api/query-client.ts`
- [Client logic](https://github.com/johanprise/restok-app/tree/main/mobile/src/lib): `mobile/src/lib`
- [Localization](https://github.com/johanprise/restok-app/tree/main/mobile/src/i18n): `mobile/src/i18n`

### Identity and groups

- [Authentication](https://github.com/johanprise/restok-app/blob/main/backend/src/auth/auth.service.ts): `backend/src/auth/auth.service.ts`
- [Groups and members](https://github.com/johanprise/restok-app/blob/main/backend/src/groups/groups.controller.ts): `backend/src/groups/groups.controller.ts`

### Inventory and shopping

- [Inventory actions](https://github.com/johanprise/restok-app/blob/main/backend/src/items/items.controller.ts): `backend/src/items/items.controller.ts`
- [Shopping list](https://github.com/johanprise/restok-app/blob/main/backend/src/shopping/shopping.controller.ts): `backend/src/shopping/shopping.controller.ts`

### Recipes and audit

- [Recipe service](https://github.com/johanprise/restok-app/blob/main/backend/src/recipes/recipes.controller.ts): `backend/src/recipes/recipes.controller.ts`
- [Domain events](https://github.com/johanprise/restok-app/blob/main/backend/src/app.module.ts): `backend/src/app.module.ts`
- [Action journal](https://github.com/johanprise/restok-app/blob/main/backend/src/action-history/action-history.controller.ts): `backend/src/action-history/action-history.controller.ts`

### Notifications and mail

- [Push notifications](https://github.com/johanprise/restok-app/blob/main/backend/src/notifications/notifications.module.ts): `backend/src/notifications/notifications.module.ts`
- [Mail delivery](https://github.com/johanprise/restok-app/blob/main/backend/src/mail/mail.module.ts): `backend/src/mail/mail.module.ts`

### Other components

- **Member**
- **PostgreSQL**
- **Wikibooks catalogue**
- **Expo push API**

## Connections

- Member → Mobile screens: uses
- Mobile screens → Query cache: reads and writes
- Mobile screens → Localization: renders text
- Query cache → Authentication: HTTPS requests
- Query cache → Groups and members: HTTPS requests
- Query cache → Inventory actions: HTTPS requests
- Query cache → Shopping list: HTTPS requests
- Query cache → Recipe service: HTTPS requests
- Query cache → Action journal: HTTPS requests
- Query cache → Client logic: provides cache
- Client logic → Mobile screens: returns feasibility
- Authentication → PostgreSQL: reads and writes
- Groups and members → PostgreSQL: reads and writes
- Inventory actions → PostgreSQL: reads and writes
- Shopping list → PostgreSQL: reads and writes
- Recipe service → PostgreSQL: reads and writes
- Shopping list → Inventory actions: reads stock
- Recipe service → Wikibooks catalogue: searches catalogue
- Inventory actions → Domain events: dispatches events
- Domain events → Action journal: records actions
- Domain events → Push notifications: dispatches alerts
- Push notifications → Expo push API: sends pushes
- Authentication → Mail delivery: sends reset code
