# sjha-dev/product-store-with-postgress architecture

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

- Interactive diagram: https://gitdiagram.com/sjha-dev/product-store-with-postgress
- Repository: https://github.com/sjha-dev/product-store-with-postgress

## Overview

This is a small PERN product-catalogue app: an Express API supports product listing and CRUD, while a React storefront provides home/product routes and theme selection. The backend initializes a Neon Postgres products table, applies Arcjet protection, and dispatches product routes to database-backed controllers. The frontend pages are skeletal in the sampled source, and no frontend-to-API call is shown, so that connection is omitted. The graph reflects the inspected files; other product behavior is not assumed.

Main entry points: [`frontend/src/App.jsx`](https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/App.jsx) (App Router), [`backend/server.js`](https://github.com/sjha-dev/product-store-with-postgress/blob/main/backend/server.js) (API Server), [`frontend/src/components/ThemeSelector.jsx`](https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/components/ThemeSelector.jsx) (Theme Selector), [`backend/config/db.js`](https://github.com/sjha-dev/product-store-with-postgress/blob/main/backend/config/db.js) (Database Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Product API"]
  node_api["API Server<br/>[server.js]"]
  node_product_routes["Product Routes<br/>[productRoutes.js]"]
  node_product_controller["Product Controller"]
  node_db_config["Database Client<br/>[db.js]"]
  node_postgres[("Neon Postgres")]
end

subgraph group_security["Request Security"]
  node_arcjet_config["Arcjet Rules<br/>[arcjet.js]"]
end

subgraph group_frontend["Storefront"]
  node_app["App Router<br/>[App.jsx]"]
  node_home["Home Page<br/>[HomePage.jsx]"]
  node_product_page["Product Page<br/>[ProductPage.jsx]"]
  node_navbar["Navigation Bar<br/>[Navbar.jsx]"]
  node_frontend_entry["Frontend Entry<br/>[main.jsx]"]
end

subgraph group_theme["Theme Selection"]
  node_theme_selector["Theme Selector<br/>[ThemeSelector.jsx]"]
  node_theme_store["Theme Store<br/>[useThemestore.js]"]
  node_theme_constants["Theme Options<br/>[index.js]"]
end

node_shopper(("Shopper"))
node_browser(("Browser"))
node_local_storage[("Browser Storage")]

node_shopper -->|"uses"| node_browser
node_browser -->|"loads"| node_frontend_entry
node_frontend_entry -->|"renders"| node_app
node_shopper -.->|"requests"| node_api
node_api -->|"checks requests"| node_arcjet_config
node_api -->|"mounts routes"| node_product_routes
node_api -->|"creates table"| node_db_config
node_product_routes -->|"dispatches"| node_product_controller
node_product_controller -->|"queries"| node_db_config
node_db_config -->|"connects"| node_postgres
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_product_page
node_app -->|"renders"| node_navbar
node_app -->|"reads theme"| node_theme_store
node_navbar -->|"renders"| node_theme_selector
node_theme_selector -->|"lists options"| node_theme_constants
node_theme_selector -->|"updates theme"| node_theme_store
node_theme_store -->|"reads and writes"| node_local_storage

click node_api "https://github.com/sjha-dev/product-store-with-postgress/blob/main/backend/server.js"
click node_product_routes "https://github.com/sjha-dev/product-store-with-postgress/blob/main/backend/routes/productRoutes.js"
click node_product_controller "https://github.com/sjha-dev/product-store-with-postgress/blob/main/backend/controllers/productsControllers.js"
click node_db_config "https://github.com/sjha-dev/product-store-with-postgress/blob/main/backend/config/db.js"
click node_arcjet_config "https://github.com/sjha-dev/product-store-with-postgress/blob/main/backend/lib/arcjet.js"
click node_app "https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/App.jsx"
click node_home "https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/pages/HomePage.jsx"
click node_product_page "https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/pages/ProductPage.jsx"
click node_navbar "https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/components/Navbar.jsx"
click node_theme_selector "https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/components/ThemeSelector.jsx"
click node_theme_store "https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/store/useThemestore.js"
click node_theme_constants "https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/constant/index.js"
click node_frontend_entry "https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/main.jsx"

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_api,node_product_routes,node_product_controller,node_db_config,node_postgres,node_browser toneBlue
class node_arcjet_config,node_local_storage toneAmber
class node_app,node_home,node_product_page,node_navbar,node_frontend_entry toneMint
class node_theme_selector,node_theme_store,node_theme_constants toneRose
class node_shopper toneIndigo
```

## Components

### Product API

- [API Server](https://github.com/sjha-dev/product-store-with-postgress/blob/main/backend/server.js): `backend/server.js`
- [Product Routes](https://github.com/sjha-dev/product-store-with-postgress/blob/main/backend/routes/productRoutes.js): `backend/routes/productRoutes.js`
- [Product Controller](https://github.com/sjha-dev/product-store-with-postgress/blob/main/backend/controllers/productsControllers.js): `backend/controllers/productsControllers.js`
- [Database Client](https://github.com/sjha-dev/product-store-with-postgress/blob/main/backend/config/db.js): `backend/config/db.js`
- **Neon Postgres**

### Request Security

- [Arcjet Rules](https://github.com/sjha-dev/product-store-with-postgress/blob/main/backend/lib/arcjet.js): `backend/lib/arcjet.js`

### Storefront

- [App Router](https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Home Page](https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/pages/HomePage.jsx): `frontend/src/pages/HomePage.jsx`
- [Product Page](https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/pages/ProductPage.jsx): `frontend/src/pages/ProductPage.jsx`
- [Navigation Bar](https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/components/Navbar.jsx): `frontend/src/components/Navbar.jsx`
- [Frontend Entry](https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`

### Theme Selection

- [Theme Selector](https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/components/ThemeSelector.jsx): `frontend/src/components/ThemeSelector.jsx`
- [Theme Store](https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/store/useThemestore.js): `frontend/src/store/useThemestore.js`
- [Theme Options](https://github.com/sjha-dev/product-store-with-postgress/blob/main/frontend/src/constant/index.js): `frontend/src/constant/index.js`

### Other components

- **Shopper**
- **Browser**
- **Browser Storage**

## Connections

- Shopper → Browser: uses
- Browser → Frontend Entry: loads (evidence: `frontend/src/main.jsx`)
- Frontend Entry → App Router: renders (evidence: `frontend/src/main.jsx`)
- Shopper → API Server: requests
- API Server → Arcjet Rules: checks requests (evidence: `backend/server.js`)
- API Server → Product Routes: mounts routes (evidence: `backend/server.js`)
- API Server → Database Client: creates table (evidence: `backend/server.js`)
- Product Routes → Product Controller: dispatches (evidence: `backend/routes/productRoutes.js`)
- Product Controller → Database Client: queries (evidence: `backend/controllers/productsControllers.js`)
- Database Client → Neon Postgres: connects (evidence: `backend/config/db.js`)
- App Router → Home Page: routes to (evidence: `frontend/src/App.jsx`)
- App Router → Product Page: routes to (evidence: `frontend/src/App.jsx`)
- App Router → Navigation Bar: renders (evidence: `frontend/src/App.jsx`)
- App Router → Theme Store: reads theme (evidence: `frontend/src/App.jsx`)
- Navigation Bar → Theme Selector: renders (evidence: `frontend/src/components/Navbar.jsx`)
- Theme Selector → Theme Options: lists options (evidence: `frontend/src/components/ThemeSelector.jsx`)
- Theme Selector → Theme Store: updates theme (evidence: `frontend/src/components/ThemeSelector.jsx`)
- Theme Store → Browser Storage: reads and writes (evidence: `frontend/src/store/useThemestore.js`)
