# yashasrnair/vulnshop architecture

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

- Interactive diagram: https://gitdiagram.com/yashasrnair/vulnshop
- Repository: https://github.com/yashasrnair/vulnshop

## Overview

VulnShop is an intentionally vulnerable e-commerce application and OWASP Top 10 classroom demonstration. Users browse products, authenticate, inspect product details, comment or place orders, and can explore profile, order, and admin vulnerability demos; the React pages call an Express REST API backed by MongoDB. The graph preserves documented account, product, order, comment, and admin capabilities. Backend route wiring is evidenced by server.js; some page-to-route mappings and unsampled capabilities are documented in README, so edges cite that documentation where appropriate.

Main entry points: [`frontend/src/App.js`](https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/App.js) (Page routing), [`frontend/src/utils/api.js`](https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/utils/api.js) (API client), [`backend/server.js`](https://github.com/yashasrnair/vulnshop/blob/main/backend/server.js) (HTTP server), [`backend/models/index.js`](https://github.com/yashasrnair/vulnshop/blob/main/backend/models/index.js) (Mongoose models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["React storefront"]
  node_app["Page routing<br/>[App.js]"]
  node_catalog["Product catalog<br/>[Products.js]"]
  node_detail["Product detail<br/>[ProductDetail.js]"]
  node_ordersui["Order history<br/>[Orders.js]"]
  node_profile["Account profile<br/>[Profile.js]"]
  node_apiutil["API client<br/>[api.js]"]
end

subgraph group_api["Express API"]
  node_server["HTTP server<br/>[server.js]"]
  node_authroutes["Auth routes<br/>[auth.js]"]
  node_productroutes["Product routes<br/>[products.js]"]
  node_orderroutes["Order routes<br/>[orders.js]"]
  node_userroutes["User routes<br/>[users.js]"]
  node_commentroutes["Comment routes<br/>[comments.js]"]
  node_adminroutes["Admin routes<br/>[admin.js]"]
  node_authmw["JWT middleware<br/>[auth.js]"]
end

subgraph group_data["MongoDB domain data"]
  node_models["Mongoose models<br/>[index.js]"]
  node_mongo[("MongoDB")]
end

subgraph group_training["Security demos"]
  node_home["OWASP overview<br/>[Home.js]"]
  node_login["Login demo<br/>[Login.js]"]
  node_register["Registration demo<br/>[Register.js]"]
  node_usersui["User directory<br/>[UserList.js]"]
  node_adminui["Admin demos<br/>[Admin.js]"]
end

node_visitor(("Shopper / learner"))

node_visitor -->|"opens storefront"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_register
node_app -->|"routes to"| node_catalog
node_app -->|"routes to"| node_detail
node_app -->|"routes to"| node_ordersui
node_app -->|"routes to"| node_profile
node_app -->|"routes to"| node_usersui
node_app -->|"routes to"| node_adminui
node_login -->|"calls auth API"| node_apiutil
node_register -->|"calls auth API"| node_apiutil
node_catalog -->|"calls product API"| node_apiutil
node_detail -->|"calls product and comment APIs"| node_apiutil
node_detail -->|"submits order"| node_apiutil
node_ordersui -->|"calls order API"| node_apiutil
node_profile -->|"calls account API"| node_apiutil
node_usersui -->|"calls user API"| node_apiutil
node_adminui -->|"calls admin API"| node_apiutil
node_apiutil -->|"sends REST requests"| node_server
node_server -->|"mounts route"| node_authroutes
node_server -->|"mounts route"| node_productroutes
node_server -->|"mounts route"| node_orderroutes
node_server -->|"mounts route"| node_userroutes
node_server -->|"mounts route"| node_adminroutes
node_server -->|"mounts route"| node_commentroutes
node_productroutes -->|"guards mutations"| node_authmw
node_orderroutes -->|"guards endpoints"| node_authmw
node_adminroutes -->|"guards admin routes"| node_authmw
node_authroutes -->|"reads and writes users"| node_models
node_productroutes -->|"reads and writes products"| node_models
node_orderroutes -->|"reads and writes orders"| node_models
node_userroutes -->|"reads and writes users"| node_models
node_commentroutes -->|"reads and writes comments"| node_models
node_adminroutes -->|"queries user and product counts"| node_models
node_models -.->|"persists domain records"| node_mongo

click node_app "https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/App.js"
click node_home "https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/Home.js"
click node_login "https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/Login.js"
click node_register "https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/Register.js"
click node_catalog "https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/Products.js"
click node_detail "https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/ProductDetail.js"
click node_ordersui "https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/Orders.js"
click node_profile "https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/Profile.js"
click node_usersui "https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/UserList.js"
click node_adminui "https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/Admin.js"
click node_apiutil "https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/utils/api.js"
click node_server "https://github.com/yashasrnair/vulnshop/blob/main/backend/server.js"
click node_authroutes "https://github.com/yashasrnair/vulnshop/blob/main/backend/routes/auth.js"
click node_productroutes "https://github.com/yashasrnair/vulnshop/blob/main/backend/routes/products.js"
click node_orderroutes "https://github.com/yashasrnair/vulnshop/blob/main/backend/routes/orders.js"
click node_userroutes "https://github.com/yashasrnair/vulnshop/blob/main/backend/routes/users.js"
click node_commentroutes "https://github.com/yashasrnair/vulnshop/blob/main/backend/routes/comments.js"
click node_adminroutes "https://github.com/yashasrnair/vulnshop/blob/main/backend/routes/admin.js"
click node_authmw "https://github.com/yashasrnair/vulnshop/blob/main/backend/middleware/auth.js"
click node_models "https://github.com/yashasrnair/vulnshop/blob/main/backend/models/index.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_catalog,node_detail,node_ordersui,node_profile,node_apiutil toneBlue
class node_server,node_authroutes,node_productroutes,node_orderroutes,node_userroutes,node_commentroutes,node_adminroutes,node_authmw toneAmber
class node_models,node_mongo toneMint
class node_home,node_login,node_register,node_usersui,node_adminui toneRose
class node_visitor toneIndigo
```

## Components

### React storefront

- [Page routing](https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/App.js): `frontend/src/App.js`
- [Product catalog](https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/Products.js): `frontend/src/pages/Products.js`
- [Product detail](https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/ProductDetail.js): `frontend/src/pages/ProductDetail.js`
- [Order history](https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/Orders.js): `frontend/src/pages/Orders.js`
- [Account profile](https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/Profile.js): `frontend/src/pages/Profile.js`
- [API client](https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/utils/api.js): `frontend/src/utils/api.js`

### Express API

- [HTTP server](https://github.com/yashasrnair/vulnshop/blob/main/backend/server.js): `backend/server.js`
- [Auth routes](https://github.com/yashasrnair/vulnshop/blob/main/backend/routes/auth.js): `backend/routes/auth.js`
- [Product routes](https://github.com/yashasrnair/vulnshop/blob/main/backend/routes/products.js): `backend/routes/products.js`
- [Order routes](https://github.com/yashasrnair/vulnshop/blob/main/backend/routes/orders.js): `backend/routes/orders.js`
- [User routes](https://github.com/yashasrnair/vulnshop/blob/main/backend/routes/users.js): `backend/routes/users.js`
- [Comment routes](https://github.com/yashasrnair/vulnshop/blob/main/backend/routes/comments.js): `backend/routes/comments.js`
- [Admin routes](https://github.com/yashasrnair/vulnshop/blob/main/backend/routes/admin.js): `backend/routes/admin.js`
- [JWT middleware](https://github.com/yashasrnair/vulnshop/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`

### MongoDB domain data

- [Mongoose models](https://github.com/yashasrnair/vulnshop/blob/main/backend/models/index.js): `backend/models/index.js`
- **MongoDB**

### Security demos

- [OWASP overview](https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/Home.js): `frontend/src/pages/Home.js`
- [Login demo](https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/Login.js): `frontend/src/pages/Login.js`
- [Registration demo](https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/Register.js): `frontend/src/pages/Register.js`
- [User directory](https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/UserList.js): `frontend/src/pages/UserList.js`
- [Admin demos](https://github.com/yashasrnair/vulnshop/blob/main/frontend/src/pages/Admin.js): `frontend/src/pages/Admin.js`

### Other components

- **Shopper / learner**

## Connections

- Shopper / learner → Page routing: opens storefront (evidence: `README.md`)
- Page routing → OWASP overview: routes to (evidence: `frontend/src/App.js`)
- Page routing → Login demo: routes to (evidence: `frontend/src/App.js`)
- Page routing → Registration demo: routes to (evidence: `frontend/src/App.js`)
- Page routing → Product catalog: routes to (evidence: `frontend/src/App.js`)
- Page routing → Product detail: routes to (evidence: `frontend/src/App.js`)
- Page routing → Order history: routes to (evidence: `frontend/src/App.js`)
- Page routing → Account profile: routes to (evidence: `frontend/src/App.js`)
- Page routing → User directory: routes to (evidence: `frontend/src/App.js`)
- Page routing → Admin demos: routes to (evidence: `frontend/src/App.js`)
- Login demo → API client: calls auth API (evidence: `frontend/src/pages/Login.js`)
- Registration demo → API client: calls auth API (evidence: `frontend/src/pages/Register.js`)
- Product catalog → API client: calls product API (evidence: `frontend/src/pages/Products.js`)
- Product detail → API client: calls product and comment APIs (evidence: `frontend/src/pages/ProductDetail.js`)
- Product detail → API client: submits order (evidence: `frontend/src/pages/ProductDetail.js`)
- Order history → API client: calls order API (evidence: `README.md`)
- Account profile → API client: calls account API (evidence: `README.md`)
- User directory → API client: calls user API (evidence: `README.md`)
- Admin demos → API client: calls admin API (evidence: `frontend/src/pages/Admin.js`)
- API client → HTTP server: sends REST requests (evidence: `frontend/src/utils/api.js`)
- HTTP server → Auth routes: mounts route (evidence: `backend/server.js`)
- HTTP server → Product routes: mounts route (evidence: `backend/server.js`)
- HTTP server → Order routes: mounts route (evidence: `backend/server.js`)
- HTTP server → User routes: mounts route (evidence: `backend/server.js`)
- HTTP server → Admin routes: mounts route (evidence: `backend/server.js`)
- HTTP server → Comment routes: mounts route (evidence: `backend/server.js`)
- Product routes → JWT middleware: guards mutations (evidence: `backend/routes/products.js`)
- Order routes → JWT middleware: guards endpoints (evidence: `backend/routes/orders.js`)
- Admin routes → JWT middleware: guards admin routes (evidence: `backend/routes/admin.js`)
- Auth routes → Mongoose models: reads and writes users (evidence: `backend/routes/auth.js`)
- Product routes → Mongoose models: reads and writes products (evidence: `backend/routes/products.js`)
- Order routes → Mongoose models: reads and writes orders (evidence: `backend/routes/orders.js`)
- User routes → Mongoose models: reads and writes users (evidence: `backend/routes/users.js`)
- Comment routes → Mongoose models: reads and writes comments (evidence: `backend/routes/comments.js`)
- Admin routes → Mongoose models: queries user and product counts (evidence: `backend/routes/admin.js`)
- Mongoose models → MongoDB: persists domain records (evidence: `README.md`)
