# klasikh/node_api_mysql architecture

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

- Interactive diagram: https://gitdiagram.com/klasikh/node_api_mysql
- Repository: https://github.com/klasikh/node_api_mysql

## Overview

This repository is a small Express service for CRUD operations on notes. A client request enters the app, is routed to a notes handler, and the handler reads or mutates notes through a MySQL pool before returning a response. The app also installs not-found and error middleware; handlers are wrapped to forward exceptions, and custom errors carry HTTP status codes. The README gives no additional product capabilities, and the graph is based on the shown source excerpts.

Main entry points: [`app.js`](https://github.com/klasikh/node_api_mysql/blob/main/app.js) (Express App), [`src/resources/notes/notes.controllers.js`](https://github.com/klasikh/node_api_mysql/blob/main/src/resources/notes/notes.controllers.js) (Notes CRUD), [`src/errors/customErrors.js`](https://github.com/klasikh/node_api_mysql/blob/main/src/errors/customErrors.js) (Custom Errors), [`src/resources/notes/notes.routes.js`](https://github.com/klasikh/node_api_mysql/blob/main/src/resources/notes/notes.routes.js) (Notes Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_app["Express App<br/>[app.js]"]
  node_routes["Notes Routes<br/>[notes.routes.js]"]
  node_controllers["Notes CRUD"]
end

subgraph group_storage["Notes Storage"]
  node_pool["MySQL Pool<br/>[connect.js]"]
  node_mysql[("MySQL Database")]
end

subgraph group_errors["Error Handling"]
  node_wrapper["Async Wrapper<br/>[tryCatchWrapper.js]"]
  node_custom["Custom Errors<br/>[customErrors.js]"]
  node_notfound["Not Found<br/>[notFound.js]"]
  node_errorhandler["Error Handler<br/>[handleError.js]"]
end

node_client(("API Client"))

node_client -->|"sends requests"| node_app
node_app -->|"mounts at /notes"| node_routes
node_routes -->|"dispatches handlers"| node_controllers
node_controllers -->|"queries notes"| node_pool
node_pool -->|"configures connection"| node_mysql
node_controllers -->|"wraps handlers"| node_wrapper
node_wrapper -->|"creates errors"| node_custom
node_controllers -->|"creates errors"| node_custom
node_errorhandler -->|"checks error type"| node_custom
node_app -->|"registers fallback"| node_notfound
node_app -->|"registers handler"| node_errorhandler

click node_app "https://github.com/klasikh/node_api_mysql/blob/main/app.js"
click node_routes "https://github.com/klasikh/node_api_mysql/blob/main/src/resources/notes/notes.routes.js"
click node_controllers "https://github.com/klasikh/node_api_mysql/blob/main/src/resources/notes/notes.controllers.js"
click node_pool "https://github.com/klasikh/node_api_mysql/blob/main/src/db/connect.js"
click node_wrapper "https://github.com/klasikh/node_api_mysql/blob/main/src/middlewares/tryCatchWrapper.js"
click node_custom "https://github.com/klasikh/node_api_mysql/blob/main/src/errors/customErrors.js"
click node_notfound "https://github.com/klasikh/node_api_mysql/blob/main/src/middlewares/notFound.js"
click node_errorhandler "https://github.com/klasikh/node_api_mysql/blob/main/src/middlewares/handleError.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_routes,node_controllers,node_client toneBlue
class node_pool,node_mysql toneAmber
class node_wrapper,node_custom,node_notfound,node_errorhandler toneMint
```

## Components

### HTTP API

- [Express App](https://github.com/klasikh/node_api_mysql/blob/main/app.js): `app.js`
- [Notes Routes](https://github.com/klasikh/node_api_mysql/blob/main/src/resources/notes/notes.routes.js): `src/resources/notes/notes.routes.js`
- [Notes CRUD](https://github.com/klasikh/node_api_mysql/blob/main/src/resources/notes/notes.controllers.js): `src/resources/notes/notes.controllers.js`

### Notes Storage

- [MySQL Pool](https://github.com/klasikh/node_api_mysql/blob/main/src/db/connect.js): `src/db/connect.js`
- **MySQL Database**

### Error Handling

- [Async Wrapper](https://github.com/klasikh/node_api_mysql/blob/main/src/middlewares/tryCatchWrapper.js): `src/middlewares/tryCatchWrapper.js`
- [Custom Errors](https://github.com/klasikh/node_api_mysql/blob/main/src/errors/customErrors.js): `src/errors/customErrors.js`
- [Not Found](https://github.com/klasikh/node_api_mysql/blob/main/src/middlewares/notFound.js): `src/middlewares/notFound.js`
- [Error Handler](https://github.com/klasikh/node_api_mysql/blob/main/src/middlewares/handleError.js): `src/middlewares/handleError.js`

### Other components

- **API Client**

## Connections

- API Client → Express App: sends requests (evidence: `app.js`)
- Express App → Notes Routes: mounts at /notes (evidence: `app.js`)
- Notes Routes → Notes CRUD: dispatches handlers (evidence: `src/resources/notes/notes.routes.js`)
- Notes CRUD → MySQL Pool: queries notes (evidence: `src/resources/notes/notes.controllers.js`)
- MySQL Pool → MySQL Database: configures connection (evidence: `src/db/connect.js`)
- Notes CRUD → Async Wrapper: wraps handlers (evidence: `src/resources/notes/notes.controllers.js`)
- Async Wrapper → Custom Errors: creates errors (evidence: `src/middlewares/tryCatchWrapper.js`)
- Notes CRUD → Custom Errors: creates errors (evidence: `src/resources/notes/notes.controllers.js`)
- Error Handler → Custom Errors: checks error type (evidence: `src/middlewares/handleError.js`)
- Express App → Not Found: registers fallback (evidence: `app.js`)
- Express App → Error Handler: registers handler (evidence: `app.js`)
