# kotasarat/namaste-react architecture

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

- Interactive diagram: https://gitdiagram.com/kotasarat/namaste-react
- Repository: https://github.com/kotasarat/namaste-react

## Overview

1. **Project shape**
   - This is a React-based food ordering app (“Namaste Food”) built as a client-side SPA.
   - The app is organized around reusable UI components, custom hooks, and a small global state layer for cart data.

2. **Application shell**
   - `src/App.js` is the top-level composition point.
   - It likely defines the route map and stitches together the major screens: header, restaurant listing, restaurant menu, cart, about/contact, grocery, and error handling.

3. **Core user-facing screens**
   - `Header`, `Body`, `RestaurantCard`, `RestaurantMenu`, `RestaurantCategory`, `ItemList`, and `Cart` form the main customer flow.
   - The typical journey is: browse restaurants → open a restaurant menu → expand categories/items → add items to cart → review cart.

4. **Restaurant discovery layer**
   - `Body` and `RestaurantCard` are the listing/search surface.
   - `Search` behavior appears to be covered by tests, so the listing screen likely supports filtering or searching restaurants before navigation into a restaurant detail view.

5. **Menu and item breakdown**
   - `RestaurantMenu` is the restaurant detail page.
   - `RestaurantCategory` and `ItemList` suggest the menu is grouped into collapsible sections, with items rendered and selected from those sections.
   - `useRestaurantMenu` is the data-fetching hook for this page, separating remote menu retrieval from presentation.

6. **Global cart state**
   - `src/utils/appStore.js` and `src/utils/cartSlice.js` indicate Redux Toolkit is used for cart management.
   - Cart state is the primary shared mutable state across the app, consumed by the menu flow and rendered in `Cart`.
   - This creates a clear boundary between local UI state and application-wide order state.

7. **Shared user/context state**
   - `src/utils/UserContext.js` provides a separate context-based shared state, likely for lightweight user identity/profile data.
   - This is distinct from Redux cart state, so the architecture uses both Context API and Redux depending on scope and frequency of updates.

8. **Custom hooks and environmental concerns**
   - `useOnlineStatus` encapsulates connectivity detection and can gate UI behavior when the user is offline.
   - `useRestaurantMenu` encapsulates restaurant/menu fetching logic.
   - These hooks keep network and browser-environment concerns out of presentational components.

9. **Supporting screens and boundaries**
   - `About`, `Contact`, `Grocery`, `User`, `UserClass`, and `Error` are separate route-level or auxiliary components.
   - `Grocery` likely represents a distinct feature area and is probably isolated from the main restaurant/cart flow.
   - `Error` provides a fallback boundary for invalid routes or failures.

10. **Visual loading and empty states**
   - `Shimmer` is used for skeleton/loading feedback while async restaurant or menu data is being fetched.
   - This implies the UI has explicit loading state handling rather than blocking rendering.

11. **Data fixtures and testability**
   - The app includes mocked restaurant and menu payloads under `src/components/mocks`.
   - Unit tests cover key UI and utility behavior in `src/components/__tests__`, including header, cart, contact, restaurant card, search, and a simple utility test.
   - This indicates the UI is designed around deterministic mock-driven tests rather than live API dependence in test runs.

12. **Build, styling, and deployment**
   - Parcel is the bundler/dev server (`parcelrc`, `package.json`), so the app is built as a front-end bundle with hot reload and production optimization.
   - Tailwind is present via `tailwind.config.js`, with `index.css` as the main style entry.
   - Firebase config files (`firebase.json`, `.firebaserc`) suggest deployment/hosting through Firebase.
   - Jest is used for automated testing.

13. **Architectural boundaries to capture in a diagram**
   - UI components render data and emit user actions.
   - Custom hooks handle browser/network concerns.
   - Redux owns shared cart state.
   - Context owns lightweight shared user state.
   - Mock fixtures and tests sit alongside the UI layer to support local development and verification.

Main entry points: [`src/App.js`](https://github.com/kotasarat/namaste-react/blob/main/src/App.js) (App), [`src/components/RestaurantMenu.js`](https://github.com/kotasarat/namaste-react/blob/main/src/components/RestaurantMenu.js) (RestaurantMenu), [`src/components/Body.js`](https://github.com/kotasarat/namaste-react/blob/main/src/components/Body.js) (Body), [`src/components/__tests__`](https://github.com/kotasarat/namaste-react/tree/main/src/components/__tests__) (Tests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_app["App shell"]
  node_app["App<br/>spa shell<br/>[App.js]"]
end

subgraph group_grp_ui["UI flow"]
  node_header["Header<br/>nav<br/>[Header.js]"]
  node_body["Body<br/>listing screen<br/>[Body.js]"]
  node_card["RestaurantCard<br/>listing card<br/>[RestaurantCard.js]"]
  node_menu["RestaurantMenu<br/>detail screen<br/>[RestaurantMenu.js]"]
  node_category["RestaurantCategory<br/>accordion section"]
  node_items["ItemList<br/>menu items<br/>[ItemList.js]"]
  node_cart["Cart<br/>basket screen<br/>[Cart.js]"]
  node_about["About<br/>route page<br/>[About.js]"]
  node_contact["Contact<br/>route page<br/>[Contact.js]"]
  node_grocery["Grocery<br/>feature page<br/>[Grocery.js]"]
  node_error["Error<br/>fallback<br/>[Error.js]"]
  node_shimmer["Shimmer<br/>loading state<br/>[Shimmer.js]"]
  node_user["User<br/>profile view<br/>[User.js]"]
  node_userclass["UserClass<br/>class profile<br/>[UserClass.js]"]
end

subgraph group_grp_state["State and hooks"]
  node_store[("appStore<br/>redux store<br/>[appStore.js]")]
  node_slice["cartSlice<br/>redux slice<br/>[cartSlice.js]"]
  node_context["UserContext<br/>context state<br/>[UserContext.js]"]
  node_online["useOnlineStatus<br/>hook<br/>[useOnlineStatus.js]"]
  node_menuhook["useRestaurantMenu<br/>hook"]
end

subgraph group_grp_support["Support"]
  node_mocks["Mocks<br/>fixtures"]
  node_tests["Tests<br/>jest suite"]
  node_build["Build config<br/>tooling"]
end

node_app -->|"renders"| node_header
node_app -->|"routes to"| node_body
node_app -->|"routes to"| node_menu
node_app -->|"routes to"| node_cart
node_app -->|"routes to"| node_about
node_app -->|"routes to"| node_contact
node_app -->|"routes to"| node_grocery
node_app -->|"fallback"| node_error
node_body -->|"uses"| node_card
node_menu -->|"groups"| node_category
node_category -->|"renders"| node_items
node_menu -->|"fetches via"| node_menuhook
node_body -.->|"checks"| node_online
node_body -->|"loads with"| node_shimmer
node_menu -->|"loads with"| node_shimmer
node_items -->|"dispatches"| node_slice
node_cart -->|"reads"| node_store
node_menu -->|"dispatches"| node_store
node_app -->|"provides"| node_context
node_user -->|"consumes"| node_context
node_userclass -->|"consumes"| node_context
node_body -.->|"tested with"| node_mocks
node_menu -.->|"tested with"| node_mocks
node_tests -.->|"covers"| node_header
node_tests -.->|"covers"| node_cart
node_tests -.->|"covers"| node_contact
node_tests -.->|"covers"| node_card
node_build -.->|"bundles"| node_app
node_build -.->|"runs"| node_tests

click node_app "https://github.com/kotasarat/namaste-react/blob/main/src/App.js"
click node_header "https://github.com/kotasarat/namaste-react/blob/main/src/components/Header.js"
click node_body "https://github.com/kotasarat/namaste-react/blob/main/src/components/Body.js"
click node_card "https://github.com/kotasarat/namaste-react/blob/main/src/components/RestaurantCard.js"
click node_menu "https://github.com/kotasarat/namaste-react/blob/main/src/components/RestaurantMenu.js"
click node_category "https://github.com/kotasarat/namaste-react/blob/main/src/components/RestaurantCategory.js"
click node_items "https://github.com/kotasarat/namaste-react/blob/main/src/components/ItemList.js"
click node_cart "https://github.com/kotasarat/namaste-react/blob/main/src/components/Cart.js"
click node_about "https://github.com/kotasarat/namaste-react/blob/main/src/components/About.js"
click node_contact "https://github.com/kotasarat/namaste-react/blob/main/src/components/Contact.js"
click node_grocery "https://github.com/kotasarat/namaste-react/blob/main/src/components/Grocery.js"
click node_error "https://github.com/kotasarat/namaste-react/blob/main/src/components/Error.js"
click node_shimmer "https://github.com/kotasarat/namaste-react/blob/main/src/components/Shimmer.js"
click node_user "https://github.com/kotasarat/namaste-react/blob/main/src/components/User.js"
click node_userclass "https://github.com/kotasarat/namaste-react/blob/main/src/components/UserClass.js"
click node_store "https://github.com/kotasarat/namaste-react/blob/main/src/utils/appStore.js"
click node_slice "https://github.com/kotasarat/namaste-react/blob/main/src/utils/cartSlice.js"
click node_context "https://github.com/kotasarat/namaste-react/blob/main/src/utils/UserContext.js"
click node_online "https://github.com/kotasarat/namaste-react/blob/main/src/utils/useOnlineStatus.js"
click node_menuhook "https://github.com/kotasarat/namaste-react/blob/main/src/utils/useRestaurantMenu.js"
click node_mocks "https://github.com/kotasarat/namaste-react/tree/main/src/components/mocks"
click node_tests "https://github.com/kotasarat/namaste-react/tree/main/src/components/__tests__"

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_app toneBlue
class node_header,node_body,node_card,node_menu,node_category,node_items,node_cart,node_about,node_contact,node_grocery,node_error,node_shimmer,node_user,node_userclass toneAmber
class node_store,node_slice,node_context,node_online,node_menuhook toneMint
class node_mocks,node_tests,node_build toneRose
```

## Components

### App shell

Top-level composition and route screens

- [App](https://github.com/kotasarat/namaste-react/blob/main/src/App.js): spa shell · Top-level composition and route wiring · `src/App.js`

### UI flow

Customer-facing screens and shared view components

- [Header](https://github.com/kotasarat/namaste-react/blob/main/src/components/Header.js): nav · Global app header and entry navigation · `src/components/Header.js`
- [Body](https://github.com/kotasarat/namaste-react/blob/main/src/components/Body.js): listing screen · Restaurant discovery and search surface · `src/components/Body.js`
- [RestaurantCard](https://github.com/kotasarat/namaste-react/blob/main/src/components/RestaurantCard.js): listing card · Restaurant preview tile in lists · `src/components/RestaurantCard.js`
- [RestaurantMenu](https://github.com/kotasarat/namaste-react/blob/main/src/components/RestaurantMenu.js): detail screen · Restaurant detail and menu page · `src/components/RestaurantMenu.js`
- [RestaurantCategory](https://github.com/kotasarat/namaste-react/blob/main/src/components/RestaurantCategory.js): accordion section · Collapsible menu category grouping · `src/components/RestaurantCategory.js`
- [ItemList](https://github.com/kotasarat/namaste-react/blob/main/src/components/ItemList.js): menu items · Renders selectable items within a category · `src/components/ItemList.js`
- [Cart](https://github.com/kotasarat/namaste-react/blob/main/src/components/Cart.js): basket screen · Cart review and checkout state view · `src/components/Cart.js`
- [About](https://github.com/kotasarat/namaste-react/blob/main/src/components/About.js): route page · Informational route page · `src/components/About.js`
- [Contact](https://github.com/kotasarat/namaste-react/blob/main/src/components/Contact.js): route page · Contact route page · `src/components/Contact.js`
- [Grocery](https://github.com/kotasarat/namaste-react/blob/main/src/components/Grocery.js): feature page · Separate grocery feature area · `src/components/Grocery.js`
- [Error](https://github.com/kotasarat/namaste-react/blob/main/src/components/Error.js): fallback · Fallback screen for errors or invalid routes · `src/components/Error.js`
- [Shimmer](https://github.com/kotasarat/namaste-react/blob/main/src/components/Shimmer.js): loading state · Skeleton loading feedback for async screens · `src/components/Shimmer.js`
- [User](https://github.com/kotasarat/namaste-react/blob/main/src/components/User.js): profile view · Lightweight user display component · `src/components/User.js`
- [UserClass](https://github.com/kotasarat/namaste-react/blob/main/src/components/UserClass.js): class profile · Class-based user variant · `src/components/UserClass.js`

### State and hooks

Shared state, context, and reusable data/browser hooks

- [appStore](https://github.com/kotasarat/namaste-react/blob/main/src/utils/appStore.js): redux store · Redux Toolkit store for shared application state · `src/utils/appStore.js`
- [cartSlice](https://github.com/kotasarat/namaste-react/blob/main/src/utils/cartSlice.js): redux slice · Cart reducer and actions · `src/utils/cartSlice.js`
- [UserContext](https://github.com/kotasarat/namaste-react/blob/main/src/utils/UserContext.js): context state · Shared user/context state · `src/utils/UserContext.js`
- [useOnlineStatus](https://github.com/kotasarat/namaste-react/blob/main/src/utils/useOnlineStatus.js): hook · Connectivity detection hook · `src/utils/useOnlineStatus.js`
- [useRestaurantMenu](https://github.com/kotasarat/namaste-react/blob/main/src/utils/useRestaurantMenu.js): hook · Menu data-fetching hook · `src/utils/useRestaurantMenu.js`

### Support

Mocks, tests, and build/deploy scaffolding

- [Mocks](https://github.com/kotasarat/namaste-react/tree/main/src/components/mocks): fixtures · Mock restaurant and menu payloads · `src/components/mocks`
- [Tests](https://github.com/kotasarat/namaste-react/tree/main/src/components/__tests__): jest suite · Component and utility test coverage · `src/components/__tests__`
- **Build config**: tooling · Parcel, Tailwind, Jest, and Firebase deployment setup

## Connections

- App → Header: renders · Shell composes global header
- App → Body: routes to · Shell connects to main discovery screen
- App → RestaurantMenu: routes to · Shell connects to restaurant detail flow
- App → Cart: routes to · Shell exposes cart screen
- App → About: routes to · Shell exposes about page
- App → Contact: routes to · Shell exposes contact page
- App → Grocery: routes to · Shell exposes grocery feature page
- App → Error: fallback · Shell handles invalid routes or failures
- Body → RestaurantCard: uses · Restaurant listing is composed from cards
- RestaurantMenu → RestaurantCategory: groups · Menu is split into collapsible categories
- RestaurantCategory → ItemList: renders · Each category expands into item rows
- RestaurantMenu → useRestaurantMenu: fetches via · Menu page gets remote data through hook
- Body → useOnlineStatus: checks · Discovery screen can react to connectivity
- Body → Shimmer: loads with · Discovery screen shows loading state
- RestaurantMenu → Shimmer: loads with · Menu page shows loading state
- ItemList → cartSlice: dispatches · Item selection updates cart state
- Cart → appStore: reads · Cart consumes shared redux state
- RestaurantMenu → appStore: dispatches · Menu flow updates shared cart store
- App → UserContext: provides · App wraps tree with shared user context
- User → UserContext: consumes · Profile view reads context state
- UserClass → UserContext: consumes · Class profile participates in user context
- Body → Mocks: tested with · Discovery UI uses mock fixtures in development and tests
- RestaurantMenu → Mocks: tested with · Menu flow relies on mock payloads for local verification
- Tests → Header: covers · Jest suite verifies header behavior
- Tests → Cart: covers · Jest suite verifies cart behavior
- Tests → Contact: covers · Jest suite verifies contact behavior
- Tests → RestaurantCard: covers · Jest suite verifies restaurant card behavior
- Build config → App: bundles · Tooling builds the React SPA
- Build config → Tests: runs · Tooling supports automated tests
