# nishalkc/scatch architecture

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

- Interactive diagram: https://gitdiagram.com/nishalkc/scatch
- Repository: https://github.com/nishalkc/scatch

## Overview

Scatch is a marketplace web application for browsing and listing products, with account registration/login and a cart. The main workflow loads the user and product catalogue in the React app, lets users browse shops, categories, offers and product details, and sends listing or cart actions to Express routes and controllers. The backend uses user and product models, cookie-based authentication, and image-upload configuration. The source index and excerpts support the main wiring; some unsampled page behavior and database connection details are not verified here.

Main entry points: [`client/src/App.jsx`](https://github.com/nishalkc/scatch/blob/main/client/src/App.jsx) (App and routing), [`client/src/services/Api.jsx`](https://github.com/nishalkc/scatch/blob/main/client/src/services/Api.jsx) (HTTP client), [`client/src/components/ProductCard.jsx`](https://github.com/nishalkc/scatch/blob/main/client/src/components/ProductCard.jsx) (Product card), [`client/src/pages/Shop.jsx`](https://github.com/nishalkc/scatch/blob/main/client/src/pages/Shop.jsx) (Shop page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["App and routing<br/>[App.jsx]"]
  node_navbar["Navigation bar<br/>[Navbar.jsx]"]
  node_sidebar["Account sidebar<br/>[SideBar.jsx]"]
  node_create["Create listing<br/>[CreateProducts.jsx]"]
  node_form["Listing form<br/>[Form.jsx]"]
  node_api["HTTP client<br/>[Api.jsx]"]
end

subgraph group_browse["Product discovery"]
  node_home["Home page<br/>[Home.jsx]"]
  node_hero["Home showcase<br/>[Hero.jsx]"]
  node_shop["Shop page<br/>[Shop.jsx]"]
  node_category["Category page"]
  node_offers["Offers page<br/>[OfferProducts.jsx]"]
  node_details["Product details<br/>[ProductDetails.jsx]"]
  node_loader["Product loader<br/>[ProductLoader.jsx]"]
  node_card["Product card<br/>[ProductCard.jsx]"]
end

subgraph group_identity["Accounts"]
  node_login["Login page<br/>[Login.jsx]"]
  node_register["Registration page<br/>[Register.jsx]"]
  node_profile["Profile page<br/>[Profile.jsx]"]
end

subgraph group_backend["API and domain"]
  node_express["Express app<br/>[app.js]"]
  node_user_routes["User routes<br/>[userRoutes.js]"]
  node_product_routes["Product routes<br/>[productsRoutes.js]"]
  node_auth["Auth controller<br/>[authcontroller.js]"]
  node_products["Product controller"]
  node_middleware["Auth middleware<br/>[authmiddleware.js]"]
  node_user_model["User model<br/>[user.js]"]
  node_product_model["Product model<br/>[products.js]"]
  node_upload["Image upload config<br/>[multer.js]"]
  node_cloudinary["Cloudinary config<br/>[cloudinary.js]"]
end

node_visitor(("Shopper / seller"))

node_visitor -->|"uses"| node_app
node_app -->|"renders"| node_navbar
node_app -->|"renders"| node_sidebar
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_shop
node_app -->|"routes to"| node_category
node_app -->|"routes to"| node_offers
node_app -->|"routes to"| node_details
node_app -->|"routes to"| node_create
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_register
node_app -->|"routes to"| node_profile
node_home -->|"renders"| node_hero
node_hero -->|"renders"| node_card
node_shop -->|"uses"| node_sidebar
node_shop -->|"renders"| node_card
node_shop -->|"renders"| node_loader
node_offers -->|"renders"| node_loader
node_category -->|"renders"| node_loader
node_details -->|"uses"| node_card
node_loader -->|"renders"| node_card
node_create -->|"renders"| node_form
node_app -->|"loads user and products"| node_api
node_login -->|"sends auth requests"| node_api
node_register -->|"sends registration"| node_api
node_create -->|"submits listing"| node_api
node_details -->|"requests product"| node_api
node_category -->|"requests category"| node_api
node_card -->|"adds to cart"| node_api
node_sidebar -->|"logs out"| node_api
node_api -.->|"HTTP requests"| node_express
node_express -->|"mounts"| node_user_routes
node_express -->|"mounts"| node_product_routes
node_user_routes -->|"dispatches"| node_auth
node_user_routes -->|"protects profile"| node_middleware
node_product_routes -->|"dispatches"| node_products
node_product_routes -->|"protects routes"| node_middleware
node_product_routes -->|"configures upload"| node_upload
node_auth -->|"reads and writes"| node_user_model
node_auth -->|"issues token for"| node_user_model
node_middleware -->|"loads user"| node_user_model
node_products -->|"reads and writes"| node_product_model
node_products -->|"updates owner"| node_user_model
node_upload -->|"uses config"| node_cloudinary

click node_app "https://github.com/nishalkc/scatch/blob/main/client/src/App.jsx"
click node_navbar "https://github.com/nishalkc/scatch/blob/main/client/src/components/Navbar.jsx"
click node_sidebar "https://github.com/nishalkc/scatch/blob/main/client/src/components/SideBar.jsx"
click node_home "https://github.com/nishalkc/scatch/blob/main/client/src/pages/Home.jsx"
click node_hero "https://github.com/nishalkc/scatch/blob/main/client/src/components/Hero.jsx"
click node_shop "https://github.com/nishalkc/scatch/blob/main/client/src/pages/Shop.jsx"
click node_category "https://github.com/nishalkc/scatch/blob/main/client/src/pages/ProductsBYCategory.jsx"
click node_offers "https://github.com/nishalkc/scatch/blob/main/client/src/pages/OfferProducts.jsx"
click node_details "https://github.com/nishalkc/scatch/blob/main/client/src/pages/ProductDetails.jsx"
click node_loader "https://github.com/nishalkc/scatch/blob/main/client/src/components/ProductLoader.jsx"
click node_card "https://github.com/nishalkc/scatch/blob/main/client/src/components/ProductCard.jsx"
click node_create "https://github.com/nishalkc/scatch/blob/main/client/src/pages/CreateProducts.jsx"
click node_form "https://github.com/nishalkc/scatch/blob/main/client/src/components/Form.jsx"
click node_login "https://github.com/nishalkc/scatch/blob/main/client/src/pages/Login.jsx"
click node_register "https://github.com/nishalkc/scatch/blob/main/client/src/pages/Register.jsx"
click node_profile "https://github.com/nishalkc/scatch/blob/main/client/src/pages/Profile.jsx"
click node_api "https://github.com/nishalkc/scatch/blob/main/client/src/services/Api.jsx"
click node_express "https://github.com/nishalkc/scatch/blob/main/server/app.js"
click node_user_routes "https://github.com/nishalkc/scatch/blob/main/server/routes/userRoutes.js"
click node_product_routes "https://github.com/nishalkc/scatch/blob/main/server/routes/productsRoutes.js"
click node_auth "https://github.com/nishalkc/scatch/blob/main/server/controllers/authcontroller.js"
click node_products "https://github.com/nishalkc/scatch/blob/main/server/controllers/productscontroller.js"
click node_middleware "https://github.com/nishalkc/scatch/blob/main/server/middleware/authmiddleware.js"
click node_user_model "https://github.com/nishalkc/scatch/blob/main/server/models/user.js"
click node_product_model "https://github.com/nishalkc/scatch/blob/main/server/models/products.js"
click node_upload "https://github.com/nishalkc/scatch/blob/main/server/config/multer.js"
click node_cloudinary "https://github.com/nishalkc/scatch/blob/main/server/config/cloudinary.js"

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_navbar,node_sidebar,node_create,node_form,node_api toneBlue
class node_home,node_hero,node_shop,node_category,node_offers,node_details,node_loader,node_card toneAmber
class node_login,node_register,node_profile toneMint
class node_express,node_user_routes,node_product_routes,node_auth,node_products,node_middleware,node_user_model,node_product_model,node_upload,node_cloudinary toneRose
class node_visitor toneIndigo
```

## Components

### Web application

- [App and routing](https://github.com/nishalkc/scatch/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Navigation bar](https://github.com/nishalkc/scatch/blob/main/client/src/components/Navbar.jsx): `client/src/components/Navbar.jsx`
- [Account sidebar](https://github.com/nishalkc/scatch/blob/main/client/src/components/SideBar.jsx): `client/src/components/SideBar.jsx`
- [Create listing](https://github.com/nishalkc/scatch/blob/main/client/src/pages/CreateProducts.jsx): `client/src/pages/CreateProducts.jsx`
- [Listing form](https://github.com/nishalkc/scatch/blob/main/client/src/components/Form.jsx): `client/src/components/Form.jsx`
- [HTTP client](https://github.com/nishalkc/scatch/blob/main/client/src/services/Api.jsx): `client/src/services/Api.jsx`

### Product discovery

- [Home page](https://github.com/nishalkc/scatch/blob/main/client/src/pages/Home.jsx): `client/src/pages/Home.jsx`
- [Home showcase](https://github.com/nishalkc/scatch/blob/main/client/src/components/Hero.jsx): `client/src/components/Hero.jsx`
- [Shop page](https://github.com/nishalkc/scatch/blob/main/client/src/pages/Shop.jsx): `client/src/pages/Shop.jsx`
- [Category page](https://github.com/nishalkc/scatch/blob/main/client/src/pages/ProductsBYCategory.jsx): `client/src/pages/ProductsBYCategory.jsx`
- [Offers page](https://github.com/nishalkc/scatch/blob/main/client/src/pages/OfferProducts.jsx): `client/src/pages/OfferProducts.jsx`
- [Product details](https://github.com/nishalkc/scatch/blob/main/client/src/pages/ProductDetails.jsx): `client/src/pages/ProductDetails.jsx`
- [Product loader](https://github.com/nishalkc/scatch/blob/main/client/src/components/ProductLoader.jsx): `client/src/components/ProductLoader.jsx`
- [Product card](https://github.com/nishalkc/scatch/blob/main/client/src/components/ProductCard.jsx): `client/src/components/ProductCard.jsx`

### Accounts

- [Login page](https://github.com/nishalkc/scatch/blob/main/client/src/pages/Login.jsx): `client/src/pages/Login.jsx`
- [Registration page](https://github.com/nishalkc/scatch/blob/main/client/src/pages/Register.jsx): `client/src/pages/Register.jsx`
- [Profile page](https://github.com/nishalkc/scatch/blob/main/client/src/pages/Profile.jsx): `client/src/pages/Profile.jsx`

### API and domain

- [Express app](https://github.com/nishalkc/scatch/blob/main/server/app.js): `server/app.js`
- [User routes](https://github.com/nishalkc/scatch/blob/main/server/routes/userRoutes.js): `server/routes/userRoutes.js`
- [Product routes](https://github.com/nishalkc/scatch/blob/main/server/routes/productsRoutes.js): `server/routes/productsRoutes.js`
- [Auth controller](https://github.com/nishalkc/scatch/blob/main/server/controllers/authcontroller.js): `server/controllers/authcontroller.js`
- [Product controller](https://github.com/nishalkc/scatch/blob/main/server/controllers/productscontroller.js): `server/controllers/productscontroller.js`
- [Auth middleware](https://github.com/nishalkc/scatch/blob/main/server/middleware/authmiddleware.js): `server/middleware/authmiddleware.js`
- [User model](https://github.com/nishalkc/scatch/blob/main/server/models/user.js): `server/models/user.js`
- [Product model](https://github.com/nishalkc/scatch/blob/main/server/models/products.js): `server/models/products.js`
- [Image upload config](https://github.com/nishalkc/scatch/blob/main/server/config/multer.js): `server/config/multer.js`
- [Cloudinary config](https://github.com/nishalkc/scatch/blob/main/server/config/cloudinary.js): `server/config/cloudinary.js`

### Other components

- **Shopper / seller**

## Connections

- Shopper / seller → App and routing: uses (evidence: `client/src/App.jsx`)
- App and routing → Navigation bar: renders (evidence: `client/src/App.jsx`)
- App and routing → Account sidebar: renders (evidence: `client/src/App.jsx`)
- App and routing → Home page: routes to (evidence: `client/src/App.jsx`)
- App and routing → Shop page: routes to (evidence: `client/src/App.jsx`)
- App and routing → Category page: routes to (evidence: `client/src/App.jsx`)
- App and routing → Offers page: routes to (evidence: `client/src/App.jsx`)
- App and routing → Product details: routes to (evidence: `client/src/App.jsx`)
- App and routing → Create listing: routes to (evidence: `client/src/App.jsx`)
- App and routing → Login page: routes to (evidence: `client/src/App.jsx`)
- App and routing → Registration page: routes to (evidence: `client/src/App.jsx`)
- App and routing → Profile page: routes to (evidence: `client/src/App.jsx`)
- Home page → Home showcase: renders (evidence: `client/src/pages/Home.jsx`)
- Home showcase → Product card: renders (evidence: `client/src/components/Hero.jsx`)
- Shop page → Account sidebar: uses (evidence: `client/src/pages/Shop.jsx`)
- Shop page → Product card: renders (evidence: `client/src/pages/Shop.jsx`)
- Shop page → Product loader: renders (evidence: `client/src/pages/Shop.jsx`)
- Offers page → Product loader: renders (evidence: `client/src/pages/OfferProducts.jsx`)
- Category page → Product loader: renders (evidence: `client/src/pages/ProductsBYCategory.jsx`)
- Product details → Product card: uses (evidence: `client/src/pages/ProductDetails.jsx`)
- Product loader → Product card: renders (evidence: `client/src/components/ProductLoader.jsx`)
- Create listing → Listing form: renders (evidence: `client/src/pages/CreateProducts.jsx`)
- App and routing → HTTP client: loads user and products (evidence: `client/src/App.jsx`)
- Login page → HTTP client: sends auth requests (evidence: `client/src/pages/Login.jsx`)
- Registration page → HTTP client: sends registration (evidence: `client/src/pages/Register.jsx`)
- Create listing → HTTP client: submits listing (evidence: `client/src/pages/CreateProducts.jsx`)
- Product details → HTTP client: requests product (evidence: `client/src/pages/ProductDetails.jsx`)
- Category page → HTTP client: requests category (evidence: `client/src/pages/ProductsBYCategory.jsx`)
- Product card → HTTP client: adds to cart (evidence: `client/src/components/ProductCard.jsx`)
- Account sidebar → HTTP client: logs out (evidence: `client/src/components/SideBar.jsx`)
- HTTP client → Express app: HTTP requests
- Express app → User routes: mounts (evidence: `server/app.js`)
- Express app → Product routes: mounts (evidence: `server/app.js`)
- User routes → Auth controller: dispatches (evidence: `server/routes/userRoutes.js`)
- User routes → Auth middleware: protects profile (evidence: `server/routes/userRoutes.js`)
- Product routes → Product controller: dispatches (evidence: `server/routes/productsRoutes.js`)
- Product routes → Auth middleware: protects routes (evidence: `server/routes/productsRoutes.js`)
- Product routes → Image upload config: configures upload (evidence: `server/routes/productsRoutes.js`)
- Auth controller → User model: reads and writes (evidence: `server/controllers/authcontroller.js`)
- Auth controller → User model: issues token for (evidence: `server/controllers/authcontroller.js`)
- Auth middleware → User model: loads user (evidence: `server/middleware/authmiddleware.js`)
- Product controller → Product model: reads and writes (evidence: `server/controllers/productscontroller.js`)
- Product controller → User model: updates owner (evidence: `server/controllers/productscontroller.js`)
- Image upload config → Cloudinary config: uses config (evidence: `server/config/multer.js`)
