# venu-822006/vr architecture

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

- Interactive diagram: https://gitdiagram.com/venu-822006/vr
- Repository: https://github.com/venu-822006/vr

## Overview

#### Purpose and Entrypoints

VR Vegetables is a local vegetable-delivery e-commerce system with a React/Next.js customer UI and a Node/Express API plus background worker. The browser entry is `pages/index.jsx`, bootstrapped through `pages/_app.jsx`; the application UI is centered in `src/App.jsx`. Backend processes start from `backend/server.js` (HTTP API) and `backend/worker.js` (asynchronous jobs).

#### Frontend Application Shell

`src/App.jsx` coordinates the storefront’s major states: browsing, authentication, cart/checkout, account access, and owner operations. The Next wrapper at `pages/index.jsx` exposes this React application, while `pages/_document.jsx` controls document-level markup. Shared presentation and global UI behavior are composed from `src/components/Header.jsx`, `src/components/BottomNav.jsx`, and `src/styles/styles.js`.

#### Storefront and Product Discovery

Catalog presentation is client-driven from local product data in `src/data/products.js`, with labels/content centralized in `src/data/constants.js` and `src/data/translations.js`. Product browsing flows through category selection, search, and card rendering: `src/components/CategoryTabs.jsx`, `src/components/SearchSuggestions.jsx`, and `src/components/ProductCard.jsx`. Product imagery is served from `public/images`.

#### Cart and Checkout Boundary

The purchasing flow accumulates product selections in the client UI, presents them through `src/components/CartDrawer.jsx`, and transitions into `src/components/Checkout.jsx`. `src/components/PaymentOption.jsx` encapsulates payment-choice presentation. This is the primary boundary where frontend state must invoke the Express API for order creation and downstream processing rather than treating local UI state as authoritative.

#### Identity, Customer, and Owner Modes

Authentication and persisted session behavior are isolated under `src/utils/auth.js`, `src/utils/session.js`, and `src/utils/storage.js`; customer profile handling is in `src/utils/customerProfile.js`. Customer-facing account operations are rendered by `src/components/AccountPage.jsx`. A separate owner authorization path, `src/utils/ownerAuth.js`, gates administrative functionality in `src/components/OwnerDashboard.jsx`.

#### Backend API and Asynchronous Processing

`backend/server.js` is the API boundary between the browser and durable services, expected to handle application requests, database access, and queue submission. `backend/worker.js` consumes BullMQ jobs independently of HTTP request lifetimes. Operational data scripts—`backend/seed_images.js` and `backend/reset_login_data.js`—support initial content and login-data maintenance.

#### Runtime, Infrastructure, and External Services

Production separates the Next.js frontend (Vercel) from Node API and worker processes (Render), configured for deployment by `render.yaml`. Supabase PostgreSQL is the durable database, and Upstash Redis supports cache and BullMQ queues. Local parity services—PostgreSQL, Redis, and MinIO/S3-compatible object storage—are orchestrated by `docker-compose.yml`; backend containerization is defined in `backend/Dockerfile`. Browser push/service-worker behavior is represented by `src/sw.js` and `src/utils/push.js`.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Next.js Storefront"]
  node_next_entry["Next entry<br/>page entry<br/>[index.jsx]"]
  node_app["Storefront app<br/>React application<br/>[App.jsx]"]
  node_app_shell["Shared UI shell<br/>presentation<br/>[Header.jsx]"]
  node_catalog["Catalog discovery<br/>storefront flow<br/>[CategoryTabs.jsx]"]
  node_product_data["Local catalog data<br/>client data<br/>[products.js]"]
  node_product_images["Product images<br/>static assets"]
  node_cart_checkout["Cart &amp; checkout<br/>purchase flow<br/>[Checkout.jsx]"]
  node_identity["Customer identity<br/>client session<br/>[auth.js]"]
  node_account["Account page<br/>customer UI<br/>[AccountPage.jsx]"]
  node_owner["Owner dashboard<br/>admin UI<br/>[OwnerDashboard.jsx]"]
  node_push["Push service worker<br/>browser worker<br/>[sw.js]"]
end

subgraph group_backend["API &amp; Jobs"]
  node_api{{"Express API<br/>HTTP service<br/>[server.js]"}}
  node_worker["BullMQ worker<br/>job consumer<br/>[worker.js]"]
  node_operations["Data operations<br/>maintenance scripts<br/>[seed_images.js]"]
end

subgraph group_services["Durable Services"]
  node_postgres[("Supabase PostgreSQL<br/>durable database")]
  node_redis["Upstash Redis<br/>cache &amp; queue"]
end

subgraph group_deployment["Runtime &amp; Local Parity"]
  node_vercel["Vercel frontend<br/>production runtime"]
  node_render["Render API &amp; worker<br/>production runtime<br/>[render.yaml]"]
  node_local_stack["Local service stack<br/>Docker Compose<br/>[docker-compose.yml]"]
end

node_next_entry -->|"mounts"| node_app
node_app -->|"composes"| node_app_shell
node_app -->|"drives"| node_catalog
node_catalog -->|"reads"| node_product_data
node_catalog -->|"renders"| node_product_images
node_app -->|"transitions to"| node_cart_checkout
node_app -->|"uses"| node_identity
node_identity -->|"enables"| node_account
node_app -->|"exposes"| node_owner
node_app -.->|"registers"| node_push
node_cart_checkout -->|"creates orders"| node_api
node_api -->|"persists"| node_postgres
node_api -->|"submits jobs"| node_redis
node_worker -->|"consumes jobs"| node_redis
node_worker -->|"updates data"| node_postgres
node_operations -.->|"maintains"| node_postgres
node_vercel -->|"hosts"| node_next_entry
node_render -->|"runs"| node_api
node_render -->|"runs"| node_worker
node_local_stack -.->|"local parity"| node_postgres
node_local_stack -.->|"local parity"| node_redis

click node_next_entry "https://github.com/venu-822006/vr/blob/main/pages/index.jsx"
click node_app "https://github.com/venu-822006/vr/blob/main/src/App.jsx"
click node_app_shell "https://github.com/venu-822006/vr/blob/main/src/components/Header.jsx"
click node_catalog "https://github.com/venu-822006/vr/blob/main/src/components/CategoryTabs.jsx"
click node_product_data "https://github.com/venu-822006/vr/blob/main/src/data/products.js"
click node_product_images "https://github.com/venu-822006/vr/tree/main/public/images"
click node_cart_checkout "https://github.com/venu-822006/vr/blob/main/src/components/Checkout.jsx"
click node_identity "https://github.com/venu-822006/vr/blob/main/src/utils/auth.js"
click node_account "https://github.com/venu-822006/vr/blob/main/src/components/AccountPage.jsx"
click node_owner "https://github.com/venu-822006/vr/blob/main/src/components/OwnerDashboard.jsx"
click node_push "https://github.com/venu-822006/vr/blob/main/src/sw.js"
click node_api "https://github.com/venu-822006/vr/blob/main/backend/server.js"
click node_worker "https://github.com/venu-822006/vr/blob/main/backend/worker.js"
click node_operations "https://github.com/venu-822006/vr/blob/main/backend/seed_images.js"
click node_render "https://github.com/venu-822006/vr/blob/main/render.yaml"
click node_local_stack "https://github.com/venu-822006/vr/blob/main/docker-compose.yml"

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_next_entry,node_app,node_app_shell,node_catalog,node_product_data,node_product_images,node_cart_checkout,node_identity,node_account,node_owner,node_push toneBlue
class node_api,node_worker,node_operations toneAmber
class node_postgres,node_redis toneMint
class node_vercel,node_render,node_local_stack toneRose
```

## Components

### Next.js Storefront

- [Next entry](https://github.com/venu-822006/vr/blob/main/pages/index.jsx): page entry · `pages/index.jsx`
- [Storefront app](https://github.com/venu-822006/vr/blob/main/src/App.jsx): React application · Coordinates browsing, identity, cart, checkout, and owner modes. · `src/App.jsx`
- [Shared UI shell](https://github.com/venu-822006/vr/blob/main/src/components/Header.jsx): presentation · `src/components/Header.jsx`
- [Catalog discovery](https://github.com/venu-822006/vr/blob/main/src/components/CategoryTabs.jsx): storefront flow · Category, search, and product-card browsing. · `src/components/CategoryTabs.jsx`
- [Local catalog data](https://github.com/venu-822006/vr/blob/main/src/data/products.js): client data · `src/data/products.js`
- [Product images](https://github.com/venu-822006/vr/tree/main/public/images): static assets · `public/images`
- [Cart & checkout](https://github.com/venu-822006/vr/blob/main/src/components/Checkout.jsx): purchase flow · Creates orders through the API boundary. · `src/components/Checkout.jsx`
- [Customer identity](https://github.com/venu-822006/vr/blob/main/src/utils/auth.js): client session · Authentication, storage, session, and profile behavior. · `src/utils/auth.js`
- [Account page](https://github.com/venu-822006/vr/blob/main/src/components/AccountPage.jsx): customer UI · `src/components/AccountPage.jsx`
- [Owner dashboard](https://github.com/venu-822006/vr/blob/main/src/components/OwnerDashboard.jsx): admin UI · Gated by separate owner authorization. · `src/components/OwnerDashboard.jsx`
- [Push service worker](https://github.com/venu-822006/vr/blob/main/src/sw.js): browser worker · `src/sw.js`

### API & Jobs

- [Express API](https://github.com/venu-822006/vr/blob/main/backend/server.js): HTTP service · Request boundary for orders, database access, and job submission. · `backend/server.js`
- [BullMQ worker](https://github.com/venu-822006/vr/blob/main/backend/worker.js): job consumer · Processes asynchronous work outside HTTP request lifetimes. · `backend/worker.js`
- [Data operations](https://github.com/venu-822006/vr/blob/main/backend/seed_images.js): maintenance scripts · Seeds images and resets login data. · `backend/seed_images.js`

### Durable Services

- **Supabase PostgreSQL**: durable database
- **Upstash Redis**: cache & queue · Supports caching and BullMQ queues.

### Runtime & Local Parity

- **Vercel frontend**: production runtime
- [Render API & worker](https://github.com/venu-822006/vr/blob/main/render.yaml): production runtime · Runs independent API and worker processes. · `render.yaml`
- [Local service stack](https://github.com/venu-822006/vr/blob/main/docker-compose.yml): Docker Compose · PostgreSQL, Redis, and MinIO/S3-compatible local parity services. · `docker-compose.yml`

## Connections

- Next entry → Storefront app: mounts
- Storefront app → Shared UI shell: composes
- Storefront app → Catalog discovery: drives
- Catalog discovery → Local catalog data: reads
- Catalog discovery → Product images: renders
- Storefront app → Cart & checkout: transitions to
- Storefront app → Customer identity: uses
- Customer identity → Account page: enables
- Storefront app → Owner dashboard: exposes
- Storefront app → Push service worker: registers
- Cart & checkout → Express API: creates orders
- Express API → Supabase PostgreSQL: persists
- Express API → Upstash Redis: submits jobs
- BullMQ worker → Upstash Redis: consumes jobs
- BullMQ worker → Supabase PostgreSQL: updates data
- Data operations → Supabase PostgreSQL: maintains
- Vercel frontend → Next entry: hosts
- Render API & worker → Express API: runs
- Render API & worker → BullMQ worker: runs
- Local service stack → Supabase PostgreSQL: local parity
- Local service stack → Upstash Redis: local parity
