# oukmnut/node-crud-api-fronend architecture

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

- Interactive diagram: https://gitdiagram.com/oukmnut/node-crud-api-fronend
- Repository: https://github.com/oukmnut/node-crud-api-fronend

## Overview

This Express/EJS application provides browser-based CRUD pages and a JSON API for users and products, backed by MySQL. Requests enter through the server’s mounted route sets, then controllers validate or shape responses and call the corresponding model; models execute SQL through a shared connection pool. The README documents the full page workflows and a narrower product API (GET/POST); it also notes that product API creation currently has mismatched fields. Views are represented as subsystem nodes because their individual templates were not sampled.

Main entry points: [`src/index.js`](https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/index.js) (Express Server), [`src/controllers/userController.js`](https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/controllers/userController.js) (User Controller), [`src/controllers/productController.js`](https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/controllers/productController.js) (Product Controller), [`src/models/userModel.js`](https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/models/userModel.js) (User Model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["HTTP Runtime"]
  node_server["Express Server<br/>[index.js]"]
end

subgraph group_frontend["Browser CRUD"]
  node_user_pages["User Pages<br/>[userRoutes.js]"]
  node_user_controller["User Controller<br/>[userController.js]"]
  node_user_views["User Templates"]
  node_product_pages["Product Pages<br/>[productRoutes.js]"]
  node_product_controller["Product Controller"]
  node_product_views["Product Templates"]
end

subgraph group_api["JSON API"]
  node_user_api_routes["User API Routes<br/>[apiUserRoutes.js]"]
  node_user_api["User API Handlers<br/>[userController.js]"]
  node_product_api_routes["Product API Routes"]
  node_product_api["Product API Handlers"]
end

subgraph group_persistence["MySQL Persistence"]
  node_user_model["User Model<br/>[userModel.js]"]
  node_product_model["Product Model<br/>[productModel.js]"]
  node_db_pool["MySQL Pool<br/>[db.js]"]
end

node_browser(("Browser"))
node_api_client(("API Client"))
node_mysql[("MySQL Database")]

node_browser -->|"sends requests"| node_server
node_api_client -->|"sends requests"| node_server
node_server -->|"mounts routes"| node_user_pages
node_server -->|"mounts routes"| node_product_pages
node_server -->|"mounts routes"| node_user_api_routes
node_server -->|"mounts routes"| node_product_api_routes
node_user_pages -->|"dispatches to"| node_user_controller
node_product_pages -->|"dispatches to"| node_product_controller
node_user_controller -->|"calls"| node_user_model
node_product_controller -->|"calls"| node_product_model
node_user_controller -->|"renders"| node_user_views
node_product_controller -->|"renders"| node_product_views
node_user_api_routes -->|"dispatches to"| node_user_api
node_product_api_routes -->|"dispatches to"| node_product_api
node_user_api -->|"calls"| node_user_model
node_product_api -->|"calls"| node_product_model
node_user_model -->|"executes queries"| node_db_pool
node_product_model -->|"executes queries"| node_db_pool
node_db_pool -->|"connects to"| node_mysql

click node_server "https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/index.js"
click node_user_pages "https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/routes/userRoutes.js"
click node_user_controller "https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/controllers/userController.js"
click node_user_views "https://github.com/oukmnut/node-crud-api-fronend/tree/master/src/views/users"
click node_product_pages "https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/routes/productRoutes.js"
click node_product_controller "https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/controllers/productController.js"
click node_product_views "https://github.com/oukmnut/node-crud-api-fronend/tree/master/src/views/product"
click node_user_api_routes "https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/routes/apiUserRoutes.js"
click node_user_api "https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/controllers/userController.js"
click node_product_api_routes "https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/routes/apiProductRoutes.js"
click node_product_api "https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/controllers/productController.js"
click node_user_model "https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/models/userModel.js"
click node_product_model "https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/models/productModel.js"
click node_db_pool "https://github.com/oukmnut/node-crud-api-fronend/blob/master/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_server,node_browser,node_api_client toneBlue
class node_user_pages,node_user_controller,node_user_views,node_product_pages,node_product_controller,node_product_views,node_mysql toneAmber
class node_user_api_routes,node_user_api,node_product_api_routes,node_product_api toneMint
class node_user_model,node_product_model,node_db_pool toneRose
```

## Components

### HTTP Runtime

- [Express Server](https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/index.js): `src/index.js`

### Browser CRUD

- [User Pages](https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/routes/userRoutes.js): `src/routes/userRoutes.js`
- [User Controller](https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/controllers/userController.js): `src/controllers/userController.js`
- [User Templates](https://github.com/oukmnut/node-crud-api-fronend/tree/master/src/views/users): `src/views/users`
- [Product Pages](https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/routes/productRoutes.js): `src/routes/productRoutes.js`
- [Product Controller](https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/controllers/productController.js): `src/controllers/productController.js`
- [Product Templates](https://github.com/oukmnut/node-crud-api-fronend/tree/master/src/views/product): `src/views/product`

### JSON API

- [User API Routes](https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/routes/apiUserRoutes.js): `src/routes/apiUserRoutes.js`
- [User API Handlers](https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/controllers/userController.js): `src/controllers/userController.js`
- [Product API Routes](https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/routes/apiProductRoutes.js): `src/routes/apiProductRoutes.js`
- [Product API Handlers](https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/controllers/productController.js): `src/controllers/productController.js`

### MySQL Persistence

- [User Model](https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/models/userModel.js): `src/models/userModel.js`
- [Product Model](https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/models/productModel.js): `src/models/productModel.js`
- [MySQL Pool](https://github.com/oukmnut/node-crud-api-fronend/blob/master/src/config/db.js): `src/config/db.js`

### Other components

- **Browser**
- **API Client**
- **MySQL Database**

## Connections

- Browser → Express Server: sends requests (evidence: `README.md`)
- API Client → Express Server: sends requests (evidence: `README.md`)
- Express Server → User Pages: mounts routes (evidence: `src/index.js`)
- Express Server → Product Pages: mounts routes (evidence: `src/index.js`)
- Express Server → User API Routes: mounts routes (evidence: `src/index.js`)
- Express Server → Product API Routes: mounts routes (evidence: `src/index.js`)
- User Pages → User Controller: dispatches to (evidence: `src/routes/userRoutes.js`)
- Product Pages → Product Controller: dispatches to (evidence: `src/routes/productRoutes.js`)
- User Controller → User Model: calls (evidence: `src/controllers/userController.js`)
- Product Controller → Product Model: calls (evidence: `src/controllers/productController.js`)
- User Controller → User Templates: renders (evidence: `src/controllers/userController.js`)
- Product Controller → Product Templates: renders (evidence: `src/controllers/productController.js`)
- User API Routes → User API Handlers: dispatches to (evidence: `src/routes/apiUserRoutes.js`)
- Product API Routes → Product API Handlers: dispatches to (evidence: `src/routes/apiProductRoutes.js`)
- User API Handlers → User Model: calls (evidence: `src/controllers/userController.js`)
- Product API Handlers → Product Model: calls (evidence: `src/controllers/productController.js`)
- User Model → MySQL Pool: executes queries (evidence: `src/models/userModel.js`)
- Product Model → MySQL Pool: executes queries (evidence: `src/models/productModel.js`)
- MySQL Pool → MySQL Database: connects to (evidence: `src/config/db.js`)
