Skip to content

Commit 8b838f7

Browse files
Revise README.md to enhance clarity and feature presentation
- Updated the project title and added Python support badge. - Expanded the features section with a table format for better readability. - Included detailed usage examples for both Python and Rust, showcasing database operations. - Improved command reference and added a section for CLI REPL commands. - Enhanced visual elements and overall structure for a more engaging presentation.
1 parent 89bab25 commit 8b838f7

1 file changed

Lines changed: 102 additions & 55 deletions

File tree

README.md

Lines changed: 102 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,150 @@
1-
# 🛡️ FerrumDB
1+
# FerrumDB
22

33
<p align="center">
44
<img src="https://img.shields.io/badge/Rust-000000?style=for-the-badge&logo=rust&logoColor=white" />
5+
<img src="https://img.shields.io/badge/Python-3776AB?style=for-the-badge&logo=python&logoColor=white" />
56
<img src="https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge" />
6-
<img src="https://img.shields.io/badge/Version-0.1.2-blue.svg?style=for-the-badge" />
7-
<img src="https://img.shields.io/badge/Storage-Append--Only-orange?style=for-the-badge" />
7+
<img src="https://img.shields.io/badge/AES--256-Encrypted-red?style=for-the-badge" />
88
</p>
99

10-
---
10+
**FerrumDB** is a premium, zero-setup embedded document database for **Rust** and **Python**. No server. No config. No migrations. Just open a file and go.
1111

12-
**FerrumDB** is a premium, high-performance local key-value database built in **Rust**. Designed for developers who need a reliable, "zero-setup" structured data store that feels as fast as a cache but is as durable as a disk-backed database.
12+
---
1313

14-
## 🌟 Why FerrumDB?
14+
## 🌟 Features
1515

16-
-**Append-Only Architecture (AOF)**: $O(1)$ write performance. We never overwrite—we only grow.
17-
- 📦 **Structured Data**: Native support for **JSON Values**. Store objects, arrays, and numbers directly.
18-
-**Time-To-Live (TTL)**: Built-in data expiration for efficient local caching.
19-
- 🧹 **Background Compaction**: Automatic garbage collection to keep your storage footprint minimal.
20-
- 🏗️ **Embeddable Library**: Use it as a CLI tool or import it as a high-level Rust crate.
21-
- 🛡️ **Crash Resilient**: Atomic swaps and `sync_data` guarantee your data survives power loss.
16+
| | |
17+
|---|---|
18+
|**O(1) reads & writes** | Append-only log + in-memory HashMap index |
19+
| 📄 **Native JSON** | Store any structured document natively |
20+
| 🔍 **Secondary Indexing** | Query by JSON fields via `create_index()` |
21+
| 🔐 **AES-256 Encryption** | Protect data at rest with one line of config |
22+
| ⚛️ **Atomic Transactions** | All-or-nothing batch operations |
23+
| 🖥️ **Ferrum Studio** | Embedded web dashboard at `localhost:7474` |
24+
| 🐍 **Python Bindings** | `pip install ferrumdb` — no Rust required |
25+
| 🛡️ **Crash Resilient** | `fsync` + atomic rename guarantee durability |
2226

2327
---
2428

25-
## 🚀 Quick Start
29+
## 🐍 Python Usage
30+
31+
```bash
32+
pip install ferrumdb
33+
```
34+
35+
```python
36+
from ferrumdb import FerrumDB
37+
38+
# Zero-setup: creates myapp.db if it doesn't exist
39+
db = FerrumDB.open("myapp.db")
40+
41+
# Store any JSON-serializable value
42+
db.set("user:1", '{"name": "alice", "role": "admin", "score": 99}')
43+
db.set("user:2", '{"name": "bob", "role": "user", "score": 45}')
2644

27-
### Library Usage (Zero-Setup)
45+
# Read back
46+
print(db.get("user:1")) # {"name": "alice", "role": "admin", "score": 99}
47+
print(db.count()) # 2
48+
print(db.keys()) # ["user:1", "user:2"]
2849

29-
Add FerrumDB to your project and start storing data in seconds:
50+
# Secondary indexing — O(1) field lookups
51+
db.create_index("role")
52+
admins = db.find("role", '"admin"') # => ["user:1"]
53+
54+
# Delete
55+
db.delete("user:2")
56+
```
57+
58+
Your data is stored in a plain file in your project directory — portable, no server, no Docker.
59+
60+
---
61+
62+
## 🦀 Rust Usage
63+
64+
```toml
65+
# Cargo.toml
66+
[dependencies]
67+
ferrumdb = "0.1.0"
68+
tokio = { version = "1", features = ["full"] }
69+
serde_json = "1"
70+
```
3071

3172
```rust
32-
use ferrumdb::FerrumDB;
73+
use ferrumdb::{FerrumDB, Config, Transaction};
3374
use serde_json::json;
3475

3576
#[tokio::main]
3677
async fn main() -> Result<(), Box<dyn std::error::Error>> {
37-
// Zero-setup open (defaults to ./ferrum.db)
78+
// Standard open
3879
let db = FerrumDB::open_default().await?;
3980

40-
// Store structured JSON
41-
db.set("user:1".into(), json!({
42-
"name": "Usman",
43-
"role": "Premium Developer"
44-
})).await?;
81+
// Store documents
82+
db.set("user:1".into(), json!({"name": "alice", "role": "admin"})).await?;
83+
84+
// Query
85+
db.create_index("role").await?;
86+
let admins = db.find("role", &json!("admin")).await;
4587

46-
// Retrieve data
47-
if let Some(user) = db.get("user:1").await {
48-
println!("User: {}", user["name"]);
49-
}
88+
// Atomic transaction
89+
let tx = Transaction::new()
90+
.set("k1".into(), json!({"tag": "blue"}))
91+
.set("k2".into(), json!({"tag": "red"}))
92+
.delete("k1".into());
93+
db.commit(tx).await?;
94+
95+
// Encrypted database
96+
let key: [u8; 32] = *b"my_super_secret_key_32_bytes_!!";
97+
let db_enc = FerrumDB::open(
98+
Config::new().with_encryption(key)
99+
).await?;
50100

51101
Ok(())
52102
}
53103
```
54104

55-
### CLI Interactive REPL
105+
---
56106

57-
Experience the premium terminal interface with autocomplete and syntax highlighting:
107+
## 🔥 Ferrum Studio
108+
109+
When you run the REPL, Ferrum Studio auto-launches — a premium web dashboard to browse, query, and edit your database visually.
58110

59111
```bash
60112
cargo run --release
113+
# 🔥 Ferrum Studio → http://localhost:7474
61114
```
62115

63116
---
64117

65-
## 🛠️ Commands Reference
66-
67-
| Command | Usage | Description |
68-
| :--- | :--- | :--- |
69-
| **SET** | `SET <key> <json>` | Store structured data (Strings, Objects, Arrays) |
70-
| **GET** | `GET <key>` | Retrieve and pretty-print stored data |
71-
| **DELETE** | `DELETE <key>` | Remove a key-value pair |
72-
| **KEYS** | `KEYS` | List all indexed keys |
73-
| **COUNT** | `COUNT` | Show total number of entries |
74-
| **COMPACT**| `COMPACT` | Manually trigger log file optimization |
75-
| **HELP** | `HELP` | Show commands and session metrics |
76-
77-
---
118+
## 🖥️ CLI REPL Commands
78119

79-
## 🎨 Premium REPL Features
120+
```bash
121+
cargo run
122+
```
80123

81-
- **Tab-Complete**: Instantly complete commands and keys.
82-
- **Colorized Output**: High-contrast, easy-to-read terminal feedback.
83-
- **JSON Pretty-Print**: Structured output for complex data.
124+
| Command | Description |
125+
|---|---|
126+
| `SET <key> <json>` | Store a document |
127+
| `GET <key>` | Retrieve and pretty-print |
128+
| `DELETE <key>` | Remove a key |
129+
| `KEYS` | List all keys |
130+
| `COUNT` | Total number of entries |
131+
| `INDEX <field>` | Create secondary index |
132+
| `FIND <field> <value>` | Query by indexed field |
133+
| `HELP` | Show commands + session metrics |
84134

85135
---
86136

87-
## 📐 Architecture
137+
## 🏗️ Architecture
88138

89-
- **Engine**: Bitcask-lite inspired log-structured storage.
90-
- **Index**: In-memory `HashMap` leveraging `tokio::sync::RwLock` for high concurrency.
91-
- **Persistence**: Binary serialization via `bincode` for maximum speed and minimal disk usage.
139+
- **Storage**: Bitcask-inspired append-only log (AOF)
140+
- **Index**: In-memory `HashMap` with `tokio::sync::RwLock`
141+
- **Encryption**: AES-256-GCM per-block, transparent decorator pattern
142+
- **Compaction**: Atomic log rewrite via temp-file + rename
92143

93144
---
94145

95146
## 📝 License
96147

97-
Distributed under the **MIT License**. See `LICENSE` for more information.
148+
MIT — see `LICENSE` for details.
98149

99-
---
100-
101-
<p align="center">
102-
Built with 🦀 by Muhammad Usman
103-
</p>
150+
<p align="center">Built with 🦀 by Muhammad Usman</p>

0 commit comments

Comments
 (0)