A Lightweight Key-Value Database with Web Interface and REST API
A simple NoSQL database designed for internal tools, featuring a web-based shell and RESTful API. Built with Flask for easy integration and extensibility.
- Features
- Installation
- Quick Start
- Configuration
- Web Interface
- API Documentation
- Database Management
- Advanced Usage
- Project Structure
- License
- π Key-Value Storage: Simple
set,get, anddeloperations. - π Web-Based Shell: Interactive browser interface for direct database access.
- π API Key Authentication: Secure endpoints with customizable keys.
- πΎ Auto-Save & Persistence: Data preserved across restarts.
- π Admin Tools: Multi-database management, backups, and bulk operations.
- π¦ Lightweight: Single-file storage with minimal dependencies.
-
Clone the Repository:
git clone https://github.com/yourusername/monodb.git cd monodb -
Install Dependencies (via Poetry):
poetry install
Development Mode (Port 5000):
python run.py # Debug mode with hot reloadProduction Mode (Port 8080):
python3 -m app # Simulated production environmentgunicorn -w 4 -b 0.0.0.0:8080 app:create_app()-
Set the Secret Key:
export SECRET_KEY='your_random_secret_here'
-
Admin Api_Key:
- The Admin API Key is derived from the server's SECRET_KEY. When the server starts, it reads the SECRET_KEY environment variable and uses it to authenticate administrative actions. Any request using this key is granted full admin privileges.
Access the interactive shell at http://localhost:5000:\
(gif incomming)
POST /api
Execute database commands via HTTP.
| Header | Body Example | Description |
|---|---|---|
Api-Key: KEY |
set user:1 John |
Requires valid API key. Plain text command. |
-
Update an Existing Key:
curl -X POST http://localhost:5000/api -H "Api-Key: your_secret_key" -d "set user:1234 'John Doe, jonhdoe@corp.com'"
-
Get a Key:
curl -X POST http://localhost:5000/api -H "Api-Key: your_secret_key" -d "get user:1234"
-
Delete a Key:
curl -X POST http://localhost:5000/api -H "Api-Key: your_secret_key" -d "del user:1234"
-
Admin Command (Clear Database):
curl -X POST http://localhost:5000/api -H "Api-Key: your_secret_key" -d "clear"
set <key> <value>: Set a key-value pair.get <key>: Get the value of a key.del <key>: Delete a key.help: Display available commands.getalldata: Get all data in the selected database.
- Reserved for internal operations (API keys, database mappings).
- Do not modify manually. Use admin commands instead.
- The Admin Api-Key is the app's secret key, and with it, you can execute all admin commands.
# Syntax: [core] set db:<API_KEY> <DATABASE_NAME>
core set db:invetory_api_key inventory# Prefix commands with the database name:
inventory set item:1 "Product A"core getalldata # Returns all API key-database mappings| Command | Description |
|---|---|
save |
Force immediate data persistence. |
load |
Reload data from disk. |
clear |
Wipe all data in the current DB. |
dump |
Export all key-value pairs (JSON). |
<database> <db_command> |
Run a command in a selected database |
- MonoDB is not based on JSON files but rather a Python dictionary stored in memory. JSON is only used as a means to ensure data persistence in case of shutdown.
- Disk storage occurs only periodically, ensuring better performance during normal operations.
- Manual saves:
curl -X POST ... -d "save"
MonoDB/
βββ app/
β βββ __init__.py # Flask app factory
β βββ database.py # Core database logic
β βββ templates/shell.html # Web interface
βββ run.py # Development launcher
βββ wsgi.py # Production WSGI entry
βββ database.json # Auto-saved data (backup)
Distributed under the MIT License. See LICENSE for details.
Contributions welcome! Submit issues or PRs via GitHub.