# mossawir/bounty-app architecture

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

- Interactive diagram: https://gitdiagram.com/mossawir/bounty-app
- Repository: https://github.com/mossawir/bounty-app

## Overview

The Bug Bazaar is a React storefront for browsing developer gear, managing a cart and session, and placing and tracking orders. Shoppers enter through the route shell, browse a URL-filtered and paginated catalogue or product details, then proceed through a protected checkout to an order confirmation. RTK Query handles server data through one transport; Redux holds cart, auth, and live-stock state. The README documents the in-browser mock and optional real-backend configuration. Some page and integration wiring is documented or indexed but not excerpted, so edges show only supported relationships.

Main entry points: [`src/app/App.tsx`](https://github.com/mossawir/bounty-app/blob/main/src/app/App.tsx) (Route shell), [`src/app/api.ts`](https://github.com/mossawir/bounty-app/blob/main/src/app/api.ts) (RTK Query API), [`src/pages/HomePage.tsx`](https://github.com/mossawir/bounty-app/blob/main/src/pages/HomePage.tsx) (Catalogue page), [`src/app/store.ts`](https://github.com/mossawir/bounty-app/blob/main/src/app/store.ts) (Redux store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Storefront experience"]
  node_app["Route shell<br/>[App.tsx]"]
  node_home["Catalogue page<br/>[HomePage.tsx]"]
  node_filters["URL filters"]
  node_filter_logic["Filter logic<br/>[filters.ts]"]
  node_grid["Product grid<br/>[ProductGrid.tsx]"]
  node_product_detail["Product detail"]
  node_cart_page["Cart page<br/>[CartPage.tsx]"]
  node_checkout["Checkout page<br/>[CheckoutPage.tsx]"]
  node_validation["Contact validation<br/>[validation.ts]"]
  node_login["Sign in page<br/>[LoginPage.tsx]"]
  node_account["Account page<br/>[AccountPage.tsx]"]
  node_order_page["Order confirmation<br/>[OrderPage.tsx]"]
  node_layout["Shared layout<br/>[Layout.tsx]"]
end

subgraph group_commerce["Commerce state"]
  node_cart_state["Cart state<br/>[cartSlice.ts]"]
  node_auth_state["Session state<br/>[authSlice.ts]"]
  node_auth_guard["Route guard<br/>[RequireAuth.tsx]"]
  node_store["Redux store<br/>[store.ts]"]
  node_persistence["State persistence<br/>[persist.ts]"]
end

subgraph group_data["Data and errors"]
  node_query_api["RTK Query API<br/>[api.ts]"]
  node_transport["API transport<br/>[client.ts]"]
  node_error_mapping["Error mapping<br/>[errors.ts]"]
  node_backend{{"Mock or backend API"}}
end

subgraph group_realtime["Live stock"]
  node_socket["Stock socket<br/>[stockSocket.ts]"]
  node_stock_feed["Stock feed hook<br/>[useStockFeed.ts]"]
  node_realtime_state["Stock overrides<br/>[realtimeSlice.ts]"]
end

subgraph group_shared["Shared services"]
  node_state_views["Request states<br/>[StateViews.tsx]"]
  node_toast["Toast provider<br/>[ToastProvider.tsx]"]
  node_domain["Domain contract<br/>[domain.ts]"]
  node_format["Formatting and queries<br/>[format.ts]"]
  node_logger["Application logger<br/>[logger.ts]"]
end

node_shopper(("Shopper"))

node_shopper -->|"opens storefront"| node_app
node_app -->|"wraps routes"| node_layout
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_product_detail
node_app -->|"routes to"| node_cart_page
node_app -->|"guards route"| node_checkout
node_app -->|"guards route"| node_order_page
node_app -->|"routes to"| node_login
node_app -->|"guards route"| node_account
node_home -->|"reads URL state"| node_filters
node_filters -->|"uses"| node_filter_logic
node_home -->|"loads catalogue"| node_query_api
node_home -->|"renders results"| node_grid
node_home -->|"renders request states"| node_state_views
node_product_detail -->|"loads product"| node_query_api
node_product_detail -->|"adds product"| node_cart_state
node_cart_page -->|"updates quantities"| node_cart_state
node_checkout -->|"validates contact"| node_validation
node_checkout -->|"submits order"| node_query_api
node_checkout -->|"reads cart"| node_cart_state
node_login -->|"submits credentials"| node_query_api
node_login -->|"sets session"| node_auth_state
node_auth_guard -->|"checks session"| node_auth_state
node_store -->|"registers reducer"| node_auth_state
node_store -->|"registers reducer"| node_cart_state
node_store -->|"registers reducer"| node_realtime_state
node_store -->|"registers API"| node_query_api
node_store -->|"configures persistence"| node_persistence
node_query_api -->|"sends requests"| node_transport
node_query_api -->|"normalizes failures"| node_error_mapping
node_transport -.->|"requests data"| node_backend
node_query_api -->|"expires session"| node_auth_state
node_layout -->|"starts feed"| node_stock_feed
node_stock_feed -->|"opens connection"| node_socket
node_stock_feed -->|"dispatches updates"| node_realtime_state
node_socket -->|"emits stock ticks"| node_realtime_state
node_home -.->|"overlays stock"| node_realtime_state
node_product_detail -.->|"shows live stock"| node_realtime_state
node_layout -.->|"hosts notifications"| node_toast
node_query_api -->|"uses API types"| node_domain
node_filter_logic -->|"queries products"| node_format
node_product_detail -->|"formats display values"| node_format
node_home -->|"derives product data"| node_format
node_layout -.->|"logs errors"| node_logger

click node_app "https://github.com/mossawir/bounty-app/blob/main/src/app/App.tsx"
click node_home "https://github.com/mossawir/bounty-app/blob/main/src/pages/HomePage.tsx"
click node_filters "https://github.com/mossawir/bounty-app/blob/main/src/features/products/useProductFilters.ts"
click node_filter_logic "https://github.com/mossawir/bounty-app/blob/main/src/features/products/filters.ts"
click node_grid "https://github.com/mossawir/bounty-app/blob/main/src/components/ProductGrid.tsx"
click node_product_detail "https://github.com/mossawir/bounty-app/blob/main/src/pages/ProductDetailPage.tsx"
click node_cart_page "https://github.com/mossawir/bounty-app/blob/main/src/pages/CartPage.tsx"
click node_checkout "https://github.com/mossawir/bounty-app/blob/main/src/pages/CheckoutPage.tsx"
click node_validation "https://github.com/mossawir/bounty-app/blob/main/src/features/checkout/validation.ts"
click node_login "https://github.com/mossawir/bounty-app/blob/main/src/pages/LoginPage.tsx"
click node_account "https://github.com/mossawir/bounty-app/blob/main/src/pages/AccountPage.tsx"
click node_order_page "https://github.com/mossawir/bounty-app/blob/main/src/pages/OrderPage.tsx"
click node_cart_state "https://github.com/mossawir/bounty-app/blob/main/src/features/cart/cartSlice.ts"
click node_auth_state "https://github.com/mossawir/bounty-app/blob/main/src/features/auth/authSlice.ts"
click node_auth_guard "https://github.com/mossawir/bounty-app/blob/main/src/features/auth/RequireAuth.tsx"
click node_store "https://github.com/mossawir/bounty-app/blob/main/src/app/store.ts"
click node_query_api "https://github.com/mossawir/bounty-app/blob/main/src/app/api.ts"
click node_transport "https://github.com/mossawir/bounty-app/blob/main/src/api/client.ts"
click node_error_mapping "https://github.com/mossawir/bounty-app/blob/main/src/api/errors.ts"
click node_socket "https://github.com/mossawir/bounty-app/blob/main/src/realtime/stockSocket.ts"
click node_stock_feed "https://github.com/mossawir/bounty-app/blob/main/src/hooks/useStockFeed.ts"
click node_realtime_state "https://github.com/mossawir/bounty-app/blob/main/src/features/realtime/realtimeSlice.ts"
click node_layout "https://github.com/mossawir/bounty-app/blob/main/src/components/Layout.tsx"
click node_state_views "https://github.com/mossawir/bounty-app/blob/main/src/components/StateViews.tsx"
click node_toast "https://github.com/mossawir/bounty-app/blob/main/src/components/ToastProvider.tsx"
click node_domain "https://github.com/mossawir/bounty-app/blob/main/src/types/domain.ts"
click node_format "https://github.com/mossawir/bounty-app/blob/main/src/lib/format.ts"
click node_logger "https://github.com/mossawir/bounty-app/blob/main/src/lib/logger.ts"
click node_persistence "https://github.com/mossawir/bounty-app/blob/main/src/app/persist.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_app,node_home,node_filters,node_filter_logic,node_grid,node_product_detail,node_cart_page,node_checkout,node_validation,node_login,node_account,node_order_page,node_layout toneBlue
class node_cart_state,node_auth_state,node_auth_guard,node_store,node_persistence toneAmber
class node_query_api,node_transport,node_error_mapping,node_backend toneMint
class node_socket,node_stock_feed,node_realtime_state toneRose
class node_state_views,node_toast,node_domain,node_format,node_logger,node_shopper toneIndigo
```

## Components

### Storefront experience

- [Route shell](https://github.com/mossawir/bounty-app/blob/main/src/app/App.tsx): `src/app/App.tsx`
- [Catalogue page](https://github.com/mossawir/bounty-app/blob/main/src/pages/HomePage.tsx): `src/pages/HomePage.tsx`
- [URL filters](https://github.com/mossawir/bounty-app/blob/main/src/features/products/useProductFilters.ts): `src/features/products/useProductFilters.ts`
- [Filter logic](https://github.com/mossawir/bounty-app/blob/main/src/features/products/filters.ts): `src/features/products/filters.ts`
- [Product grid](https://github.com/mossawir/bounty-app/blob/main/src/components/ProductGrid.tsx): `src/components/ProductGrid.tsx`
- [Product detail](https://github.com/mossawir/bounty-app/blob/main/src/pages/ProductDetailPage.tsx): `src/pages/ProductDetailPage.tsx`
- [Cart page](https://github.com/mossawir/bounty-app/blob/main/src/pages/CartPage.tsx): `src/pages/CartPage.tsx`
- [Checkout page](https://github.com/mossawir/bounty-app/blob/main/src/pages/CheckoutPage.tsx): `src/pages/CheckoutPage.tsx`
- [Contact validation](https://github.com/mossawir/bounty-app/blob/main/src/features/checkout/validation.ts): `src/features/checkout/validation.ts`
- [Sign in page](https://github.com/mossawir/bounty-app/blob/main/src/pages/LoginPage.tsx): `src/pages/LoginPage.tsx`
- [Account page](https://github.com/mossawir/bounty-app/blob/main/src/pages/AccountPage.tsx): `src/pages/AccountPage.tsx`
- [Order confirmation](https://github.com/mossawir/bounty-app/blob/main/src/pages/OrderPage.tsx): `src/pages/OrderPage.tsx`
- [Shared layout](https://github.com/mossawir/bounty-app/blob/main/src/components/Layout.tsx): `src/components/Layout.tsx`

### Commerce state

- [Cart state](https://github.com/mossawir/bounty-app/blob/main/src/features/cart/cartSlice.ts): `src/features/cart/cartSlice.ts`
- [Session state](https://github.com/mossawir/bounty-app/blob/main/src/features/auth/authSlice.ts): `src/features/auth/authSlice.ts`
- [Route guard](https://github.com/mossawir/bounty-app/blob/main/src/features/auth/RequireAuth.tsx): `src/features/auth/RequireAuth.tsx`
- [Redux store](https://github.com/mossawir/bounty-app/blob/main/src/app/store.ts): `src/app/store.ts`
- [State persistence](https://github.com/mossawir/bounty-app/blob/main/src/app/persist.ts): `src/app/persist.ts`

### Data and errors

- [RTK Query API](https://github.com/mossawir/bounty-app/blob/main/src/app/api.ts): `src/app/api.ts`
- [API transport](https://github.com/mossawir/bounty-app/blob/main/src/api/client.ts): `src/api/client.ts`
- [Error mapping](https://github.com/mossawir/bounty-app/blob/main/src/api/errors.ts): `src/api/errors.ts`
- **Mock or backend API**

### Live stock

- [Stock socket](https://github.com/mossawir/bounty-app/blob/main/src/realtime/stockSocket.ts): `src/realtime/stockSocket.ts`
- [Stock feed hook](https://github.com/mossawir/bounty-app/blob/main/src/hooks/useStockFeed.ts): `src/hooks/useStockFeed.ts`
- [Stock overrides](https://github.com/mossawir/bounty-app/blob/main/src/features/realtime/realtimeSlice.ts): `src/features/realtime/realtimeSlice.ts`

### Shared services

- [Request states](https://github.com/mossawir/bounty-app/blob/main/src/components/StateViews.tsx): `src/components/StateViews.tsx`
- [Toast provider](https://github.com/mossawir/bounty-app/blob/main/src/components/ToastProvider.tsx): `src/components/ToastProvider.tsx`
- [Domain contract](https://github.com/mossawir/bounty-app/blob/main/src/types/domain.ts): `src/types/domain.ts`
- [Formatting and queries](https://github.com/mossawir/bounty-app/blob/main/src/lib/format.ts): `src/lib/format.ts`
- [Application logger](https://github.com/mossawir/bounty-app/blob/main/src/lib/logger.ts): `src/lib/logger.ts`

### Other components

- **Shopper**

## Connections

- Shopper → Route shell: opens storefront (evidence: `src/app/App.tsx`)
- Route shell → Shared layout: wraps routes (evidence: `src/app/App.tsx`)
- Route shell → Catalogue page: routes to (evidence: `src/app/App.tsx`)
- Route shell → Product detail: routes to (evidence: `src/app/App.tsx`)
- Route shell → Cart page: routes to (evidence: `src/app/App.tsx`)
- Route shell → Checkout page: guards route (evidence: `src/app/App.tsx`)
- Route shell → Order confirmation: guards route (evidence: `src/app/App.tsx`)
- Route shell → Sign in page: routes to (evidence: `src/app/App.tsx`)
- Route shell → Account page: guards route (evidence: `src/app/App.tsx`)
- Catalogue page → URL filters: reads URL state (evidence: `src/pages/HomePage.tsx`)
- URL filters → Filter logic: uses (evidence: `src/features/products/useProductFilters.ts`)
- Catalogue page → RTK Query API: loads catalogue (evidence: `src/pages/HomePage.tsx`)
- Catalogue page → Product grid: renders results (evidence: `src/pages/HomePage.tsx`)
- Catalogue page → Request states: renders request states (evidence: `src/pages/HomePage.tsx`)
- Product detail → RTK Query API: loads product (evidence: `src/pages/ProductDetailPage.tsx`)
- Product detail → Cart state: adds product (evidence: `src/pages/ProductDetailPage.tsx`)
- Cart page → Cart state: updates quantities (evidence: `src/pages/CartPage.tsx`)
- Checkout page → Contact validation: validates contact (evidence: `src/pages/CheckoutPage.tsx`)
- Checkout page → RTK Query API: submits order (evidence: `src/pages/CheckoutPage.tsx`)
- Checkout page → Cart state: reads cart (evidence: `src/pages/CheckoutPage.tsx`)
- Sign in page → RTK Query API: submits credentials (evidence: `src/pages/LoginPage.tsx`)
- Sign in page → Session state: sets session (evidence: `src/pages/LoginPage.tsx`)
- Route guard → Session state: checks session (evidence: `src/features/auth/RequireAuth.tsx`)
- Redux store → Session state: registers reducer (evidence: `src/app/store.ts`)
- Redux store → Cart state: registers reducer (evidence: `src/app/store.ts`)
- Redux store → Stock overrides: registers reducer (evidence: `src/app/store.ts`)
- Redux store → RTK Query API: registers API (evidence: `src/app/store.ts`)
- Redux store → State persistence: configures persistence (evidence: `src/app/store.ts`)
- RTK Query API → API transport: sends requests (evidence: `src/app/api.ts`)
- RTK Query API → Error mapping: normalizes failures (evidence: `src/app/api.ts`)
- API transport → Mock or backend API: requests data (evidence: `README.md`)
- RTK Query API → Session state: expires session (evidence: `src/app/api.ts`)
- Shared layout → Stock feed hook: starts feed (evidence: `src/components/Layout.tsx`)
- Stock feed hook → Stock socket: opens connection (evidence: `src/hooks/useStockFeed.ts`)
- Stock feed hook → Stock overrides: dispatches updates (evidence: `src/hooks/useStockFeed.ts`)
- Stock socket → Stock overrides: emits stock ticks (evidence: `src/realtime/stockSocket.ts`)
- Catalogue page → Stock overrides: overlays stock (evidence: `README.md`)
- Product detail → Stock overrides: shows live stock (evidence: `README.md`)
- Shared layout → Toast provider: hosts notifications (evidence: `README.md`)
- RTK Query API → Domain contract: uses API types (evidence: `src/app/api.ts`)
- Filter logic → Formatting and queries: queries products (evidence: `src/lib/format.ts`)
- Product detail → Formatting and queries: formats display values (evidence: `src/pages/ProductDetailPage.tsx`)
- Catalogue page → Formatting and queries: derives product data (evidence: `src/pages/HomePage.tsx`)
- Shared layout → Application logger: logs errors
