# bear-system-brasil/bear-delivery-app-web architecture

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

- Interactive diagram: https://gitdiagram.com/bear-system-brasil/bear-delivery-app-web
- Repository: https://github.com/bear-system-brasil/bear-delivery-app-web

## Overview

Bear Delivery is a multi-role food-delivery web app. Customers discover restaurants, customize items, manage a cart, check out, and track orders; restaurant staff, cooks, finance users, and drivers have separate operational workspaces. The client centralizes backend requests through the Next.js proxy, while auth routes and middleware manage session-aware access. The README documents real-time kitchen, delivery, and notification updates. Most feature-page implementations were not sampled, so their internal call relationships are not asserted here.

Main entry points: [`src/services/api.ts`](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/services/api.ts) (API client), [`src/app/cart/page.tsx`](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/cart/page.tsx) (Shopping cart), [`src/app/checkout/page.tsx`](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/checkout/page.tsx) (Checkout), [`src/hooks/useAuthModal.ts`](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/hooks/useAuthModal.ts) (Authentication flow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_customer["Customer ordering"]
  node_browse["Restaurant discovery<br/>[page.tsx]"]
  node_restaurant["Restaurant detail<br/>[page.tsx]"]
  node_customize["Item customization<br/>[index.tsx]"]
  node_cart["Shopping cart<br/>[page.tsx]"]
  node_checkout["Checkout<br/>[page.tsx]"]
  node_tracking["Order tracking<br/>[page.tsx]"]
end

subgraph group_operations["Restaurant operations"]
  node_management["Menu and categories<br/>[page.tsx]"]
  node_orders["Order management<br/>[page.tsx]"]
  node_kitchen["Kitchen display<br/>[index.tsx]"]
  node_finance["Financial management<br/>[page.tsx]"]
  node_delivery["Delivery dashboard<br/>[page.tsx]"]
  node_team["Team management<br/>[page.tsx]"]
  node_notifications["Notifications"]
end

subgraph group_platform["Platform services"]
  node_api["API client<br/>[api.ts]"]
  node_proxy["Backend proxy<br/>[route.ts]"]
  node_cartstate["Cart state<br/>[cart-store.ts]"]
  node_storage["Browser storage<br/>[storage-manager.ts]"]
end

subgraph group_identity["Identity and access"]
  node_authmodal["Authentication dialog<br/>[index.tsx]"]
  node_authflow["Authentication flow<br/>[useAuthModal.ts]"]
  node_authstate["Auth state<br/>[auth-store.ts]"]
  node_authroutes["Auth API routes<br/>[route.ts]"]
  node_session["Session cookie<br/>[session.ts]"]
  node_access["Role route guard<br/>[middleware.ts]"]
  node_roles["Role helpers<br/>[role-helpers.ts]"]
end

node_customer(("Customer"))
node_backend{{"Delivery backend"}}

node_customer -->|"browses"| node_browse
node_browse -->|"opens"| node_restaurant
node_restaurant -->|"customizes"| node_customize
node_customize -->|"adds items"| node_cart
node_cart -->|"checks out"| node_checkout
node_checkout -.->|"submits order"| node_api
node_checkout -->|"tracks order"| node_tracking
node_cart -.->|"uses state"| node_cartstate
node_management -.->|"manages menu"| node_api
node_orders -.->|"manages orders"| node_api
node_kitchen -.->|"handles orders"| node_api
node_finance -.->|"loads finances"| node_api
node_delivery -.->|"updates delivery"| node_api
node_team -.->|"manages staff"| node_api
node_notifications -.->|"loads feed"| node_api
node_api -->|"requests through"| node_proxy
node_proxy -->|"forwards requests"| node_backend
node_authmodal -->|"renders"| node_authflow
node_authflow -->|"authenticates"| node_api
node_authflow -->|"updates session"| node_authstate
node_authroutes -->|"sets cookie"| node_session
node_authroutes -.->|"authenticates with"| node_backend
node_authstate -->|"persists via"| node_storage
node_access -->|"checks roles"| node_roles
node_access -.->|"checks identity"| node_authstate

click node_browse "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/(home)/page.tsx"
click node_restaurant "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/restaurant/%5Bid%5D/page.tsx"
click node_customize "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/components/customize-order/customize-order/index.tsx"
click node_cart "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/cart/page.tsx"
click node_checkout "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/checkout/page.tsx"
click node_tracking "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/order-status/page.tsx"
click node_management "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/menu-management/page.tsx"
click node_orders "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/orders/page.tsx"
click node_kitchen "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/components/kitchen/index.tsx"
click node_finance "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/financial-management/dashboard/page.tsx"
click node_delivery "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/delivery-dashboard/page.tsx"
click node_team "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/team-management/page.tsx"
click node_notifications "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/providers/notifications-provider.tsx"
click node_api "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/services/api.ts"
click node_proxy "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/api/proxy/%5B...path%5D/route.ts"
click node_cartstate "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/stores/cart-store.ts"
click node_authmodal "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/components/auth-modal/index.tsx"
click node_authflow "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/hooks/useAuthModal.ts"
click node_authstate "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/stores/auth-store.ts"
click node_authroutes "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/api/auth/login/route.ts"
click node_session "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/lib/session.ts"
click node_access "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/middleware.ts"
click node_roles "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/utils/role-helpers.ts"
click node_storage "https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/utils/storage-manager.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_browse,node_restaurant,node_customize,node_cart,node_checkout,node_tracking toneBlue
class node_management,node_orders,node_kitchen,node_finance,node_delivery,node_team,node_notifications toneAmber
class node_api,node_proxy,node_cartstate,node_storage toneMint
class node_authmodal,node_authflow,node_authstate,node_authroutes,node_session,node_access,node_roles toneRose
class node_customer,node_backend toneIndigo
```

## Components

### Customer ordering

- [Restaurant discovery](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/(home)/page.tsx): `src/app/(home)/page.tsx`
- [Restaurant detail](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/restaurant/%5Bid%5D/page.tsx): `src/app/restaurant/[id]/page.tsx`
- [Item customization](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/components/customize-order/customize-order/index.tsx): `src/components/customize-order/customize-order/index.tsx`
- [Shopping cart](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/cart/page.tsx): `src/app/cart/page.tsx`
- [Checkout](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/checkout/page.tsx): `src/app/checkout/page.tsx`
- [Order tracking](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/order-status/page.tsx): `src/app/order-status/page.tsx`

### Restaurant operations

- [Menu and categories](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/menu-management/page.tsx): `src/app/menu-management/page.tsx`
- [Order management](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/orders/page.tsx): `src/app/orders/page.tsx`
- [Kitchen display](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/components/kitchen/index.tsx): `src/components/kitchen/index.tsx`
- [Financial management](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/financial-management/dashboard/page.tsx): `src/app/financial-management/dashboard/page.tsx`
- [Delivery dashboard](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/delivery-dashboard/page.tsx): `src/app/delivery-dashboard/page.tsx`
- [Team management](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/team-management/page.tsx): `src/app/team-management/page.tsx`
- [Notifications](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/providers/notifications-provider.tsx): `src/providers/notifications-provider.tsx`

### Platform services

- [API client](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/services/api.ts): `src/services/api.ts`
- [Backend proxy](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/api/proxy/%5B...path%5D/route.ts): `src/app/api/proxy/[...path]/route.ts`
- [Cart state](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/stores/cart-store.ts): `src/stores/cart-store.ts`
- [Browser storage](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/utils/storage-manager.ts): `src/utils/storage-manager.ts`

### Identity and access

- [Authentication dialog](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/components/auth-modal/index.tsx): `src/components/auth-modal/index.tsx`
- [Authentication flow](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/hooks/useAuthModal.ts): `src/hooks/useAuthModal.ts`
- [Auth state](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/stores/auth-store.ts): `src/stores/auth-store.ts`
- [Auth API routes](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/app/api/auth/login/route.ts): `src/app/api/auth/login/route.ts`
- [Session cookie](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/lib/session.ts): `src/lib/session.ts`
- [Role route guard](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/middleware.ts): `src/middleware.ts`
- [Role helpers](https://github.com/bear-system-brasil/bear-delivery-app-web/blob/prod/src/utils/role-helpers.ts): `src/utils/role-helpers.ts`

### Other components

- **Customer**
- **Delivery backend**

## Connections

- Customer → Restaurant discovery: browses (evidence: `README.md`)
- Restaurant discovery → Restaurant detail: opens (evidence: `README.md`)
- Restaurant detail → Item customization: customizes (evidence: `README.md`)
- Item customization → Shopping cart: adds items (evidence: `README.md`)
- Shopping cart → Checkout: checks out (evidence: `README.md`)
- Checkout → API client: submits order
- Checkout → Order tracking: tracks order (evidence: `README.md`)
- Shopping cart → Cart state: uses state
- Menu and categories → API client: manages menu
- Order management → API client: manages orders
- Kitchen display → API client: handles orders
- Financial management → API client: loads finances
- Delivery dashboard → API client: updates delivery
- Team management → API client: manages staff
- Notifications → API client: loads feed
- API client → Backend proxy: requests through (evidence: `src/services/api.ts`)
- Backend proxy → Delivery backend: forwards requests (evidence: `README.md`)
- Authentication dialog → Authentication flow: renders (evidence: `src/components/auth-modal/index.tsx`)
- Authentication flow → API client: authenticates (evidence: `src/hooks/useAuthModal.ts`)
- Authentication flow → Auth state: updates session (evidence: `src/hooks/useAuthModal.ts`)
- Auth API routes → Session cookie: sets cookie (evidence: `src/app/api/auth/login/route.ts`)
- Auth API routes → Delivery backend: authenticates with
- Auth state → Browser storage: persists via (evidence: `src/stores/auth-store.ts`)
- Role route guard → Role helpers: checks roles (evidence: `src/middleware.ts`)
- Role route guard → Auth state: checks identity
