B o o t i n g
Blog Cover Projects

VDB (Viswath Database) NOSQL

 


πŸ“– What is VDB?

VDB (Viswath Database) is a lightweight, terminal-driven NoSQL system built on top of flat JSON files. It simulates a developer-friendly database using natural, shell-like commands via a browser-based terminal.

Unlike traditional databases, VDB is:

  • File-based and schema-less

  • Nested JSON-compatible

  • Backend-accessible through secure tokenized API

  • Interactive via CLI-style terminal


βš™οΈ How VDB Works

VDB stores your data inside individual .json files. These files behave like collections in a NoSQL database. All database logic (create, fetch, write, modify, delete) is performed on the server using pure PHP, with command input passed via AJAX from the terminal UI.

Main parts:

  • πŸ“‚ JSON file = Database (e.g. users.json, orders.json)

  • βš™οΈ PHP handles commands (via regex + file operations)

  • 🌐 AJAX frontend = terminal interface

  • 🧠 Supports nested JSON path access like user.profile.name


🧠 VDB Command Schemas

Below are the pure schemas (not examples) for each supported operation in VDB β€” all support dot notation for nested keys.


🧱 1. Create Database

vdb.create <db_name>

πŸ“Œ Creates a new JSON file as an empty array [].


πŸ’£ 2. Destroy Database

vdb.destroy <db_name>

🧨 Permanently deletes the .json file.


πŸ“ 3. Insert (Write) JSON Data

vdb.write into <db_name> (<valid_JSON_data>)

πŸ“₯ Appends a new JSON object to the file. The JSON must be enclosed in ().


πŸ“€ 4. Fetch All Records

vdb.fetch <db_name>

πŸ“€ Returns all JSON records in the selected file.


πŸ” 5. Fetch by Field (Supports Nested)

vdb.fetch where <field.path>="<match_value>" from <db_name>

πŸ”Ž Filters and returns records where the nested field matches the value.


✏️ 6. Modify (Update) Field Conditionally

vdb.modify <field.to.update>="<new_value>" where <field.to.match>="<match_value>" at <db_name>

✏️ Finds records matching a condition and updates a specific field β€” both support nesting.


πŸ—‘οΈ 7. Drop (Delete) Record Conditionally

vdb.drop where <field.to.match>="<value>" at <db_name>

πŸ—‘οΈ Removes all records where a nested field matches the given value.


πŸ–₯️ VDB Terminal Mechanics

The terminal is a custom-built web UI that mimics command-line environments. It works like this:

  1. You type a command

  2. It is POSTed to the server via AJAX (cmd)

  3. PHP matches the syntax using regex

  4. Performs the corresponding action on the JSON file

  5. JSON response is returned and shown in the terminal

js
fetch("vdb-terminal.php", { method: "POST", body: new URLSearchParams({ cmd: userInput }) })

✨ All logic runs server-side. No client-side manipulation of data.


πŸ” Implemented Security: .json File Access


1. .htaccess Protection

In VDB folder:

apache
<FilesMatch "\.json$"> Order Allow,Deny Deny from all </FilesMatch>

βœ… This denies browser access to any .json file.


2. Cloudflare Worker Firewall

I’ve added a Cloudflare Worker that intercepts .json URL access requests globally:

js
addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)) }) async function handleRequest(request) { const url = new URL(request.url) if (url.pathname.endsWith('.json')) { return new Response("Unauthorized", { status: 403 }) } return fetch(request) }

βœ… Prevents .json access even if .htaccess fails or is bypassed.


πŸ”— VDB Integration with Backend

πŸ’‘ Backend Use Case:

VDB can power:

  • Surveys

  • Form data collectors

  • Logs

  • Mini-CRMs

  • Simple backend APIs

  • Admin dashboards

  • Student/attendance managers


πŸ” Secure Backend Access with 256-bit Hash

I’ve added an optional secured access mechanism via PHP cURL, which allows backend scripts to access the JSON data using a 256-bit hash token.

🧠 How it works:

  1. The backend passes a hashed token using Authorization or a secure POST field.

  2. PHP verifies the token before giving access to VDB data.

  3. It provides the relative path to the backend for that .json database, where only origin server can access the file through backend

php

// Sample backend curl to VDB curl_setopt($ch, CURLOPT_POSTFIELDS, [ 'uname' => 'username', 'token' => 'd5f8e14c62ac...securehash...' ]);

βœ… Protects your data when used in:

  • Internal scripts

  • Server-to-server communication

  • API microservices


πŸ”— Live Demo

πŸ’» Try it now:
πŸ‘‰ https://viswath.me/try-vdb/

  • Full working web terminal

  • Try creating, writing, fetching, and deleting DBs

  • Supports nested JSON fields

  • Friendly error messages

  • Looks and behaves like a real shell interface


πŸš€ Example Use Cases

  • Custom CMS storage

  • Client data capture form

  • Storing internal logs

  • Product feedback/bug report manager

  • Emergency data API (when DB fails)


πŸ“Œ Conclusion

VDB is my signature creation β€” a unique, terminal-based, secure, and extensible NoSQL system built on native technologies. It’s perfect for:

  • Low-resource apps

  • Developers experimenting with NoSQL

  • Educational platforms

  • Offline web apps


🧱 Tech Stack

  • PHP (backend)

  • JSON (flat-file DB)

  • JavaScript + AJAX (terminal UI)

  • .htaccess + Cloudflare Worker (security)

  • cURL + 256-bit token access (API) for backend



#WebDev #FullStackDev #NoSQL #PHPDevelopment #JSONDatabase #CustomDatabase #TerminalUI #AJAX #CommandLineInterface



Leave a Comment

Your email address will not be published. Required fields are marked *

0 Comments

Support me