# xandrine-commits/e-commerce-api architecture

> Architecture diagram of the GitHub repository xandrine-commits/e-commerce-api, 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/xandrine-commits/e-commerce-api
- Repository: https://github.com/xandrine-commits/e-commerce-api

## Overview

This is a REST e-commerce API. Clients enter through the Express server and use registration/login or protected product and order endpoints; route handlers validate requests, apply authorization, and query SQL Server. Order handlers also check product existence and return product details and calculated totals. The README documents capabilities beyond the sampled implementation; the graph includes those documented domain stages while limiting links to relationships shown in source or README.

Main entry points: [`routes/orders.js`](https://github.com/xandrine-commits/e-commerce-api/blob/master/routes/orders.js) (Order CRUD), [`server.js`](https://github.com/xandrine-commits/e-commerce-api/blob/master/server.js) (Express server), [`routes/products.js`](https://github.com/xandrine-commits/e-commerce-api/blob/master/routes/products.js) (Product CRUD), [`routes/auth.js`](https://github.com/xandrine-commits/e-commerce-api/blob/master/routes/auth.js) (Auth endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry"]
  node_server["Express server<br/>[server.js]"]
end

subgraph group_identity["Identity and access"]
  node_auth_routes["Auth endpoints<br/>[auth.js]"]
  node_token_auth["JWT verification<br/>[auth.js]"]
  node_role_check["Role authorization<br/>[role.js]"]
end

subgraph group_catalog["Product catalog"]
  node_product_routes["Product CRUD<br/>[products.js]"]
end

subgraph group_orders["Order management"]
  node_order_routes["Order CRUD<br/>[orders.js]"]
  node_product_check["Product existence check<br/>[productHelper.js]"]
end

subgraph group_persistence["Persistence"]
  node_sql_config["SQL connection config<br/>[db.js]"]
  node_sql_server[("SQL Server")]
  node_products_table[("Products")]
  node_orders_table[("Orders")]
  node_users_table[("Users")]
end

node_client(("API client"))

node_client -->|"sends API requests"| node_server
node_server -->|"mounts routes"| node_auth_routes
node_server -->|"mounts routes"| node_product_routes
node_server -->|"mounts routes"| node_order_routes
node_server -->|"connects on startup"| node_sql_config
node_auth_routes -->|"queries users"| node_sql_server
node_auth_routes -->|"reads and writes"| node_users_table
node_auth_routes -->|"returns access token"| node_client
node_product_routes -->|"requires token"| node_token_auth
node_product_routes -->|"checks admin role"| node_role_check
node_product_routes -->|"queries products"| node_sql_server
node_product_routes -->|"reads and writes"| node_products_table
node_order_routes -->|"requires token"| node_token_auth
node_order_routes -->|"checks admin role"| node_role_check
node_order_routes -->|"checks product existence"| node_product_check
node_product_check -->|"queries products"| node_sql_server
node_order_routes -->|"queries orders and products"| node_sql_server
node_order_routes -->|"reads and writes"| node_orders_table
node_order_routes -->|"joins product details"| node_products_table
node_sql_config -->|"configures connection"| node_sql_server
node_products_table -->|"product foreign key"| node_orders_table

click node_server "https://github.com/xandrine-commits/e-commerce-api/blob/master/server.js"
click node_auth_routes "https://github.com/xandrine-commits/e-commerce-api/blob/master/routes/auth.js"
click node_token_auth "https://github.com/xandrine-commits/e-commerce-api/blob/master/middleware/auth.js"
click node_role_check "https://github.com/xandrine-commits/e-commerce-api/blob/master/middleware/role.js"
click node_product_routes "https://github.com/xandrine-commits/e-commerce-api/blob/master/routes/products.js"
click node_order_routes "https://github.com/xandrine-commits/e-commerce-api/blob/master/routes/orders.js"
click node_product_check "https://github.com/xandrine-commits/e-commerce-api/blob/master/helpers/productHelper.js"
click node_sql_config "https://github.com/xandrine-commits/e-commerce-api/blob/master/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_server,node_client toneBlue
class node_auth_routes,node_token_auth,node_role_check toneAmber
class node_product_routes toneMint
class node_order_routes,node_product_check toneRose
class node_sql_config,node_sql_server,node_products_table,node_orders_table,node_users_table toneIndigo
```

## Components

### API entry

- [Express server](https://github.com/xandrine-commits/e-commerce-api/blob/master/server.js): `server.js`

### Identity and access

- [Auth endpoints](https://github.com/xandrine-commits/e-commerce-api/blob/master/routes/auth.js): `routes/auth.js`
- [JWT verification](https://github.com/xandrine-commits/e-commerce-api/blob/master/middleware/auth.js): `middleware/auth.js`
- [Role authorization](https://github.com/xandrine-commits/e-commerce-api/blob/master/middleware/role.js): `middleware/role.js`

### Product catalog

- [Product CRUD](https://github.com/xandrine-commits/e-commerce-api/blob/master/routes/products.js): `routes/products.js`

### Order management

- [Order CRUD](https://github.com/xandrine-commits/e-commerce-api/blob/master/routes/orders.js): `routes/orders.js`
- [Product existence check](https://github.com/xandrine-commits/e-commerce-api/blob/master/helpers/productHelper.js): `helpers/productHelper.js`

### Persistence

- [SQL connection config](https://github.com/xandrine-commits/e-commerce-api/blob/master/db.js): `db.js`
- **SQL Server**
- **Products**
- **Orders**
- **Users**

### Other components

- **API client**

## Connections

- API client → Express server: sends API requests (evidence: `README.md`)
- Express server → Auth endpoints: mounts routes (evidence: `server.js`)
- Express server → Product CRUD: mounts routes (evidence: `server.js`)
- Express server → Order CRUD: mounts routes (evidence: `server.js`)
- Express server → SQL connection config: connects on startup (evidence: `server.js`)
- Auth endpoints → SQL Server: queries users (evidence: `routes/auth.js`)
- Auth endpoints → Users: reads and writes (evidence: `routes/auth.js`)
- Auth endpoints → API client: returns access token (evidence: `README.md`)
- Product CRUD → JWT verification: requires token (evidence: `routes/products.js`)
- Product CRUD → Role authorization: checks admin role (evidence: `routes/products.js`)
- Product CRUD → SQL Server: queries products (evidence: `routes/products.js`)
- Product CRUD → Products: reads and writes (evidence: `routes/products.js`)
- Order CRUD → JWT verification: requires token (evidence: `routes/orders.js`)
- Order CRUD → Role authorization: checks admin role (evidence: `routes/orders.js`)
- Order CRUD → Product existence check: checks product existence (evidence: `routes/orders.js`)
- Product existence check → SQL Server: queries products (evidence: `helpers/productHelper.js`)
- Order CRUD → SQL Server: queries orders and products (evidence: `routes/orders.js`)
- Order CRUD → Orders: reads and writes (evidence: `routes/orders.js`)
- Order CRUD → Products: joins product details (evidence: `routes/orders.js`)
- SQL connection config → SQL Server: configures connection (evidence: `db.js`)
- Products → Orders: product foreign key (evidence: `README.md`)
