# david-fernando/nodestorage architecture

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

- Interactive diagram: https://gitdiagram.com/david-fernando/nodestorage
- Repository: https://github.com/david-fernando/nodestorage

## Overview

NodeStorage is a small Node.js local-storage library. A caller creates a storage instance, which loads persisted items into memory; its methods read or update that state, while mutations write it back to a JSON file. The README documents the full browser-like API. The runtime is contained in one source file, so API and persistence responsibilities share that path.

Main entry points: [`index.js`](https://github.com/david-fernando/nodestorage/blob/main/index.js) (Storage API)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_caller(("Library caller"))
node_api["Storage API<br/>[index.js]"]
node_loader["Load items<br/>[index.js]"]
node_memory["In-memory items<br/>[index.js]"]
node_writer["Persist items<br/>[index.js]"]
node_store[("JSON file")]
node_filesystem["Node filesystem"]

node_caller -->|"creates instance"| node_api
node_api -->|"loads items"| node_loader
node_loader -->|"reads"| node_store
node_loader -->|"checks and reads"| node_filesystem
node_api -->|"exposes methods"| node_memory
node_api -->|"set/remove write"| node_writer
node_writer -->|"writes JSON"| node_store
node_writer -->|"writes file"| node_filesystem
node_api -->|"clear unlinks"| node_store
node_api -->|"unlinks file"| node_filesystem

click node_api "https://github.com/david-fernando/nodestorage/blob/main/index.js"
click node_loader "https://github.com/david-fernando/nodestorage/blob/main/index.js"
click node_memory "https://github.com/david-fernando/nodestorage/blob/main/index.js"
click node_writer "https://github.com/david-fernando/nodestorage/blob/main/index.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_caller,node_filesystem toneIndigo
class node_api,node_store toneAmber
class node_loader,node_memory,node_writer toneTeal
```

## Components

### Other components

- **Library caller**
- [Storage API](https://github.com/david-fernando/nodestorage/blob/main/index.js): `index.js`
- [Load items](https://github.com/david-fernando/nodestorage/blob/main/index.js): `index.js`
- [In-memory items](https://github.com/david-fernando/nodestorage/blob/main/index.js): `index.js`
- [Persist items](https://github.com/david-fernando/nodestorage/blob/main/index.js): `index.js`
- **JSON file**
- **Node filesystem**

## Connections

- Library caller → Storage API: creates instance (evidence: `README.md`)
- Storage API → Load items: loads items (evidence: `index.js`)
- Load items → JSON file: reads (evidence: `index.js`)
- Load items → Node filesystem: checks and reads (evidence: `index.js`)
- Storage API → In-memory items: exposes methods (evidence: `index.js`)
- Storage API → Persist items: set/remove write (evidence: `index.js`)
- Persist items → JSON file: writes JSON (evidence: `index.js`)
- Persist items → Node filesystem: writes file (evidence: `index.js`)
- Storage API → JSON file: clear unlinks (evidence: `index.js`)
- Storage API → Node filesystem: unlinks file (evidence: `index.js`)
