# srushtionlinedev/globaliotplatform.backend architecture

> Architecture diagram of the GitHub repository srushtionlinedev/globaliotplatform.backend, 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/srushtionlinedev/globaliotplatform.backend
- Repository: https://github.com/srushtionlinedev/globaliotplatform.backend

## Overview

This is an Express/MySQL backend for a customer-scoped IoT platform. The main workflow registers customers and their initial owner, role, permissions, and login account; users then log in for a JWT and use it on protected APIs such as current-user lookup and product creation. Health checks are a separate capability. The README also describes schema and seed management, represented here as database structure rather than a deployment pipeline. Authentication and product call paths are supported by excerpts; some secondary repository details and the health call chain are supported only by the SOURCE INDEX.

Main entry points: [`src/services/auth.service.js`](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/services/auth.service.js) (Auth workflows), [`src/services/product.service.js`](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/services/product.service.js) (Product workflow), [`server.js`](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/server.js) (Express server), [`src/config/database.js`](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/config/database.js) (MySQL pool)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["Express server<br/>[server.js]"]
  node_auth_routes["Auth routes<br/>[auth.routes.js]"]
  node_auth_controller["Auth controller<br/>[auth.controller.js]"]
  node_auth_dto["Auth validation"]
  node_health_routes["Health routes<br/>[health.routes.js]"]
  node_health_controller["Health controller"]
  node_health_service["Health service<br/>[health.service.js]"]
  node_product_routes["Product routes<br/>[product.routes.js]"]
  node_product_controller["Product controller"]
  node_product_dto["Product validation"]
end

subgraph group_identity["Identity &amp; Access"]
  node_auth_middleware["JWT middleware<br/>[auth.middleware.js]"]
  node_jwt_util["JWT utility<br/>[jwt.util.js]"]
  node_jwt_config["JWT configuration<br/>[jwt.js]"]
  node_auth_service["Auth workflows<br/>[auth.service.js]"]
end

subgraph group_products["Product Management"]
  node_product_service["Product workflow<br/>[product.service.js]"]
end

subgraph group_persistence["Persistence"]
  node_auth_repositories["Identity repositories"]
  node_customer_repository["Customer repository"]
  node_user_repository["User repository<br/>[user.repository.js]"]
  node_db_pool[("MySQL pool<br/>[database.js]")]
  node_health_repository["Health repository"]
  node_product_repository["Product repository"]
  node_schema[("MySQL schema")]
  node_seeds["Reference seeds"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_server
node_server -->|"mounts auth"| node_auth_routes
node_server -->|"mounts health"| node_health_routes
node_server -->|"mounts products"| node_product_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_controller -->|"validates with"| node_auth_dto
node_auth_controller -->|"invokes"| node_auth_service
node_auth_routes -->|"protects current-user"| node_auth_middleware
node_auth_middleware -->|"verifies token"| node_jwt_util
node_jwt_util -->|"uses settings"| node_jwt_config
node_auth_service -->|"generates token"| node_jwt_util
node_auth_service -->|"gets connections"| node_db_pool
node_auth_service -->|"calls identity stores"| node_auth_repositories
node_auth_service -->|"creates customer"| node_customer_repository
node_auth_service -->|"creates and reads user"| node_user_repository
node_health_routes -->|"dispatches"| node_health_controller
node_health_controller -->|"invokes"| node_health_service
node_health_service -->|"calls"| node_health_repository
node_health_repository -->|"queries"| node_db_pool
node_product_routes -->|"protects creation"| node_auth_middleware
node_product_routes -->|"dispatches"| node_product_controller
node_product_controller -->|"validates with"| node_product_dto
node_product_controller -->|"invokes"| node_product_service
node_product_service -->|"gets connections"| node_db_pool
node_product_service -->|"looks up customer"| node_customer_repository
node_product_service -->|"looks up user"| node_user_repository
node_product_service -->|"creates product"| node_product_repository
node_schema -.->|"defines tables for"| node_db_pool
node_seeds -.->|"initializes reference data"| node_schema

click node_server "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/server.js"
click node_auth_routes "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/routes/auth.routes.js"
click node_auth_controller "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/controllers/auth.controller.js"
click node_auth_dto "https://github.com/srushtionlinedev/globaliotplatform.backend/tree/master/src/dto/auth"
click node_health_routes "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/routes/health.routes.js"
click node_health_controller "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/controllers/health.controller.js"
click node_auth_middleware "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/middleware/auth.middleware.js"
click node_jwt_util "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/utils/jwt.util.js"
click node_jwt_config "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/config/jwt.js"
click node_auth_service "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/services/auth.service.js"
click node_auth_repositories "https://github.com/srushtionlinedev/globaliotplatform.backend/tree/master/src/repositories/auth"
click node_customer_repository "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/repositories/customer/customer.repository.js"
click node_user_repository "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/repositories/user/user.repository.js"
click node_db_pool "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/config/database.js"
click node_health_service "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/services/health.service.js"
click node_health_repository "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/repositories/health.repository.js"
click node_product_routes "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/routes/product.routes.js"
click node_product_controller "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/controllers/product.controller.js"
click node_product_dto "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/dto/product/create-product.dto.js"
click node_product_service "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/services/product.service.js"
click node_product_repository "https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/repositories/product/product.repository.js"
click node_schema "https://github.com/srushtionlinedev/globaliotplatform.backend/tree/master/database/schema"
click node_seeds "https://github.com/srushtionlinedev/globaliotplatform.backend/tree/master/database/seed"

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_auth_routes,node_auth_controller,node_auth_dto,node_health_routes,node_health_controller,node_health_service,node_product_routes,node_product_controller,node_product_dto,node_client toneBlue
class node_auth_middleware,node_jwt_util,node_jwt_config,node_auth_service toneAmber
class node_product_service toneMint
class node_auth_repositories,node_customer_repository,node_user_repository,node_db_pool,node_health_repository,node_product_repository,node_schema,node_seeds toneRose
```

## Components

### HTTP API

- [Express server](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/server.js): `server.js`
- [Auth routes](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/routes/auth.routes.js): `src/routes/auth.routes.js`
- [Auth controller](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/controllers/auth.controller.js): `src/controllers/auth.controller.js`
- [Auth validation](https://github.com/srushtionlinedev/globaliotplatform.backend/tree/master/src/dto/auth): `src/dto/auth`
- [Health routes](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/routes/health.routes.js): `src/routes/health.routes.js`
- [Health controller](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/controllers/health.controller.js): `src/controllers/health.controller.js`
- [Health service](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/services/health.service.js): `src/services/health.service.js`
- [Product routes](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/routes/product.routes.js): `src/routes/product.routes.js`
- [Product controller](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/controllers/product.controller.js): `src/controllers/product.controller.js`
- [Product validation](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/dto/product/create-product.dto.js): `src/dto/product/create-product.dto.js`

### Identity & Access

- [JWT middleware](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/middleware/auth.middleware.js): `src/middleware/auth.middleware.js`
- [JWT utility](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/utils/jwt.util.js): `src/utils/jwt.util.js`
- [JWT configuration](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/config/jwt.js): `src/config/jwt.js`
- [Auth workflows](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/services/auth.service.js): `src/services/auth.service.js`

### Product Management

- [Product workflow](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/services/product.service.js): `src/services/product.service.js`

### Persistence

- [Identity repositories](https://github.com/srushtionlinedev/globaliotplatform.backend/tree/master/src/repositories/auth): `src/repositories/auth`
- [Customer repository](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/repositories/customer/customer.repository.js): `src/repositories/customer/customer.repository.js`
- [User repository](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/repositories/user/user.repository.js): `src/repositories/user/user.repository.js`
- [MySQL pool](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/config/database.js): `src/config/database.js`
- [Health repository](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/repositories/health.repository.js): `src/repositories/health.repository.js`
- [Product repository](https://github.com/srushtionlinedev/globaliotplatform.backend/blob/master/src/repositories/product/product.repository.js): `src/repositories/product/product.repository.js`
- [MySQL schema](https://github.com/srushtionlinedev/globaliotplatform.backend/tree/master/database/schema): `database/schema`
- [Reference seeds](https://github.com/srushtionlinedev/globaliotplatform.backend/tree/master/database/seed): `database/seed`

### Other components

- **API client**

## Connections

- API client → Express server: sends requests (evidence: `README.md`)
- Express server → Auth routes: mounts auth (evidence: `server.js`)
- Express server → Health routes: mounts health (evidence: `server.js`)
- Express server → Product routes: mounts products (evidence: `server.js`)
- Auth routes → Auth controller: dispatches (evidence: `src/routes/auth.routes.js`)
- Auth controller → Auth validation: validates with (evidence: `src/controllers/auth.controller.js`)
- Auth controller → Auth workflows: invokes (evidence: `src/controllers/auth.controller.js`)
- Auth routes → JWT middleware: protects current-user (evidence: `src/routes/auth.routes.js`)
- JWT middleware → JWT utility: verifies token (evidence: `src/middleware/auth.middleware.js`)
- JWT utility → JWT configuration: uses settings (evidence: `src/utils/jwt.util.js`)
- Auth workflows → JWT utility: generates token (evidence: `src/services/auth.service.js`)
- Auth workflows → MySQL pool: gets connections (evidence: `src/services/auth.service.js`)
- Auth workflows → Identity repositories: calls identity stores (evidence: `src/services/auth.service.js`)
- Auth workflows → Customer repository: creates customer (evidence: `src/services/auth.service.js`)
- Auth workflows → User repository: creates and reads user (evidence: `src/services/auth.service.js`)
- Health routes → Health controller: dispatches (evidence: `src/routes/health.routes.js`)
- Health controller → Health service: invokes (evidence: `src/controllers/health.controller.js`)
- Health service → Health repository: calls (evidence: `src/services/health.service.js`)
- Health repository → MySQL pool: queries (evidence: `src/repositories/health.repository.js`)
- Product routes → JWT middleware: protects creation (evidence: `src/routes/product.routes.js`)
- Product routes → Product controller: dispatches (evidence: `src/routes/product.routes.js`)
- Product controller → Product validation: validates with (evidence: `src/controllers/product.controller.js`)
- Product controller → Product workflow: invokes (evidence: `src/controllers/product.controller.js`)
- Product workflow → MySQL pool: gets connections (evidence: `src/services/product.service.js`)
- Product workflow → Customer repository: looks up customer (evidence: `src/services/product.service.js`)
- Product workflow → User repository: looks up user (evidence: `src/services/product.service.js`)
- Product workflow → Product repository: creates product (evidence: `src/services/product.service.js`)
- MySQL schema → MySQL pool: defines tables for (evidence: `README.md`)
- Reference seeds → MySQL schema: initializes reference data (evidence: `README.md`)
