# haidermoe/project architecture

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

- Interactive diagram: https://gitdiagram.com/haidermoe/project
- Repository: https://github.com/haidermoe/project

## Overview

This is a restaurant and kitchen operations web application: staff use browser-based modules for point of sale, inventory, recipes, purchasing, kitchen preparation, workforce management, and accounting, backed by an Express API. Authentication and role checks protect API routes; controllers implement domain operations against separately configured application, authentication, and HR database pools. The graph includes documented route/controller and source-reference relationships. Several domain modules are represented from the file tree and SOURCE INDEX, but their browser-to-API calls and internal behavior were not sampled, so those links are omitted.

Main entry points: [`database/appConnection.js`](https://github.com/haidermoe/project/blob/main/database/appConnection.js) (Operations database), [`auth/authRoutes.js`](https://github.com/haidermoe/project/blob/main/auth/authRoutes.js) (Auth routes), [`database/authConnection.js`](https://github.com/haidermoe/project/blob/main/database/authConnection.js) (Identity database), [`api/posRestaurantController.js`](https://github.com/haidermoe/project/blob/main/api/posRestaurantController.js) (Restaurant POS)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Staff interface"]
  node_dashboard["Dashboards<br/>[dashboard.js]"]
  node_inventory_ui["Inventory UI<br/>[inventory.js]"]
  node_manager_ui["Manager insights"]
  node_auth_ui["Login checks<br/>[auth-check.js]"]
end

subgraph group_identity["Identity and access"]
  node_auth_routes["Auth routes<br/>[authRoutes.js]"]
  node_auth_controller["Auth and users<br/>[authController.js]"]
  node_auth_middleware["JWT and roles<br/>[authMiddleware.js]"]
  node_security_middleware["Input security<br/>[security.js]"]
end

subgraph group_kitchen["Kitchen and stock"]
  node_recipe_controller["Recipes and production"]
  node_kitchen_controller["Kitchen operations"]
  node_station_stock["Station stock"]
  node_print_service["Print routing"]
  node_inventory_controller["Inventory"]
end

subgraph group_business["Restaurant operations"]
  node_accounting["Accounting"]
  node_pos["Restaurant POS"]
  node_purchasing["Purchasing"]
  node_workforce["HR and attendance<br/>[hrController.js]"]
  node_leaves["Leave management"]
  node_notifications["Notifications"]
end

subgraph group_platform["API and data"]
  node_cache["Response cache<br/>[cacheService.js]"]
  node_server["Express server<br/>[server.js]"]
  node_app_db[("Operations database<br/>[appConnection.js]")]
  node_auth_db[("Identity database<br/>[authConnection.js]")]
  node_hr_db[("HR database<br/>[hrConnection.js]")]
  node_db_config["Database config<br/>[database.js]"]
end

node_staff(("Staff"))

node_staff -.->|"uses"| node_dashboard
node_staff -.->|"uses"| node_inventory_ui
node_server -->|"mounts"| node_auth_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_routes -->|"guards"| node_auth_middleware
node_auth_routes -->|"validates"| node_security_middleware
node_auth_controller -->|"queries"| node_auth_db
node_auth_ui -.->|"checks session"| node_auth_routes
node_server -->|"tests connection"| node_app_db
node_server -->|"tests connection"| node_auth_db
node_server -->|"tests connection"| node_hr_db
node_app_db -->|"loads settings"| node_db_config
node_auth_db -->|"loads settings"| node_db_config
node_hr_db -->|"loads settings"| node_db_config
node_recipe_controller -->|"queries"| node_app_db
node_kitchen_controller -->|"queries"| node_app_db
node_kitchen_controller -->|"looks up managers"| node_auth_db
node_kitchen_controller -->|"creates alerts"| node_notifications
node_inventory_controller -->|"queries"| node_app_db
node_inventory_controller -->|"uses"| node_station_stock
node_accounting -->|"queries"| node_app_db
node_accounting -->|"uses"| node_cache
node_pos -->|"queries"| node_app_db
node_pos -->|"routes printing"| node_print_service
node_pos -->|"uses"| node_station_stock
node_pos -->|"uses"| node_cache
node_purchasing -->|"queries"| node_app_db
node_notifications -->|"queries"| node_app_db
node_notifications -->|"queries"| node_auth_db
node_workforce -.->|"uses"| node_hr_db
node_leaves -.->|"uses"| node_hr_db

click node_dashboard "https://github.com/haidermoe/project/blob/main/LOGIN/public/dashboard/dashboard.js"
click node_inventory_ui "https://github.com/haidermoe/project/blob/main/LOGIN/public/inventory.js"
click node_manager_ui "https://github.com/haidermoe/project/blob/main/LOGIN/public/manager-insights.js"
click node_auth_ui "https://github.com/haidermoe/project/blob/main/LOGIN/public/common/auth-check.js"
click node_auth_routes "https://github.com/haidermoe/project/blob/main/auth/authRoutes.js"
click node_auth_controller "https://github.com/haidermoe/project/blob/main/auth/authController.js"
click node_auth_middleware "https://github.com/haidermoe/project/blob/main/auth/authMiddleware.js"
click node_security_middleware "https://github.com/haidermoe/project/blob/main/middleware/security.js"
click node_recipe_controller "https://github.com/haidermoe/project/blob/main/api/recipesController.js"
click node_kitchen_controller "https://github.com/haidermoe/project/blob/main/api/kitchenOperationsController.js"
click node_station_stock "https://github.com/haidermoe/project/blob/main/api/stationStockService.js"
click node_print_service "https://github.com/haidermoe/project/blob/main/api/printRoutingService.js"
click node_inventory_controller "https://github.com/haidermoe/project/blob/main/api/inventoryController.js"
click node_accounting "https://github.com/haidermoe/project/blob/main/api/accountingController.js"
click node_pos "https://github.com/haidermoe/project/blob/main/api/posRestaurantController.js"
click node_purchasing "https://github.com/haidermoe/project/blob/main/api/purchaseController.js"
click node_workforce "https://github.com/haidermoe/project/blob/main/api/hrController.js"
click node_leaves "https://github.com/haidermoe/project/blob/main/api/leavesController.js"
click node_notifications "https://github.com/haidermoe/project/blob/main/api/notificationsController.js"
click node_cache "https://github.com/haidermoe/project/blob/main/api/cacheService.js"
click node_server "https://github.com/haidermoe/project/blob/main/server.js"
click node_app_db "https://github.com/haidermoe/project/blob/main/database/appConnection.js"
click node_auth_db "https://github.com/haidermoe/project/blob/main/database/authConnection.js"
click node_hr_db "https://github.com/haidermoe/project/blob/main/database/hrConnection.js"
click node_db_config "https://github.com/haidermoe/project/blob/main/config/database.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_dashboard,node_inventory_ui,node_manager_ui,node_auth_ui toneBlue
class node_auth_routes,node_auth_controller,node_auth_middleware,node_security_middleware toneAmber
class node_recipe_controller,node_kitchen_controller,node_station_stock,node_print_service,node_inventory_controller toneMint
class node_accounting,node_pos,node_purchasing,node_workforce,node_leaves,node_notifications toneRose
class node_cache,node_server,node_app_db,node_auth_db,node_hr_db,node_db_config,node_staff toneIndigo
```

## Components

### Staff interface

- [Dashboards](https://github.com/haidermoe/project/blob/main/LOGIN/public/dashboard/dashboard.js): `LOGIN/public/dashboard/dashboard.js`
- [Inventory UI](https://github.com/haidermoe/project/blob/main/LOGIN/public/inventory.js): `LOGIN/public/inventory.js`
- [Manager insights](https://github.com/haidermoe/project/blob/main/LOGIN/public/manager-insights.js): `LOGIN/public/manager-insights.js`
- [Login checks](https://github.com/haidermoe/project/blob/main/LOGIN/public/common/auth-check.js): `LOGIN/public/common/auth-check.js`

### Identity and access

- [Auth routes](https://github.com/haidermoe/project/blob/main/auth/authRoutes.js): `auth/authRoutes.js`
- [Auth and users](https://github.com/haidermoe/project/blob/main/auth/authController.js): `auth/authController.js`
- [JWT and roles](https://github.com/haidermoe/project/blob/main/auth/authMiddleware.js): `auth/authMiddleware.js`
- [Input security](https://github.com/haidermoe/project/blob/main/middleware/security.js): `middleware/security.js`

### Kitchen and stock

- [Recipes and production](https://github.com/haidermoe/project/blob/main/api/recipesController.js): `api/recipesController.js`
- [Kitchen operations](https://github.com/haidermoe/project/blob/main/api/kitchenOperationsController.js): `api/kitchenOperationsController.js`
- [Station stock](https://github.com/haidermoe/project/blob/main/api/stationStockService.js): `api/stationStockService.js`
- [Print routing](https://github.com/haidermoe/project/blob/main/api/printRoutingService.js): `api/printRoutingService.js`
- [Inventory](https://github.com/haidermoe/project/blob/main/api/inventoryController.js): `api/inventoryController.js`

### Restaurant operations

- [Accounting](https://github.com/haidermoe/project/blob/main/api/accountingController.js): `api/accountingController.js`
- [Restaurant POS](https://github.com/haidermoe/project/blob/main/api/posRestaurantController.js): `api/posRestaurantController.js`
- [Purchasing](https://github.com/haidermoe/project/blob/main/api/purchaseController.js): `api/purchaseController.js`
- [HR and attendance](https://github.com/haidermoe/project/blob/main/api/hrController.js): `api/hrController.js`
- [Leave management](https://github.com/haidermoe/project/blob/main/api/leavesController.js): `api/leavesController.js`
- [Notifications](https://github.com/haidermoe/project/blob/main/api/notificationsController.js): `api/notificationsController.js`

### API and data

- [Response cache](https://github.com/haidermoe/project/blob/main/api/cacheService.js): `api/cacheService.js`
- [Express server](https://github.com/haidermoe/project/blob/main/server.js): `server.js`
- [Operations database](https://github.com/haidermoe/project/blob/main/database/appConnection.js): `database/appConnection.js`
- [Identity database](https://github.com/haidermoe/project/blob/main/database/authConnection.js): `database/authConnection.js`
- [HR database](https://github.com/haidermoe/project/blob/main/database/hrConnection.js): `database/hrConnection.js`
- [Database config](https://github.com/haidermoe/project/blob/main/config/database.js): `config/database.js`

### Other components

- **Staff**

## Connections

- Staff → Dashboards: uses
- Staff → Inventory UI: uses
- Express server → Auth routes: mounts (evidence: `server.js`)
- Auth routes → Auth and users: dispatches (evidence: `auth/authRoutes.js`)
- Auth routes → JWT and roles: guards (evidence: `auth/authRoutes.js`)
- Auth routes → Input security: validates (evidence: `auth/authRoutes.js`)
- Auth and users → Identity database: queries (evidence: `auth/authController.js`)
- Login checks → Auth routes: checks session
- Express server → Operations database: tests connection (evidence: `server.js`)
- Express server → Identity database: tests connection (evidence: `server.js`)
- Express server → HR database: tests connection (evidence: `server.js`)
- Operations database → Database config: loads settings (evidence: `database/appConnection.js`)
- Identity database → Database config: loads settings (evidence: `database/authConnection.js`)
- HR database → Database config: loads settings (evidence: `database/hrConnection.js`)
- Recipes and production → Operations database: queries (evidence: `api/recipesController.js`)
- Kitchen operations → Operations database: queries (evidence: `api/kitchenOperationsController.js`)
- Kitchen operations → Identity database: looks up managers (evidence: `api/kitchenOperationsController.js`)
- Kitchen operations → Notifications: creates alerts (evidence: `api/kitchenOperationsController.js`)
- Inventory → Operations database: queries (evidence: `api/inventoryController.js`)
- Inventory → Station stock: uses (evidence: `api/inventoryController.js`)
- Accounting → Operations database: queries (evidence: `api/accountingController.js`)
- Accounting → Response cache: uses (evidence: `api/accountingController.js`)
- Restaurant POS → Operations database: queries (evidence: `api/posRestaurantController.js`)
- Restaurant POS → Print routing: routes printing (evidence: `api/posRestaurantController.js`)
- Restaurant POS → Station stock: uses (evidence: `api/posRestaurantController.js`)
- Restaurant POS → Response cache: uses (evidence: `api/posRestaurantController.js`)
- Purchasing → Operations database: queries (evidence: `api/purchaseController.js`)
- Notifications → Operations database: queries (evidence: `api/notificationsController.js`)
- Notifications → Identity database: queries (evidence: `api/notificationsController.js`)
- HR and attendance → HR database: uses
- Leave management → HR database: uses
