# dizonds/ashcolinventory_backend_final architecture

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

## Overview

This is an Express and MongoDB backend for branch-based inventory management. Staff sign in, then use authenticated API routes to manage catalog records, stock movements and transfers, material requests, and branch-directory data; stock changes are recorded in an auditable ledger. The sampled startup code connects to MongoDB, initializes database requirements, and starts the API. The README is empty, and some route excerpts are partial, so the graph preserves documented-by-code capabilities but omits unshown implementation details and unsupported links.

Main entry points: [`src/models.js`](https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/models.js) (Domain models), [`src/app.js`](https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/app.js) (HTTP API), [`src/auth.js`](https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/auth.js) (Authentication), [`src/routes/inventory.js`](https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/routes/inventory.js) (Inventory routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["API runtime"]
  node_server["Server startup<br/>[index.js]"]
  node_api["HTTP API<br/>[app.js]"]
end

subgraph group_identity["Identity and access"]
  node_auth["Authentication<br/>[auth.js]"]
end

subgraph group_inventory["Inventory operations"]
  node_catalog["Inventory routes<br/>[inventory.js]"]
  node_requests["Material requests<br/>[requests.js]"]
  node_helpers["Inventory helpers<br/>[helpers.js]"]
end

subgraph group_directory["Branch directory"]
  node_directory["Directory routes<br/>[directory.js]"]
end

subgraph group_persistence["Persistence"]
  node_models["Domain models<br/>[models.js]"]
  node_mongo[("MongoDB")]
end

node_staff(("Staff user"))

node_staff -->|"sends API requests"| node_api
node_server -->|"connects to"| node_mongo
node_server -->|"starts"| node_api
node_server -->|"initializes indexes"| node_models
node_api -->|"routes authentication"| node_auth
node_api -->|"mounts routes"| node_directory
node_api -->|"mounts routes"| node_catalog
node_api -->|"mounts routes"| node_requests
node_auth -->|"reads and writes"| node_models
node_auth -->|"validates inputs"| node_helpers
node_directory -->|"reads and writes"| node_models
node_directory -->|"hashes passwords"| node_auth
node_catalog -->|"reads and writes"| node_models
node_catalog -->|"uses stock operations"| node_helpers
node_catalog -->|"checks permissions"| node_auth
node_requests -->|"reads and writes"| node_models
node_requests -->|"uses stock operations"| node_helpers
node_requests -->|"checks permissions"| node_auth
node_helpers -->|"records stock movements"| node_models
node_models -.->|"persists domain data"| node_mongo

click node_server "https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/index.js"
click node_api "https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/app.js"
click node_auth "https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/auth.js"
click node_directory "https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/routes/directory.js"
click node_catalog "https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/routes/inventory.js"
click node_requests "https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/routes/requests.js"
click node_helpers "https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/helpers.js"
click node_models "https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/models.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_api,node_staff toneBlue
class node_auth toneAmber
class node_catalog,node_requests,node_helpers toneMint
class node_directory toneRose
class node_models,node_mongo toneIndigo
```

## Components

### API runtime

- [Server startup](https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/index.js): `src/index.js`
- [HTTP API](https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/app.js): `src/app.js`

### Identity and access

- [Authentication](https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/auth.js): `src/auth.js`

### Inventory operations

- [Inventory routes](https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/routes/inventory.js): `src/routes/inventory.js`
- [Material requests](https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/routes/requests.js): `src/routes/requests.js`
- [Inventory helpers](https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/helpers.js): `src/helpers.js`

### Branch directory

- [Directory routes](https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/routes/directory.js): `src/routes/directory.js`

### Persistence

- [Domain models](https://github.com/dizonds/ashcolinventory_backend_final/blob/main/src/models.js): `src/models.js`
- **MongoDB**

### Other components

- **Staff user**

## Connections

- Staff user → HTTP API: sends API requests (evidence: `src/app.js`)
- Server startup → MongoDB: connects to (evidence: `src/index.js`)
- Server startup → HTTP API: starts (evidence: `src/index.js`)
- Server startup → Domain models: initializes indexes
- HTTP API → Authentication: routes authentication (evidence: `src/app.js`)
- HTTP API → Directory routes: mounts routes (evidence: `src/app.js`)
- HTTP API → Inventory routes: mounts routes (evidence: `src/app.js`)
- HTTP API → Material requests: mounts routes (evidence: `src/app.js`)
- Authentication → Domain models: reads and writes (evidence: `src/auth.js`)
- Authentication → Inventory helpers: validates inputs (evidence: `src/auth.js`)
- Directory routes → Domain models: reads and writes (evidence: `src/routes/directory.js`)
- Directory routes → Authentication: hashes passwords (evidence: `src/routes/directory.js`)
- Inventory routes → Domain models: reads and writes (evidence: `src/routes/inventory.js`)
- Inventory routes → Inventory helpers: uses stock operations (evidence: `src/routes/inventory.js`)
- Inventory routes → Authentication: checks permissions (evidence: `src/routes/inventory.js`)
- Material requests → Domain models: reads and writes (evidence: `src/routes/requests.js`)
- Material requests → Inventory helpers: uses stock operations (evidence: `src/routes/requests.js`)
- Material requests → Authentication: checks permissions (evidence: `src/routes/requests.js`)
- Inventory helpers → Domain models: records stock movements (evidence: `src/helpers.js`)
- Domain models → MongoDB: persists domain data
