# shigosag/apexsuite architecture

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

## Overview

ApexSuite is a multi-branch business-management SPA backed by an Express REST API and PostgreSQL. Users navigate the client modules, whose API service sends requests to the server; routes apply authentication and role checks before controllers perform domain operations and return results. The main product stages are POS checkout, inventory, CRM, finance, and AI analysis, with authentication and scheduled alerts supporting them. The graph includes documented capabilities where source was not sampled; those internal links are omitted when no cited call or README relationship establishes them.

Main entry points: [`server/src/database/connection.js`](https://github.com/shigosag/apexsuite/blob/main/server/src/database/connection.js) (PostgreSQL), [`server/src/routes/apiRouter.js`](https://github.com/shigosag/apexsuite/blob/main/server/src/routes/apiRouter.js) (API router), [`server/src/middleware/authMiddleware.js`](https://github.com/shigosag/apexsuite/blob/main/server/src/middleware/authMiddleware.js) (Access and roles), [`server/index.js`](https://github.com/shigosag/apexsuite/blob/main/server/index.js) (HTTP server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_spa["SPA navigation<br/>[main.js]"]
  node_ui["Business pages"]
  node_api_client["REST client<br/>[apiService.js]"]
end

subgraph group_api["API and security"]
  node_express["HTTP server<br/>[index.js]"]
  node_router["API router<br/>[apiRouter.js]"]
  node_auth_routes["Auth routes<br/>[authRoutes.js]"]
  node_auth_controller["Authentication<br/>[authController.js]"]
  node_auth_service["Token and account service<br/>[authService.js]"]
  node_auth_middleware["Access and roles<br/>[authMiddleware.js]"]
  node_pos_routes["POS routes<br/>[posRoutes.js]"]
  node_inventory_routes["Inventory routes<br/>[inventoryRoutes.js]"]
  node_finance_routes["Finance routes<br/>[financeRoutes.js]"]
  node_crm_routes["CRM routes<br/>[crmRoutes.js]"]
end

subgraph group_domains["Business domains"]
  node_pos["Checkout and refunds<br/>[posController.js]"]
  node_orders["Order processing<br/>[orderRepository.js]"]
  node_inventory["Inventory and transfers"]
  node_inventory_repo["Inventory access"]
  node_crm["Customers and pipeline<br/>[crmController.js]"]
  node_finance["Finance and ledger"]
  node_finance_repo["Finance access"]
  node_ai["Strategy copilot<br/>[aiEngineService.js]"]
  node_pdf["PDF documents<br/>[pdfService.js]"]
  node_notifications["Notifications"]
end

subgraph group_platform["Data and operations"]
  node_db[("PostgreSQL<br/>[connection.js]")]
  node_jobs["Scheduled alerts<br/>[cronTasks.js]"]
  node_migrations["Schema migrations<br/>[migrations.js]"]
end

node_user(("Workspace user"))

node_user -->|"uses"| node_spa
node_spa -->|"renders"| node_ui
node_ui -->|"requests data"| node_api_client
node_api_client -->|"calls REST API"| node_express
node_express -->|"mounts API"| node_router
node_router -->|"mounts"| node_auth_routes
node_router -->|"mounts"| node_pos_routes
node_router -->|"mounts"| node_inventory_routes
node_router -->|"mounts"| node_finance_routes
node_router -->|"mounts"| node_crm_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_controller -->|"delegates to"| node_auth_service
node_auth_service -->|"reads and writes"| node_db
node_pos_routes -->|"checks access"| node_auth_middleware
node_inventory_routes -->|"checks access"| node_auth_middleware
node_finance_routes -->|"checks access"| node_auth_middleware
node_crm_routes -->|"checks access"| node_auth_middleware
node_auth_middleware -->|"verifies identity"| node_db
node_pos_routes -->|"dispatches"| node_pos
node_inventory_routes -->|"dispatches"| node_inventory
node_finance_routes -->|"dispatches"| node_finance
node_crm_routes -->|"dispatches"| node_crm
node_pos -->|"creates checkout"| node_orders
node_orders -->|"updates stock and ledgers"| node_db
node_pos -->|"generates receipt"| node_pdf
node_inventory -->|"delegates stock access"| node_inventory_repo
node_inventory -->|"transfers and manages"| node_db
node_inventory_repo -->|"queries"| node_db
node_crm -->|"manages customers and deals"| node_db
node_finance -->|"delegates summaries"| node_finance_repo
node_finance -->|"records payments and ledgers"| node_db
node_finance_repo -->|"queries"| node_db
node_ai -->|"analyzes business data"| node_db
node_express -->|"runs at startup"| node_migrations
node_express -->|"starts scheduler"| node_jobs
node_jobs -->|"checks stock and invoices"| node_db
node_jobs -->|"creates alerts"| node_notifications
node_migrations -->|"initializes schema"| node_db

click node_spa "https://github.com/shigosag/apexsuite/blob/main/client/src/main.js"
click node_ui "https://github.com/shigosag/apexsuite/tree/main/client/src/pages"
click node_api_client "https://github.com/shigosag/apexsuite/blob/main/client/src/services/apiService.js"
click node_express "https://github.com/shigosag/apexsuite/blob/main/server/index.js"
click node_router "https://github.com/shigosag/apexsuite/blob/main/server/src/routes/apiRouter.js"
click node_auth_routes "https://github.com/shigosag/apexsuite/blob/main/server/src/routes/authRoutes.js"
click node_auth_controller "https://github.com/shigosag/apexsuite/blob/main/server/src/controllers/authController.js"
click node_auth_service "https://github.com/shigosag/apexsuite/blob/main/server/src/services/authService.js"
click node_auth_middleware "https://github.com/shigosag/apexsuite/blob/main/server/src/middleware/authMiddleware.js"
click node_pos_routes "https://github.com/shigosag/apexsuite/blob/main/server/src/routes/posRoutes.js"
click node_inventory_routes "https://github.com/shigosag/apexsuite/blob/main/server/src/routes/inventoryRoutes.js"
click node_finance_routes "https://github.com/shigosag/apexsuite/blob/main/server/src/routes/financeRoutes.js"
click node_crm_routes "https://github.com/shigosag/apexsuite/blob/main/server/src/routes/crmRoutes.js"
click node_pos "https://github.com/shigosag/apexsuite/blob/main/server/src/controllers/posController.js"
click node_orders "https://github.com/shigosag/apexsuite/blob/main/server/src/repositories/orderRepository.js"
click node_inventory "https://github.com/shigosag/apexsuite/blob/main/server/src/controllers/inventoryController.js"
click node_inventory_repo "https://github.com/shigosag/apexsuite/blob/main/server/src/repositories/inventoryRepository.js"
click node_crm "https://github.com/shigosag/apexsuite/blob/main/server/src/controllers/crmController.js"
click node_finance "https://github.com/shigosag/apexsuite/blob/main/server/src/controllers/financeController.js"
click node_finance_repo "https://github.com/shigosag/apexsuite/blob/main/server/src/repositories/financeRepository.js"
click node_ai "https://github.com/shigosag/apexsuite/blob/main/server/src/services/aiEngineService.js"
click node_pdf "https://github.com/shigosag/apexsuite/blob/main/server/src/services/pdfService.js"
click node_db "https://github.com/shigosag/apexsuite/blob/main/server/src/database/connection.js"
click node_jobs "https://github.com/shigosag/apexsuite/blob/main/server/src/jobs/cronTasks.js"
click node_migrations "https://github.com/shigosag/apexsuite/blob/main/server/src/database/migrations.js"
click node_notifications "https://github.com/shigosag/apexsuite/blob/main/server/src/services/notificationService.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_spa,node_ui,node_api_client,node_user toneBlue
class node_express,node_router,node_auth_routes,node_auth_controller,node_auth_service,node_auth_middleware,node_pos_routes,node_inventory_routes,node_finance_routes,node_crm_routes toneAmber
class node_pos,node_orders,node_inventory,node_inventory_repo,node_crm,node_finance,node_finance_repo,node_ai,node_pdf,node_notifications toneMint
class node_db,node_jobs,node_migrations toneRose
```

## Components

### Web application

- [SPA navigation](https://github.com/shigosag/apexsuite/blob/main/client/src/main.js): `client/src/main.js`
- [Business pages](https://github.com/shigosag/apexsuite/tree/main/client/src/pages): `client/src/pages`
- [REST client](https://github.com/shigosag/apexsuite/blob/main/client/src/services/apiService.js): `client/src/services/apiService.js`

### API and security

- [HTTP server](https://github.com/shigosag/apexsuite/blob/main/server/index.js): `server/index.js`
- [API router](https://github.com/shigosag/apexsuite/blob/main/server/src/routes/apiRouter.js): `server/src/routes/apiRouter.js`
- [Auth routes](https://github.com/shigosag/apexsuite/blob/main/server/src/routes/authRoutes.js): `server/src/routes/authRoutes.js`
- [Authentication](https://github.com/shigosag/apexsuite/blob/main/server/src/controllers/authController.js): `server/src/controllers/authController.js`
- [Token and account service](https://github.com/shigosag/apexsuite/blob/main/server/src/services/authService.js): `server/src/services/authService.js`
- [Access and roles](https://github.com/shigosag/apexsuite/blob/main/server/src/middleware/authMiddleware.js): `server/src/middleware/authMiddleware.js`
- [POS routes](https://github.com/shigosag/apexsuite/blob/main/server/src/routes/posRoutes.js): `server/src/routes/posRoutes.js`
- [Inventory routes](https://github.com/shigosag/apexsuite/blob/main/server/src/routes/inventoryRoutes.js): `server/src/routes/inventoryRoutes.js`
- [Finance routes](https://github.com/shigosag/apexsuite/blob/main/server/src/routes/financeRoutes.js): `server/src/routes/financeRoutes.js`
- [CRM routes](https://github.com/shigosag/apexsuite/blob/main/server/src/routes/crmRoutes.js): `server/src/routes/crmRoutes.js`

### Business domains

- [Checkout and refunds](https://github.com/shigosag/apexsuite/blob/main/server/src/controllers/posController.js): `server/src/controllers/posController.js`
- [Order processing](https://github.com/shigosag/apexsuite/blob/main/server/src/repositories/orderRepository.js): `server/src/repositories/orderRepository.js`
- [Inventory and transfers](https://github.com/shigosag/apexsuite/blob/main/server/src/controllers/inventoryController.js): `server/src/controllers/inventoryController.js`
- [Inventory access](https://github.com/shigosag/apexsuite/blob/main/server/src/repositories/inventoryRepository.js): `server/src/repositories/inventoryRepository.js`
- [Customers and pipeline](https://github.com/shigosag/apexsuite/blob/main/server/src/controllers/crmController.js): `server/src/controllers/crmController.js`
- [Finance and ledger](https://github.com/shigosag/apexsuite/blob/main/server/src/controllers/financeController.js): `server/src/controllers/financeController.js`
- [Finance access](https://github.com/shigosag/apexsuite/blob/main/server/src/repositories/financeRepository.js): `server/src/repositories/financeRepository.js`
- [Strategy copilot](https://github.com/shigosag/apexsuite/blob/main/server/src/services/aiEngineService.js): `server/src/services/aiEngineService.js`
- [PDF documents](https://github.com/shigosag/apexsuite/blob/main/server/src/services/pdfService.js): `server/src/services/pdfService.js`
- [Notifications](https://github.com/shigosag/apexsuite/blob/main/server/src/services/notificationService.js): `server/src/services/notificationService.js`

### Data and operations

- [PostgreSQL](https://github.com/shigosag/apexsuite/blob/main/server/src/database/connection.js): `server/src/database/connection.js`
- [Scheduled alerts](https://github.com/shigosag/apexsuite/blob/main/server/src/jobs/cronTasks.js): `server/src/jobs/cronTasks.js`
- [Schema migrations](https://github.com/shigosag/apexsuite/blob/main/server/src/database/migrations.js): `server/src/database/migrations.js`

### Other components

- **Workspace user**

## Connections

- Workspace user → SPA navigation: uses (evidence: `README.md`)
- SPA navigation → Business pages: renders (evidence: `README.md`)
- Business pages → REST client: requests data (evidence: `README.md`)
- REST client → HTTP server: calls REST API (evidence: `README.md`)
- HTTP server → API router: mounts API (evidence: `server/index.js`)
- API router → Auth routes: mounts (evidence: `server/src/routes/apiRouter.js`)
- API router → POS routes: mounts (evidence: `server/src/routes/apiRouter.js`)
- API router → Inventory routes: mounts (evidence: `server/src/routes/apiRouter.js`)
- API router → Finance routes: mounts (evidence: `server/src/routes/apiRouter.js`)
- API router → CRM routes: mounts (evidence: `server/src/routes/apiRouter.js`)
- Auth routes → Authentication: dispatches (evidence: `server/src/routes/authRoutes.js`)
- Authentication → Token and account service: delegates to (evidence: `server/src/controllers/authController.js`)
- Token and account service → PostgreSQL: reads and writes (evidence: `server/src/services/authService.js`)
- POS routes → Access and roles: checks access (evidence: `server/src/routes/posRoutes.js`)
- Inventory routes → Access and roles: checks access (evidence: `server/src/routes/inventoryRoutes.js`)
- Finance routes → Access and roles: checks access (evidence: `server/src/routes/financeRoutes.js`)
- CRM routes → Access and roles: checks access (evidence: `server/src/routes/crmRoutes.js`)
- Access and roles → PostgreSQL: verifies identity (evidence: `server/src/middleware/authMiddleware.js`)
- POS routes → Checkout and refunds: dispatches (evidence: `server/src/routes/posRoutes.js`)
- Inventory routes → Inventory and transfers: dispatches (evidence: `server/src/routes/inventoryRoutes.js`)
- Finance routes → Finance and ledger: dispatches (evidence: `server/src/routes/financeRoutes.js`)
- CRM routes → Customers and pipeline: dispatches (evidence: `server/src/routes/crmRoutes.js`)
- Checkout and refunds → Order processing: creates checkout (evidence: `server/src/controllers/posController.js`)
- Order processing → PostgreSQL: updates stock and ledgers (evidence: `server/src/repositories/orderRepository.js`)
- Checkout and refunds → PDF documents: generates receipt (evidence: `server/src/controllers/posController.js`)
- Inventory and transfers → Inventory access: delegates stock access (evidence: `server/src/controllers/inventoryController.js`)
- Inventory and transfers → PostgreSQL: transfers and manages (evidence: `server/src/controllers/inventoryController.js`)
- Inventory access → PostgreSQL: queries (evidence: `server/src/repositories/inventoryRepository.js`)
- Customers and pipeline → PostgreSQL: manages customers and deals (evidence: `server/src/controllers/crmController.js`)
- Finance and ledger → Finance access: delegates summaries (evidence: `server/src/controllers/financeController.js`)
- Finance and ledger → PostgreSQL: records payments and ledgers (evidence: `server/src/controllers/financeController.js`)
- Finance access → PostgreSQL: queries (evidence: `server/src/repositories/financeRepository.js`)
- Strategy copilot → PostgreSQL: analyzes business data (evidence: `server/src/services/aiEngineService.js`)
- HTTP server → Schema migrations: runs at startup (evidence: `server/index.js`)
- HTTP server → Scheduled alerts: starts scheduler (evidence: `server/index.js`)
- Scheduled alerts → PostgreSQL: checks stock and invoices (evidence: `server/src/jobs/cronTasks.js`)
- Scheduled alerts → Notifications: creates alerts (evidence: `server/src/jobs/cronTasks.js`)
- Schema migrations → PostgreSQL: initializes schema (evidence: `server/src/database/migrations.js`)
