EmailDB is a specialized database system designed for efficient email storage and retrieval. The latest version introduces a revolutionary hybrid architecture that combines append-only block storage with advanced indexing, achieving 99.6% storage efficiency while maintaining excellent query performance.
- Append-Only Block Storage: Pack multiple emails into blocks for 99.6% storage efficiency
- ZoneTree Indexes: Lightning-fast searches with B+Tree indexes
- Hash Chain Integrity: Cryptographic proof of email authenticity for archival
- Checkpoint System: Automated backup and recovery mechanisms
- Storage Efficiency: 99.6% (only 0.4% overhead)
- Write Performance: 50+ MB/s sustained
- Read Latency: < 0.1ms for indexed lookups
- Search Speed: 50,000+ queries/second
- Cryptographic Hash Chains: Tamper-evident storage
- Immutable Blocks: Write-once guarantee
- Existence Proofs: Verifiable email timestamps
- Corruption Recovery: Automatic detection and recovery
βββββββββββββββββββββββ ββββββββββββββββββββ
β HybridEmailStore ββββββΆβ ZoneTree Indexes β
β (High-Level API) β β - MessageId β
ββββββββββββ¬βββββββββββ β - Folder β
β β - Full-Text β
βΌ ββββββββββββββββββββ
βββββββββββββββββββββββ
β AppendOnlyBlockStoreβ ββββββββββββββββββββ
β (Data Storage) ββββββΆβ Hash Chain β
βββββββββββββββββββββββ β (Integrity) β
ββββββββββββββββββββ
# Clone the repository
git clone https://github.com/yourusername/EmailDB.git
cd EmailDB
# Build the project
dotnet build
# Run tests
dotnet testusing EmailDB.Format.FileManagement;
// Create a new email store
var store = new HybridEmailStore("emails.db", "indexes/");
// Store an email
var emailId = await store.StoreEmailAsync(
messageId: "unique@example.com",
folder: "inbox",
content: emailBytes,
subject: "Hello World",
from: "sender@example.com",
to: "recipient@example.com"
);
// Search emails
var results = store.SearchFullText("important project");
// Get emails by folder
var inboxEmails = store.GetEmailsInFolder("inbox");
// Move email to another folder
await store.MoveEmailAsync(emailId, "archive");// Create an archive with cryptographic integrity
var archive = new HybridEmailStore(
"archive.db",
"archive_indexes/",
enableHashChain: true
);
// Get cryptographic proof of email existence
var proof = await archive.GetExistenceProofAsync(emailId);
// Verify archive integrity
var integrity = await archive.VerifyIntegrityAsync();EmailDB/
βββ EmailDB.Format/ # Core library
β βββ FileManagement/ # Storage engines
β β βββ HybridEmailStore.cs
β β βββ AppendOnlyBlockStore.cs
β β βββ HashChainManager.cs
β β βββ ArchiveManager.cs
β βββ Models/ # Data models
β βββ ZoneTree/ # Index integration
βββ EmailDB.UnitTests/ # Comprehensive test suite
βββ docs/ # Documentation
βββ architecture/ # Architecture docs
- One email per block
- 5-10% storage overhead
- Frequent metadata updates
- Multiple emails per block
- 0.4% storage overhead
- Append-only with separate indexes
| Metric | Traditional | Hybrid | Improvement |
|---|---|---|---|
| Storage Efficiency | 90-95% | 99.6% | 10x better |
| Write Speed | 10 MB/s | 50+ MB/s | 5x faster |
| Search Speed | 1K/sec | 50K/sec | 50x faster |
| Update Cost | High | Low | Minimal I/O |
// Migrate existing database
var migrator = new EmailDbMigrator(new MigrationPlan
{
SourcePath = "old_emails.db",
DestinationPath = "new_emails.db",
IndexPath = "indexes/",
EnableHashChain = true
});
var result = await migrator.MigrateAsync();See the Migration Guide for detailed instructions.
The project includes comprehensive tests:
# Run all tests
dotnet test
# Run specific test categories
dotnet test --filter "FullyQualifiedName~HybridEmailStore"
dotnet test --filter "FullyQualifiedName~Performance"- Long-term storage with cryptographic integrity
- Compliance with legal retention requirements
- Tamper-evident audit trails
- Fast email retrieval and search
- Efficient folder operations
- Minimal storage footprint
- Full-text search capabilities
- Metadata indexing for analysis
- Time-based queries with proof
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
[Add your license here]
- Original EMDB format by Net Ninja
- ZoneTree B+Tree implementation
- Community contributors