# bhavya-192007/smartpages-e-commerce-online-bookstore architecture

> Architecture diagram of the GitHub repository bhavya-192007/smartpages-e-commerce-online-bookstore, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhavya-192007/smartpages-e-commerce-online-bookstore
- Repository: https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore

## Overview

SmartPages is a React/Express/MySQL bookstore. Customers discover books, manage a persistent cart, check out, and review orders; administrators manage catalog, inventory, categories, analytics, and fulfillment. The graph separates browser experience, API boundary, server business logic, and persistence. Sampled code confirms several client and server calls; README capabilities fill in unsampled domain stages, so those links are documented rather than inferred from naming alone.

Main entry points: [`client/src/services/api.js`](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/services/api.js) (API Client), [`server/src/config/db.js`](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/config/db.js) (MySQL Pool), [`server/src/controllers`](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/tree/feature/database-and-auth/server/src/controllers) (Request Controllers), [`client/src/context/CartContext.jsx`](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/context/CartContext.jsx) (Cart State)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Customer and Admin UI"]
  node_app_shell["App and Routes<br/>[App.jsx]"]
  node_auth_ui["Sign-in and Profile"]
  node_auth_context["Auth Session<br/>[AuthContext.jsx]"]
  node_catalog_ui["Catalog and Details<br/>[Catalog.jsx]"]
  node_book_details["Book Details<br/>[BookDetails.jsx]"]
  node_book_card["Book Card<br/>[BookCard.jsx]"]
  node_cart_context["Cart State<br/>[CartContext.jsx]"]
  node_cart_ui["Cart<br/>[Cart.jsx]"]
  node_checkout_ui["Checkout<br/>[Checkout.jsx]"]
  node_order_views["Order Views"]
  node_admin_ui["Admin Dashboard<br/>[AdminDashboard.jsx]"]
end

subgraph group_client_api["Browser API Access"]
  node_api_client["API Client<br/>[api.js]"]
  node_book_client["Book Service<br/>[bookService.js]"]
  node_cart_client["Cart Service<br/>[cartService.js]"]
  node_order_client["Order Service<br/>[orderService.js]"]
  node_admin_client["Admin Service<br/>[adminService.js]"]
end

subgraph group_server["Express API and Domain"]
  node_express_app["Express App<br/>[app.js]"]
  node_routes["API Routes"]
  node_controllers["Request Controllers"]
  node_auth_service["Authentication<br/>[authService.js]"]
  node_catalog_service["Catalog and Categories<br/>[catalogService.js]"]
  node_cart_service["Cart Operations<br/>[cartService.js]"]
  node_order_service["Order Transactions<br/>[orderService.js]"]
  node_payment_gateway["Mock Payment"]
  node_admin_service["Admin Operations<br/>[adminService.js]"]
  node_auth_middleware["JWT and Role Guards<br/>[auth.js]"]
  node_validation["Request Validation<br/>[validate.js]"]
end

subgraph group_storage["Relational Persistence"]
  node_database[("MySQL Pool<br/>[db.js]")]
end

node_customer(("Customer"))
node_administrator(("Administrator"))

node_customer -->|"uses"| node_app_shell
node_administrator -->|"uses"| node_app_shell
node_app_shell -->|"provides session"| node_auth_context
node_app_shell -->|"provides cart"| node_cart_context
node_auth_ui -->|"uses"| node_auth_context
node_catalog_ui -->|"fetches catalog"| node_book_client
node_catalog_ui -->|"renders"| node_book_card
node_book_details -->|"fetches book"| node_book_client
node_book_details -->|"adds to cart"| node_cart_context
node_cart_ui -->|"uses cart"| node_cart_context
node_checkout_ui -->|"reads cart"| node_cart_context
node_checkout_ui -->|"places order"| node_order_client
node_order_views -.->|"loads orders"| node_order_client
node_admin_ui -->|"requests admin data"| node_admin_client
node_admin_ui -->|"requests books"| node_book_client
node_auth_context -->|"sends auth requests"| node_api_client
node_cart_context -->|"manages cart"| node_cart_client
node_book_client -->|"calls"| node_api_client
node_cart_client -->|"calls"| node_api_client
node_order_client -->|"calls"| node_api_client
node_admin_client -->|"calls"| node_api_client
node_api_client -->|"sends REST requests"| node_express_app
node_express_app -->|"mounts routes"| node_routes
node_routes -->|"dispatches"| node_controllers
node_routes -->|"guards requests"| node_auth_middleware
node_routes -->|"validates requests"| node_validation
node_controllers -->|"delegates auth"| node_auth_service
node_controllers -->|"delegates cart"| node_cart_service
node_controllers -->|"delegates orders"| node_order_service
node_controllers -->|"delegates admin"| node_admin_service
node_auth_service -->|"queries users"| node_database
node_auth_middleware -->|"checks users"| node_database
node_cart_service -->|"reads and writes"| node_database
node_order_service -->|"transacts orders"| node_database
node_admin_service -->|"queries and updates"| node_database
node_order_service -->|"processes payment"| node_payment_gateway
node_catalog_service -.->|"queries catalog"| node_database

click node_app_shell "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/App.jsx"
click node_auth_ui "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/tree/feature/database-and-auth/client/src/pages/Auth"
click node_auth_context "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/context/AuthContext.jsx"
click node_catalog_ui "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/pages/Catalog/Catalog.jsx"
click node_book_details "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/pages/BookDetails/BookDetails.jsx"
click node_book_card "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/components/books/BookCard.jsx"
click node_cart_context "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/context/CartContext.jsx"
click node_cart_ui "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/pages/Cart/Cart.jsx"
click node_checkout_ui "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/pages/Checkout/Checkout.jsx"
click node_order_views "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/tree/feature/database-and-auth/client/src/pages/Orders"
click node_admin_ui "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/pages/Admin/AdminDashboard.jsx"
click node_api_client "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/services/api.js"
click node_book_client "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/services/bookService.js"
click node_cart_client "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/services/cartService.js"
click node_order_client "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/services/orderService.js"
click node_admin_client "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/services/adminService.js"
click node_express_app "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/app.js"
click node_routes "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/tree/feature/database-and-auth/server/src/routes"
click node_controllers "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/tree/feature/database-and-auth/server/src/controllers"
click node_auth_service "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/services/authService.js"
click node_catalog_service "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/services/catalogService.js"
click node_cart_service "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/services/cartService.js"
click node_order_service "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/services/orderService.js"
click node_payment_gateway "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/services/payment/mockPaymentGateway.js"
click node_admin_service "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/services/adminService.js"
click node_auth_middleware "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/middleware/auth.js"
click node_validation "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/middleware/validate.js"
click node_database "https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/config/db.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_shell,node_auth_ui,node_auth_context,node_catalog_ui,node_book_details,node_book_card,node_cart_context,node_cart_ui,node_checkout_ui,node_order_views,node_admin_ui toneBlue
class node_api_client,node_book_client,node_cart_client,node_order_client,node_admin_client toneAmber
class node_express_app,node_routes,node_controllers,node_auth_service,node_catalog_service,node_cart_service,node_order_service,node_payment_gateway,node_admin_service,node_auth_middleware,node_validation toneMint
class node_database toneRose
class node_customer,node_administrator toneIndigo
```

## Components

### Customer and Admin UI

- [App and Routes](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/App.jsx): `client/src/App.jsx`
- [Sign-in and Profile](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/tree/feature/database-and-auth/client/src/pages/Auth): `client/src/pages/Auth`
- [Auth Session](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Catalog and Details](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/pages/Catalog/Catalog.jsx): `client/src/pages/Catalog/Catalog.jsx`
- [Book Details](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/pages/BookDetails/BookDetails.jsx): `client/src/pages/BookDetails/BookDetails.jsx`
- [Book Card](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/components/books/BookCard.jsx): `client/src/components/books/BookCard.jsx`
- [Cart State](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/context/CartContext.jsx): `client/src/context/CartContext.jsx`
- [Cart](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/pages/Cart/Cart.jsx): `client/src/pages/Cart/Cart.jsx`
- [Checkout](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/pages/Checkout/Checkout.jsx): `client/src/pages/Checkout/Checkout.jsx`
- [Order Views](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/tree/feature/database-and-auth/client/src/pages/Orders): `client/src/pages/Orders`
- [Admin Dashboard](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/pages/Admin/AdminDashboard.jsx): `client/src/pages/Admin/AdminDashboard.jsx`

### Browser API Access

- [API Client](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/services/api.js): `client/src/services/api.js`
- [Book Service](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/services/bookService.js): `client/src/services/bookService.js`
- [Cart Service](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/services/cartService.js): `client/src/services/cartService.js`
- [Order Service](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/services/orderService.js): `client/src/services/orderService.js`
- [Admin Service](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/client/src/services/adminService.js): `client/src/services/adminService.js`

### Express API and Domain

- [Express App](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/app.js): `server/src/app.js`
- [API Routes](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/tree/feature/database-and-auth/server/src/routes): `server/src/routes`
- [Request Controllers](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/tree/feature/database-and-auth/server/src/controllers): `server/src/controllers`
- [Authentication](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/services/authService.js): `server/src/services/authService.js`
- [Catalog and Categories](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/services/catalogService.js): `server/src/services/catalogService.js`
- [Cart Operations](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/services/cartService.js): `server/src/services/cartService.js`
- [Order Transactions](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/services/orderService.js): `server/src/services/orderService.js`
- [Mock Payment](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/services/payment/mockPaymentGateway.js): `server/src/services/payment/mockPaymentGateway.js`
- [Admin Operations](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/services/adminService.js): `server/src/services/adminService.js`
- [JWT and Role Guards](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/middleware/auth.js): `server/src/middleware/auth.js`
- [Request Validation](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/middleware/validate.js): `server/src/middleware/validate.js`

### Relational Persistence

- [MySQL Pool](https://github.com/bhavya-192007/smartpages-e-commerce-online-bookstore/blob/feature/database-and-auth/server/src/config/db.js): `server/src/config/db.js`

### Other components

- **Customer**
- **Administrator**

## Connections

- Customer → App and Routes: uses (evidence: `README.md`)
- Administrator → App and Routes: uses (evidence: `README.md`)
- App and Routes → Auth Session: provides session (evidence: `client/src/App.jsx`)
- App and Routes → Cart State: provides cart (evidence: `client/src/App.jsx`)
- Sign-in and Profile → Auth Session: uses (evidence: `client/src/pages/Auth/Register.jsx`)
- Catalog and Details → Book Service: fetches catalog (evidence: `client/src/pages/Catalog/Catalog.jsx`)
- Catalog and Details → Book Card: renders (evidence: `client/src/pages/Catalog/Catalog.jsx`)
- Book Details → Book Service: fetches book (evidence: `client/src/pages/BookDetails/BookDetails.jsx`)
- Book Details → Cart State: adds to cart (evidence: `client/src/pages/BookDetails/BookDetails.jsx`)
- Cart → Cart State: uses cart (evidence: `client/src/pages/Cart/Cart.jsx`)
- Checkout → Cart State: reads cart (evidence: `client/src/pages/Checkout/Checkout.jsx`)
- Checkout → Order Service: places order (evidence: `client/src/pages/Checkout/Checkout.jsx`)
- Order Views → Order Service: loads orders (evidence: `client/src/pages/Orders/OrderConfirmation.jsx`)
- Admin Dashboard → Admin Service: requests admin data (evidence: `client/src/pages/Admin/AdminDashboard.jsx`)
- Admin Dashboard → Book Service: requests books (evidence: `client/src/pages/Admin/AdminDashboard.jsx`)
- Auth Session → API Client: sends auth requests (evidence: `client/src/context/AuthContext.jsx`)
- Cart State → Cart Service: manages cart (evidence: `client/src/context/CartContext.jsx`)
- Book Service → API Client: calls (evidence: `client/src/services/bookService.js`)
- Cart Service → API Client: calls (evidence: `client/src/services/cartService.js`)
- Order Service → API Client: calls (evidence: `client/src/services/orderService.js`)
- Admin Service → API Client: calls (evidence: `client/src/services/adminService.js`)
- API Client → Express App: sends REST requests (evidence: `README.md`)
- Express App → API Routes: mounts routes (evidence: `server/src/app.js`)
- API Routes → Request Controllers: dispatches (evidence: `server/src/routes/adminRoutes.js`)
- API Routes → JWT and Role Guards: guards requests (evidence: `server/src/routes/adminRoutes.js`)
- API Routes → Request Validation: validates requests (evidence: `server/src/routes/authRoutes.js`)
- Request Controllers → Authentication: delegates auth (evidence: `server/src/controllers/authController.js`)
- Request Controllers → Cart Operations: delegates cart (evidence: `server/src/controllers/cartController.js`)
- Request Controllers → Order Transactions: delegates orders (evidence: `server/src/controllers/orderController.js`)
- Request Controllers → Admin Operations: delegates admin (evidence: `server/src/controllers/adminController.js`)
- Authentication → MySQL Pool: queries users (evidence: `server/src/services/authService.js`)
- JWT and Role Guards → MySQL Pool: checks users (evidence: `server/src/middleware/auth.js`)
- Cart Operations → MySQL Pool: reads and writes (evidence: `server/src/services/cartService.js`)
- Order Transactions → MySQL Pool: transacts orders (evidence: `README.md`)
- Admin Operations → MySQL Pool: queries and updates (evidence: `server/src/services/adminService.js`)
- Order Transactions → Mock Payment: processes payment (evidence: `server/src/services/orderService.js`)
- Catalog and Categories → MySQL Pool: queries catalog
