# hsnkh12/json-database-library architecture

> Architecture diagram of the GitHub repository hsnkh12/json-database-library, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hsnkh12/json-database-library
- Repository: https://github.com/hsnkh12/json-database-library

## Overview

##### Project type and purpose
- This is a .NET library (JSONDatabaseManager) that implements an ORM-style wrapper around JSON files on disk.
- It exposes a simple API (JsonDatabase, Document, DataItem) to perform CRUD operations, commit changes, and run queries without a relational DB.
- There’s also a small sample/CLI entry point (Program.cs) and a test project.

##### File structure
- Top-level files:
- JSONDatabaseManager.csproj – .NET project file.
- Program.cs – example usage/CLI.
- README.md – documentation.
- Core/ – the heart of the library:
- JsonDatabase.cs – manages the database volume (folder, name, password).
- Document.cs – manages a single “table” (document) in memory.
- DataItem.cs – represents a single record (row) with an ID and data dictionary.
- DataBaseConfigurations.cs & DocumentConfigurations.cs – metadata/configuration.
- Tests/ – unit tests covering operations on JsonDatabase and Document.

##### README for additional insights
- Describes the workflow: Init disk, Create/Get document, Insert/Update/Delete, Commit, Query.

##### Elements
- Clear labels:
- “Client Application”
- “JsonDatabase” (include Init, Create/Get Document methods)
- “Document” (Insert, Update, Delete, Query, Commit)
- “DataItem” (ID + Data dictionary)
- “Disk Storage” (JSON files per document)
- “Configurations”
- “.NET Runtime”
- Client → JsonDatabase → Document → File System
- Document → DataItem (composition)
- Commit → File System (write)
- Init/Sync → File System (read)
- Query → DataItem collection
- Blue rectangles for library modules.

##### Detailed capture of essential elements
- Don’t just show one block; break the library into its submodules.
- Both read path (Init/SyncFromDisk) and write path (CommitChanges).
- How configurations influence folder structure and JSON schema.
- Asynchronous calls on I/O operations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Runtime[".NET Runtime"]:::runtime
    ProjDef["Project Definition (.csproj)"]:::library
    Client["Client Application"]:::client
    JsonDB["JsonDatabase"]:::library
    DBConfig["DataBaseConfigurations"]:::library
    DocConfig["DocumentConfigurations"]:::library
    DocMgr["Document"]:::library
    DataItem["DataItem"]:::library
    Disk["Disk Storage (JSON Files)"]:::storage
    Tests["Test Suite"]:::test
    Docs["Documentation (README.md)"]:::doc

    Runtime --> ProjDef
    Client -->|"calls Init/Create/Get"| JsonDB
    JsonDB -->|"uses configurations"| DBConfig
    JsonDB --> DBConfig
    JsonDB --> DocConfig
    JsonDB -->|"manages"| DocMgr
    DocMgr -->|"composes"| DataItem
    DocMgr -->|"reads/writes"| Disk
    DocMgr -->|"queries"| DataItem
    Tests -.-> JsonDB
    Tests -.-> DocMgr

    click Client "https://github.com/hsnkh12/json-database-library/blob/main/Program.cs"
    click JsonDB "https://github.com/hsnkh12/json-database-library/blob/main/Core/JsonDatabase.cs"
    click DocMgr "https://github.com/hsnkh12/json-database-library/blob/main/Core/Document.cs"
    click DataItem "https://github.com/hsnkh12/json-database-library/blob/main/Core/DataItem.cs"
    click DBConfig "https://github.com/hsnkh12/json-database-library/blob/main/Core/DataBaseConfigurations.cs"
    click DocConfig "https://github.com/hsnkh12/json-database-library/blob/main/Core/DocumentConfigurations.cs"
    click ProjDef "https://github.com/hsnkh12/json-database-library/blob/main/JSONDatabaseManager.csproj"
    click Tests "https://github.com/hsnkh12/json-database-library/blob/main/Tests/Tests.cs"
    click Docs "https://github.com/hsnkh12/json-database-library/blob/main/README.md"

    classDef runtime fill:#ccc,stroke:#333,stroke-width:1px
    classDef client fill:#f96,stroke:#333,stroke-width:1px
    classDef library fill:#bbf,stroke:#333,stroke-width:1px
    classDef storage fill:#9f9,stroke:#333,stroke-width:1px,shape:cylinder
    classDef test fill:#eee,stroke-dasharray: 5 5,stroke:#333
    classDef doc fill:#ffc,stroke:#333,stroke-width:1px
```
