# nandhuanil/fruitbunch architecture

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

- Interactive diagram: https://gitdiagram.com/nandhuanil/fruitbunch
- Repository: https://github.com/nandhuanil/fruitbunch

## Overview

This repository is a single-page React application built with Vite, plus a separate serverless backend project under `functions/`. The overall shape is: browser UI in `src/`, shared client state and route guards in `src/context` and `src/utils`, and a backend function runtime in `functions/` for server-side logic.

The frontend entrypoints are `src/main.jsx` and `src/App.jsx`. `main.jsx` bootstraps the React app, while `App.jsx` is the central composition point for routing and global layout. The app uses a typical SPA structure rather than server-rendered pages.

The UI shell is made of reusable cross-cutting components in `src/components`: `Navbar`, `Footer`, `ScrollToTop`, and `WhatsAppFloat`. These are likely mounted globally so navigation, page-reset behavior, and the floating WhatsApp contact action are available across the whole site.

The route map is organized into feature pages in `src/pages`. The pages fall into a few clear clusters: marketing/content pages (`Home`, `About`, `Corporate`, `Subscription`, `PrivacyPolicy`, `TermsAndCondition`), authentication/account pages (`Login`, `Signup`, `ForgotPassword`, `Profile`), purchase flow pages (`Cart`, `Checkout`, `OrderConfirm`), and an `AdminPanel` for privileged management.

Client-side state is centered on `src/context/CartContext.jsx`. That suggests cart data is held in React context and shared across product/browse, cart, and checkout views without prop drilling. This context is the main in-app state boundary for the commerce flow.

Access control is separated into route-guard utilities in `src/utils`: `PrivateRoute.jsx` and `AdminRoute.jsx`. These imply two authorization tiers in the frontend: authenticated user-only areas and admin-only areas. That makes the routing layer an important architectural boundary, not just a navigation concern.

Authentication and user identity are likely backed by Firebase, as indicated by `firebaseConfig.js` at the root. The app probably uses Firebase on the client side for auth and possibly user data, while the protected profile/admin routes rely on that identity state.

There is also a distinct backend/serverless subsystem under `functions/` with its own `package.json`, `index.js`, and Catalyst configuration files (`.catalystrc`, `catalyst.json`, `app-config.json`). This is a separate deployment/runtime boundary from the Vite app, and it likely hosts backend operations that the frontend calls indirectly.

The project appears to mix client-side and backend integrations rather than relying on a single monolith. The front end reads environment-specific settings from `.env.development` and `.env.production`, and the backend has its own `.env`, which suggests environment isolation between browser config and server-side secrets.

Styling and build tooling are standard modern frontend infrastructure: Tailwind CSS (`tailwind.config.js`), PostCSS (`postcss.config.js`), ESLint (`eslint.config.js`), and Vite (`vite.config.js`). `public/site.webmanifest` indicates the app includes PWA-style metadata or installable-web-app support.

In architectural terms, the primary data flow is: user interacts with the React SPA, route guards decide access, shared cart state drives checkout, auth state is managed via Firebase-backed identity, and server-side function calls go through the separate `functions/` runtime. The admin panel is a distinct privileged surface on top of the same frontend and backend foundations.

Main entry points: [`src/App.jsx`](https://github.com/nandhuanil/fruitbunch/blob/main/src/App.jsx) (App Shell), [`functions/index.js`](https://github.com/nandhuanil/fruitbunch/blob/main/functions/index.js) (Functions Runtime), [`firebaseConfig.js`](https://github.com/nandhuanil/fruitbunch/blob/main/firebaseConfig.js) (Firebase Config), [`src/utils/PrivateRoute.jsx`](https://github.com/nandhuanil/fruitbunch/blob/main/src/utils/PrivateRoute.jsx) (Private Route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend SPA"]
  node_main(("Bootstrap<br/>react entry<br/>[main.jsx]"))
  node_app["App Shell<br/>spa shell<br/>[App.jsx]"]
  node_navbar["Navbar<br/>ui shell<br/>[Navbar.jsx]"]
  node_footer["Footer<br/>ui shell<br/>[Footer.jsx]"]
  node_scrolltop["Scroll Top<br/>ui behavior<br/>[ScrollToTop.jsx]"]
  node_whatsapp["WhatsApp Float<br/>contact action<br/>[WhatsAppFloat.jsx]"]
  node_cartctx[("Cart State<br/>react context<br/>[CartContext.jsx]")]
  node_privateroute["Private Route<br/>route guard<br/>[PrivateRoute.jsx]"]
  node_adminroute["Admin Route<br/>route guard<br/>[AdminRoute.jsx]"]
  node_home["Home<br/>marketing page<br/>[Home.jsx]"]
  node_account["Account Pages<br/>auth/profile pages<br/>[Login.jsx]"]
  node_commerce["Commerce Pages<br/>purchase flow<br/>[Cart.jsx]"]
  node_content["Content Pages<br/>[About.jsx]"]
  node_adminpanel{{"Admin Panel<br/>admin surface<br/>[AdminPanel.jsx]"}}
end

subgraph group_backend["Serverless Backend"]
  node_functions["Functions Runtime<br/>serverless backend<br/>[index.js]"]
  node_functions_pkg["Function Package<br/>backend manifest<br/>[package.json]"]
end

subgraph group_infra["Build & Config"]
  node_firebase[("Firebase Config<br/>client backend config<br/>[firebaseConfig.js]")]
  node_env["Env Config<br/>runtime config<br/>[.env.development]"]
  node_vite["Vite Config<br/>build config<br/>[vite.config.js]"]
  node_tailwind["Tailwind Config<br/>style config<br/>[tailwind.config.js]"]
  node_webmanifest["Web Manifest<br/>pwa metadata<br/>[site.webmanifest]"]
end

node_main -->|"renders"| node_app
node_app -->|"uses"| node_navbar
node_app -->|"uses"| node_footer
node_app -->|"wraps"| node_scrolltop
node_app -->|"mounts"| node_whatsapp
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_content
node_app -->|"routes to"| node_account
node_app -->|"routes to"| node_commerce
node_app -->|"protects"| node_adminroute
node_app -->|"protects"| node_privateroute
node_adminroute -->|"guards"| node_adminpanel
node_privateroute -->|"guards"| node_account
node_cartctx -->|"drives"| node_commerce
node_firebase -->|"authenticates"| node_account
node_firebase -->|"verifies"| node_privateroute
node_functions -->|"defined by"| node_functions_pkg
node_functions -->|"integrates"| node_firebase
node_env -->|"configures"| node_vite
node_env -->|"configures"| node_functions
node_vite -->|"builds"| node_main
node_tailwind -->|"styles"| node_app
node_webmanifest -->|"supports"| node_app

click node_main "https://github.com/nandhuanil/fruitbunch/blob/main/src/main.jsx"
click node_app "https://github.com/nandhuanil/fruitbunch/blob/main/src/App.jsx"
click node_navbar "https://github.com/nandhuanil/fruitbunch/blob/main/src/components/Navbar.jsx"
click node_footer "https://github.com/nandhuanil/fruitbunch/blob/main/src/components/Footer.jsx"
click node_scrolltop "https://github.com/nandhuanil/fruitbunch/blob/main/src/components/ScrollToTop.jsx"
click node_whatsapp "https://github.com/nandhuanil/fruitbunch/blob/main/src/components/WhatsAppFloat.jsx"
click node_cartctx "https://github.com/nandhuanil/fruitbunch/blob/main/src/context/CartContext.jsx"
click node_privateroute "https://github.com/nandhuanil/fruitbunch/blob/main/src/utils/PrivateRoute.jsx"
click node_adminroute "https://github.com/nandhuanil/fruitbunch/blob/main/src/utils/AdminRoute.jsx"
click node_home "https://github.com/nandhuanil/fruitbunch/blob/main/src/pages/Home.jsx"
click node_account "https://github.com/nandhuanil/fruitbunch/blob/main/src/pages/Login.jsx"
click node_commerce "https://github.com/nandhuanil/fruitbunch/blob/main/src/pages/Cart.jsx"
click node_content "https://github.com/nandhuanil/fruitbunch/blob/main/src/pages/About.jsx"
click node_adminpanel "https://github.com/nandhuanil/fruitbunch/blob/main/src/pages/AdminPanel.jsx"
click node_firebase "https://github.com/nandhuanil/fruitbunch/blob/main/firebaseConfig.js"
click node_functions "https://github.com/nandhuanil/fruitbunch/blob/main/functions/index.js"
click node_functions_pkg "https://github.com/nandhuanil/fruitbunch/blob/main/functions/package.json"
click node_env "https://github.com/nandhuanil/fruitbunch/blob/main/.env.development"
click node_vite "https://github.com/nandhuanil/fruitbunch/blob/main/vite.config.js"
click node_tailwind "https://github.com/nandhuanil/fruitbunch/blob/main/tailwind.config.js"
click node_webmanifest "https://github.com/nandhuanil/fruitbunch/blob/main/public/site.webmanifest"

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_main,node_app,node_navbar,node_footer,node_scrolltop,node_whatsapp,node_cartctx,node_privateroute,node_adminroute,node_home,node_account,node_commerce,node_content,node_adminpanel toneBlue
class node_functions,node_functions_pkg toneAmber
class node_firebase,node_env,node_vite,node_tailwind,node_webmanifest toneMint
```

## Components

### Frontend SPA

Vite-based React single-page application in src/.

- [Bootstrap](https://github.com/nandhuanil/fruitbunch/blob/main/src/main.jsx): react entry · Mounts the React application into the browser DOM. · `src/main.jsx`
- [App Shell](https://github.com/nandhuanil/fruitbunch/blob/main/src/App.jsx): spa shell · Central composition for routing and global layout. · `src/App.jsx`
- [Navbar](https://github.com/nandhuanil/fruitbunch/blob/main/src/components/Navbar.jsx): ui shell · Primary navigation component used across the app. · `src/components/Navbar.jsx`
- [Footer](https://github.com/nandhuanil/fruitbunch/blob/main/src/components/Footer.jsx): ui shell · Global footer component for site-wide layout. · `src/components/Footer.jsx`
- [Scroll Top](https://github.com/nandhuanil/fruitbunch/blob/main/src/components/ScrollToTop.jsx): ui behavior · Resets scroll position during route changes. · `src/components/ScrollToTop.jsx`
- [WhatsApp Float](https://github.com/nandhuanil/fruitbunch/blob/main/src/components/WhatsAppFloat.jsx): contact action · Floating contact shortcut shown across the site. · `src/components/WhatsAppFloat.jsx`
- [Cart State](https://github.com/nandhuanil/fruitbunch/blob/main/src/context/CartContext.jsx): react context · Shared cart and checkout state boundary for the commerce flow. · `src/context/CartContext.jsx`
- [Private Route](https://github.com/nandhuanil/fruitbunch/blob/main/src/utils/PrivateRoute.jsx): route guard · Restricts authenticated-user-only areas. · `src/utils/PrivateRoute.jsx`
- [Admin Route](https://github.com/nandhuanil/fruitbunch/blob/main/src/utils/AdminRoute.jsx): route guard · Restricts privileged admin-only areas. · `src/utils/AdminRoute.jsx`
- [Home](https://github.com/nandhuanil/fruitbunch/blob/main/src/pages/Home.jsx): marketing page · Primary landing and discovery page. · `src/pages/Home.jsx`
- [Account Pages](https://github.com/nandhuanil/fruitbunch/blob/main/src/pages/Login.jsx): auth/profile pages · Login, signup, password recovery, and profile surfaces. · `src/pages/Login.jsx`
- [Commerce Pages](https://github.com/nandhuanil/fruitbunch/blob/main/src/pages/Cart.jsx): purchase flow · Cart, checkout, and order confirmation screens. · `src/pages/Cart.jsx`
- [Content Pages](https://github.com/nandhuanil/fruitbunch/blob/main/src/pages/About.jsx): site content pages · About, corporate, subscription, and legal information pages. · `src/pages/About.jsx`
- [Admin Panel](https://github.com/nandhuanil/fruitbunch/blob/main/src/pages/AdminPanel.jsx): admin surface · Privileged management interface inside the SPA. · `src/pages/AdminPanel.jsx`

### Serverless Backend

Separate runtime and deployment boundary under functions/.

- [Functions Runtime](https://github.com/nandhuanil/fruitbunch/blob/main/functions/index.js): serverless backend · Separate backend runtime for server-side logic and integrations. · `functions/index.js`
- [Function Package](https://github.com/nandhuanil/fruitbunch/blob/main/functions/package.json): backend manifest · Backend dependency and deployment definition for the serverless project. · `functions/package.json`

### Build & Config

Repository-wide tooling, environment, and app configuration.

- [Firebase Config](https://github.com/nandhuanil/fruitbunch/blob/main/firebaseConfig.js): client backend config · Client-side Firebase initialization and identity wiring. · `firebaseConfig.js`
- [Env Config](https://github.com/nandhuanil/fruitbunch/blob/main/.env.development): runtime config · Environment-specific browser and server configuration files. · `.env.development`
- [Vite Config](https://github.com/nandhuanil/fruitbunch/blob/main/vite.config.js): build config · Frontend build and dev server configuration. · `vite.config.js`
- [Tailwind Config](https://github.com/nandhuanil/fruitbunch/blob/main/tailwind.config.js): style config · Utility CSS framework configuration for the UI. · `tailwind.config.js`
- [Web Manifest](https://github.com/nandhuanil/fruitbunch/blob/main/public/site.webmanifest): pwa metadata · Installable-web-app metadata for the public site. · `public/site.webmanifest`

## Connections

- Bootstrap → App Shell: renders · Application bootstrap hands off to the SPA shell.
- App Shell → Navbar: uses · Global layout includes site navigation.
- App Shell → Footer: uses · Global layout includes the footer.
- App Shell → Scroll Top: wraps · Route transitions reset scroll position.
- App Shell → WhatsApp Float: mounts · Floating contact action is available site-wide.
- App Shell → Home: routes to · Landing page is one of the primary SPA destinations.
- App Shell → Content Pages: routes to · Static and informational pages are routed from the shell.
- App Shell → Account Pages: routes to · Auth and profile pages are routed from the shell.
- App Shell → Commerce Pages: routes to · Shopping and order-flow pages are routed from the shell.
- App Shell → Admin Route: protects · Admin surface is gated by privileged routing.
- App Shell → Private Route: protects · Authenticated areas are guarded at the route layer.
- Admin Route → Admin Panel: guards · Admin panel is accessible only through the admin guard.
- Private Route → Account Pages: guards · Protected account and profile areas rely on auth checks.
- Cart State → Commerce Pages: drives · Cart state powers cart and checkout screens.
- Firebase Config → Account Pages: authenticates · Client identity state supports login and profile flows.
- Firebase Config → Private Route: verifies · Frontend access control depends on authenticated identity.
- Functions Runtime → Function Package: defined by · Backend runtime is packaged and deployed separately.
- Functions Runtime → Firebase Config: integrates · Server-side logic complements the client identity/data layer.
- Env Config → Vite Config: configures · Environment settings feed the frontend build and runtime.
- Env Config → Functions Runtime: configures · Backend runtime uses its own isolated environment settings.
- Vite Config → Bootstrap: builds · Vite compiles and serves the React entrypoint.
- Tailwind Config → App Shell: styles · Tailwind provides the UI styling system.
- Web Manifest → App Shell: supports · Manifest supports PWA-style browser installation metadata.
