# gfani/friends_menu architecture

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

- Interactive diagram: https://gitdiagram.com/gfani/friends_menu
- Repository: https://github.com/gfani/friends_menu

## Overview

Mereba Friends Garden is a QR-accessible restaurant menu and manager portal. Guests open the mobile menu, browse food and drinks in three languages, and see restaurant information; managers authenticate to update dishes, availability, categories, settings, and review analytics. The backend exposes these capabilities through Fastify routes and persists application data through Prisma, with uploaded media stored locally. The README documents QR/PWA and several portal features whose implementation files are not present in the supplied tree; those are represented at subsystem level, with uncertain implementation links omitted.

Main entry points: [`friends-restaurant/frontend/src/pages/AdminDashboard.tsx`](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/pages/AdminDashboard.tsx) (Admin dashboard), [`friends-restaurant/backend/src/app.ts`](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/app.ts) (Fastify server), [`friends-restaurant/frontend/src/App.tsx`](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/App.tsx) (Web application), [`friends-restaurant/frontend/src/hooks/useMenu.ts`](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/hooks/useMenu.ts) (Menu data hooks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_guest["Guest Menu"]
  node_frontend["Web application<br/>[App.tsx]"]
  node_customer["Customer menu<br/>[CustomerMenu.tsx]"]
  node_menuquery["Menu data hooks<br/>[useMenu.ts]"]
  node_translations["Language translations<br/>[translations.ts]"]
  node_serviceworker["Offline PWA cache<br/>[sw.js]"]
end

subgraph group_management["Manager Portal"]
  node_login["Admin login<br/>[AdminLogin.tsx]"]
  node_authcontext["Session authentication<br/>[AuthContext.tsx]"]
  node_dashboard["Admin dashboard<br/>[AdminDashboard.tsx]"]
  node_categorymanager["Category management"]
  node_itemmanager["Dish management<br/>[ItemListTable.tsx]"]
  node_settingsui["Site settings CMS"]
  node_analyticsui["Menu analytics"]
  node_qrguide["QR and manager guide<br/>[TableQRModal.tsx]"]
end

subgraph group_api["API Services"]
  node_apiclient["REST API client<br/>[client.ts]"]
  node_server["Fastify server<br/>[app.ts]"]
  node_menuroutes["Menu routes<br/>[menu.routes.ts]"]
  node_authroutes["Authentication routes<br/>[auth.routes.ts]"]
  node_settingsroutes["Settings routes<br/>[settings.routes.ts]"]
  node_analyticsroutes["Analytics routes"]
  node_syncroutes["Sync routes<br/>[sync.routes.ts]"]
  node_menucontroller["Menu controller<br/>[menu.controller.ts]"]
  node_authcontroller["Auth controller<br/>[auth.controller.ts]"]
  node_settingscontroller["Settings controller"]
  node_analyticscontroller["Analytics controller"]
  node_synccontroller["Sync controller<br/>[sync.controller.ts]"]
end

subgraph group_persistence["Data and Media"]
  node_menuservice["Menu service<br/>[menu.service.ts]"]
  node_database[("Prisma database<br/>[database.ts]")]
  node_storage[("Media storage<br/>[storage.service.ts]")]
end

node_guest(("Restaurant guest"))
node_manager(("Restaurant manager"))

node_guest -->|"opens menu"| node_frontend
node_frontend -->|"routes to"| node_customer
node_customer -->|"loads menu"| node_menuquery
node_customer -->|"displays language"| node_translations
node_serviceworker -.->|"caches offline"| node_customer
node_manager -->|"opens portal"| node_frontend
node_frontend -->|"routes to"| node_login
node_frontend -->|"protects route"| node_dashboard
node_login -->|"authenticates through"| node_authcontext
node_dashboard -->|"uses session"| node_authcontext
node_dashboard -->|"renders"| node_categorymanager
node_dashboard -->|"renders"| node_itemmanager
node_dashboard -->|"renders"| node_settingsui
node_dashboard -->|"renders"| node_analyticsui
node_dashboard -.->|"offers tools"| node_qrguide
node_menuquery -->|"requests data"| node_apiclient
node_authcontext -->|"calls auth API"| node_apiclient
node_categorymanager -.->|"mutates categories"| node_menuquery
node_itemmanager -.->|"manages dishes"| node_menuquery
node_settingsui -.->|"updates settings"| node_menuquery
node_analyticsui -.->|"loads analytics"| node_apiclient
node_apiclient -->|"calls REST API"| node_server
node_server -->|"registers"| node_menuroutes
node_server -->|"registers"| node_authroutes
node_server -->|"registers"| node_settingsroutes
node_server -->|"registers"| node_analyticsroutes
node_server -->|"registers"| node_syncroutes
node_menuroutes -->|"routes requests"| node_menucontroller
node_authroutes -->|"routes requests"| node_authcontroller
node_settingsroutes -->|"routes requests"| node_settingscontroller
node_analyticsroutes -->|"routes requests"| node_analyticscontroller
node_syncroutes -->|"routes requests"| node_synccontroller
node_menucontroller -->|"delegates menu"| node_menuservice
node_menucontroller -->|"handles uploads"| node_storage
node_menuservice -->|"queries records"| node_database
node_authcontroller -->|"uses database"| node_database
node_settingscontroller -->|"uses database"| node_database
node_synccontroller -->|"uses database"| node_database
node_analyticscontroller -.->|"records analytics"| node_database

click node_frontend "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/App.tsx"
click node_customer "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/pages/CustomerMenu.tsx"
click node_menuquery "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/hooks/useMenu.ts"
click node_translations "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/i18n/translations.ts"
click node_serviceworker "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/public/sw.js"
click node_login "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/pages/AdminLogin.tsx"
click node_authcontext "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/context/AuthContext.tsx"
click node_dashboard "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/pages/AdminDashboard.tsx"
click node_categorymanager "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/components/admin/CategoryManager.tsx"
click node_itemmanager "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/components/admin/ItemListTable.tsx"
click node_settingsui "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/components/admin/SiteSettingsCMS.tsx"
click node_analyticsui "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/components/admin/AnalyticsDashboard.tsx"
click node_qrguide "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/components/admin/TableQRModal.tsx"
click node_apiclient "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/api/client.ts"
click node_server "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/app.ts"
click node_menuroutes "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/routes/menu.routes.ts"
click node_authroutes "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/routes/auth.routes.ts"
click node_settingsroutes "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/routes/settings.routes.ts"
click node_analyticsroutes "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/routes/analytics.routes.ts"
click node_syncroutes "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/routes/sync.routes.ts"
click node_menucontroller "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/controllers/menu.controller.ts"
click node_authcontroller "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/controllers/auth.controller.ts"
click node_settingscontroller "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/controllers/settings.controller.ts"
click node_analyticscontroller "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/controllers/analytics.controller.ts"
click node_synccontroller "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/controllers/sync.controller.ts"
click node_menuservice "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/services/menu.service.ts"
click node_database "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/config/database.ts"
click node_storage "https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/services/storage.service.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_frontend,node_customer,node_menuquery,node_translations,node_serviceworker toneBlue
class node_login,node_authcontext,node_dashboard,node_categorymanager,node_itemmanager,node_settingsui,node_analyticsui,node_qrguide toneAmber
class node_apiclient,node_server,node_menuroutes,node_authroutes,node_settingsroutes,node_analyticsroutes,node_syncroutes,node_menucontroller,node_authcontroller,node_settingscontroller,node_analyticscontroller,node_synccontroller toneMint
class node_menuservice,node_database,node_storage toneRose
class node_guest,node_manager toneIndigo
```

## Components

### Guest Menu

- [Web application](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/App.tsx): `friends-restaurant/frontend/src/App.tsx`
- [Customer menu](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/pages/CustomerMenu.tsx): `friends-restaurant/frontend/src/pages/CustomerMenu.tsx`
- [Menu data hooks](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/hooks/useMenu.ts): `friends-restaurant/frontend/src/hooks/useMenu.ts`
- [Language translations](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/i18n/translations.ts): `friends-restaurant/frontend/src/i18n/translations.ts`
- [Offline PWA cache](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/public/sw.js): `friends-restaurant/frontend/public/sw.js`

### Manager Portal

- [Admin login](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/pages/AdminLogin.tsx): `friends-restaurant/frontend/src/pages/AdminLogin.tsx`
- [Session authentication](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/context/AuthContext.tsx): `friends-restaurant/frontend/src/context/AuthContext.tsx`
- [Admin dashboard](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/pages/AdminDashboard.tsx): `friends-restaurant/frontend/src/pages/AdminDashboard.tsx`
- [Category management](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/components/admin/CategoryManager.tsx): `friends-restaurant/frontend/src/components/admin/CategoryManager.tsx`
- [Dish management](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/components/admin/ItemListTable.tsx): `friends-restaurant/frontend/src/components/admin/ItemListTable.tsx`
- [Site settings CMS](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/components/admin/SiteSettingsCMS.tsx): `friends-restaurant/frontend/src/components/admin/SiteSettingsCMS.tsx`
- [Menu analytics](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/components/admin/AnalyticsDashboard.tsx): `friends-restaurant/frontend/src/components/admin/AnalyticsDashboard.tsx`
- [QR and manager guide](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/components/admin/TableQRModal.tsx): `friends-restaurant/frontend/src/components/admin/TableQRModal.tsx`

### API Services

- [REST API client](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/frontend/src/api/client.ts): `friends-restaurant/frontend/src/api/client.ts`
- [Fastify server](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/app.ts): `friends-restaurant/backend/src/app.ts`
- [Menu routes](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/routes/menu.routes.ts): `friends-restaurant/backend/src/routes/menu.routes.ts`
- [Authentication routes](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/routes/auth.routes.ts): `friends-restaurant/backend/src/routes/auth.routes.ts`
- [Settings routes](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/routes/settings.routes.ts): `friends-restaurant/backend/src/routes/settings.routes.ts`
- [Analytics routes](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/routes/analytics.routes.ts): `friends-restaurant/backend/src/routes/analytics.routes.ts`
- [Sync routes](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/routes/sync.routes.ts): `friends-restaurant/backend/src/routes/sync.routes.ts`
- [Menu controller](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/controllers/menu.controller.ts): `friends-restaurant/backend/src/controllers/menu.controller.ts`
- [Auth controller](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/controllers/auth.controller.ts): `friends-restaurant/backend/src/controllers/auth.controller.ts`
- [Settings controller](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/controllers/settings.controller.ts): `friends-restaurant/backend/src/controllers/settings.controller.ts`
- [Analytics controller](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/controllers/analytics.controller.ts): `friends-restaurant/backend/src/controllers/analytics.controller.ts`
- [Sync controller](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/controllers/sync.controller.ts): `friends-restaurant/backend/src/controllers/sync.controller.ts`

### Data and Media

- [Menu service](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/services/menu.service.ts): `friends-restaurant/backend/src/services/menu.service.ts`
- [Prisma database](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/config/database.ts): `friends-restaurant/backend/src/config/database.ts`
- [Media storage](https://github.com/gfani/friends_menu/blob/main/friends-restaurant/backend/src/services/storage.service.ts): `friends-restaurant/backend/src/services/storage.service.ts`

### Other components

- **Restaurant guest**
- **Restaurant manager**

## Connections

- Restaurant guest → Web application: opens menu (evidence: `README.md`)
- Web application → Customer menu: routes to (evidence: `friends-restaurant/frontend/src/App.tsx`)
- Customer menu → Menu data hooks: loads menu (evidence: `friends-restaurant/frontend/src/pages/CustomerMenu.tsx`)
- Customer menu → Language translations: displays language (evidence: `friends-restaurant/frontend/src/pages/CustomerMenu.tsx`)
- Offline PWA cache → Customer menu: caches offline (evidence: `README.md`)
- Restaurant manager → Web application: opens portal (evidence: `README.md`)
- Web application → Admin login: routes to (evidence: `friends-restaurant/frontend/src/App.tsx`)
- Web application → Admin dashboard: protects route (evidence: `friends-restaurant/frontend/src/App.tsx`)
- Admin login → Session authentication: authenticates through (evidence: `friends-restaurant/frontend/src/pages/AdminLogin.tsx`)
- Admin dashboard → Session authentication: uses session (evidence: `friends-restaurant/frontend/src/pages/AdminDashboard.tsx`)
- Admin dashboard → Category management: renders (evidence: `friends-restaurant/frontend/src/pages/AdminDashboard.tsx`)
- Admin dashboard → Dish management: renders (evidence: `friends-restaurant/frontend/src/pages/AdminDashboard.tsx`)
- Admin dashboard → Site settings CMS: renders (evidence: `friends-restaurant/frontend/src/pages/AdminDashboard.tsx`)
- Admin dashboard → Menu analytics: renders (evidence: `friends-restaurant/frontend/src/pages/AdminDashboard.tsx`)
- Admin dashboard → QR and manager guide: offers tools (evidence: `README.md`)
- Menu data hooks → REST API client: requests data (evidence: `friends-restaurant/frontend/src/hooks/useMenu.ts`)
- Session authentication → REST API client: calls auth API (evidence: `friends-restaurant/frontend/src/context/AuthContext.tsx`)
- Category management → Menu data hooks: mutates categories (evidence: `friends-restaurant/frontend/src/components/admin/CategoryManager.tsx`)
- Dish management → Menu data hooks: manages dishes
- Site settings CMS → Menu data hooks: updates settings
- Menu analytics → REST API client: loads analytics
- REST API client → Fastify server: calls REST API (evidence: `README.md`)
- Fastify server → Menu routes: registers (evidence: `friends-restaurant/backend/src/app.ts`)
- Fastify server → Authentication routes: registers (evidence: `friends-restaurant/backend/src/app.ts`)
- Fastify server → Settings routes: registers (evidence: `friends-restaurant/backend/src/app.ts`)
- Fastify server → Analytics routes: registers (evidence: `friends-restaurant/backend/src/app.ts`)
- Fastify server → Sync routes: registers (evidence: `friends-restaurant/backend/src/app.ts`)
- Menu routes → Menu controller: routes requests (evidence: `friends-restaurant/backend/src/routes/menu.routes.ts`)
- Authentication routes → Auth controller: routes requests (evidence: `friends-restaurant/backend/src/routes/auth.routes.ts`)
- Settings routes → Settings controller: routes requests (evidence: `friends-restaurant/backend/src/routes/settings.routes.ts`)
- Analytics routes → Analytics controller: routes requests (evidence: `friends-restaurant/backend/src/routes/analytics.routes.ts`)
- Sync routes → Sync controller: routes requests (evidence: `friends-restaurant/backend/src/routes/sync.routes.ts`)
- Menu controller → Menu service: delegates menu (evidence: `friends-restaurant/backend/src/controllers/menu.controller.ts`)
- Menu controller → Media storage: handles uploads (evidence: `friends-restaurant/backend/src/controllers/menu.controller.ts`)
- Menu service → Prisma database: queries records (evidence: `friends-restaurant/backend/src/services/menu.service.ts`)
- Auth controller → Prisma database: uses database (evidence: `friends-restaurant/backend/src/controllers/auth.controller.ts`)
- Settings controller → Prisma database: uses database (evidence: `friends-restaurant/backend/src/controllers/settings.controller.ts`)
- Sync controller → Prisma database: uses database (evidence: `friends-restaurant/backend/src/controllers/sync.controller.ts`)
- Analytics controller → Prisma database: records analytics
