An open API service indexing awesome lists of open source software.

https://github.com/jurshsmith/vaultstream

High-Performance Distributed Digital Signature System
https://github.com/jurshsmith/vaultstream

cryptography ecdsa-key-pair golang jetstream nats-streaming postgresql

Last synced: 2 months ago
JSON representation

High-Performance Distributed Digital Signature System

Awesome Lists containing this project

README

          

# ๐Ÿ” VaultStream

> **High-Performance Distributed Digital Signature System**
> A microservices-based cryptographic infrastructure for secure record signing at scale, built with Go and event-driven architecture.

![Go](https://img.shields.io/badge/Go-1.18+-00ADD8?style=flat-square&logo=go)
![PostgreSQL](https://img.shields.io/badge/PostgreSQL-316192?style=flat-square&logo=postgresql&logoColor=white)
![NATS](https://img.shields.io/badge/NATS-27AAE1?style=flat-square&logo=nats.io&logoColor=white)
![Docker](https://img.shields.io/badge/Docker-2496ED?style=flat-square&logo=docker&logoColor=white)

---

## โœจ Overview

VaultStream is a production-ready distributed system designed for high-throughput digital signature operations. It demonstrates enterprise-grade patterns including event-driven microservices, concurrent processing, and cryptographic best practices.

### ๐ŸŽฏ Key Features

- **๐Ÿ”‘ ECDSA Cryptography** - P-256 curve key generation and digital signatures
- **โšก High Concurrency** - Configurable goroutine pools with semaphore-based flow control
- **๐Ÿ“Š Batch Processing** - Optimized bulk operations with chunking and parallel execution
- **๐Ÿ”„ Event-Driven Architecture** - NATS JetStream for reliable message delivery
- **๐Ÿ—„๏ธ Resilient Data Layer** - PostgreSQL with Ent ORM and migration support
- **๐Ÿ“ˆ Performance Tuning** - Configurable batch sizes and concurrency levels
- **๐Ÿงช Production Testing** - Integration tests with real database connections

## ๐Ÿ—๏ธ Architecture

### System Components

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Keys Service โ”‚ โ”‚ Records Service โ”‚ โ”‚ Signing Service โ”‚
โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚
โ”‚ โ€ข ECDSA Key Gen โ”‚ โ”‚ โ€ข Batch Queries โ”‚ โ”‚ โ€ข Concurrent โ”‚
โ”‚ โ€ข Key Streaming โ”‚ โ”‚ โ€ข Record Publish โ”‚ โ”‚ Signing โ”‚
โ”‚ โ€ข Concurrency โ”‚โ”€โ”€โ”€โ”€โ”ค โ€ข DB Integration โ”‚โ”€โ”€โ”€โ”€โ”ค โ€ข Bulk Inserts โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ โ”‚ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ NATS JetStream โ”‚
โ”‚ โ€ข Event Streaming โ”‚
โ”‚ โ€ข Durable Consumers โ”‚
โ”‚ โ€ข Message Persistence โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ PostgreSQL โ”‚
โ”‚ โ€ข Records Table โ”‚
โ”‚ โ€ข Signatures Table โ”‚
โ”‚ โ€ข ACID Compliance โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

![VaultStream Architecture Diagram](./docs/vaultstream-architecture.png "VaultStream Architecture Diagram")

## ๐Ÿš€ Quick Start

**One-command setup:**

```bash
make quick-start
```

This command will:

- โœ… Set up environment configuration
- โœ… Verify prerequisites (Go, Docker, Make)
- โœ… Launch PostgreSQL and NATS infrastructure
- โœ… Seed database with configurable record count
- โœ… Start all microservices concurrently

### ๐ŸŽ›๏ธ Performance Tuning

Adjust these variables in the generated `.env` file to observe system behavior at different scales:

```bash
BATCH_SIZE=50 # Records per batch (impacts memory vs. throughput)
TOTAL_RECORDS=1000 # Scale of the signing workload
RECORDS_MAX_CONCURRENCY=10 # Parallel batch processing
SIGNER_MAX_CONCURRENCY=8 # Concurrent signature operations
```

## ๐Ÿ› ๏ธ Tech Stack

| Category | Technology | Purpose |
| -------------------- | -------------- | --------------------------------------- |
| **Language** | Go 1.18+ | High-performance concurrent programming |
| **Message Broker** | NATS JetStream | Event streaming with persistence |
| **Database** | PostgreSQL | ACID-compliant data storage |
| **ORM** | Ent | Type-safe database operations |
| **Cryptography** | ECDSA P-256 | Industry-standard digital signatures |
| **Containerization** | Docker Compose | Local development infrastructure |

## ๐Ÿ“Š Data Model

### Database Tables

- **`records`** - Source data requiring digital signatures
- **`signatures`** - Cryptographic signatures with key associations

### Message Streams

- **`records.>`** - Batch record publishing for signature processing
- **`keys.>`** - Cryptographic key distribution and lifecycle management

## ๐Ÿ”ง Prerequisites

Ensure the following tools are installed:

| Tool | Version | Installation |
| ---------- | ------- | ----------------------------------------------------------------- |
| **Go** | 1.18+ | [golang.org/dl](https://golang.org/dl/) |
| **Docker** | 20.10+ | [docs.docker.com/get-docker](https://docs.docker.com/get-docker/) |
| **Make** | Any | Xcode CLI Tools (macOS) or package manager (Linux) |

## ๐Ÿ“‹ Available Commands

```bash
make help # Show all available commands
make quick-start # Complete setup and launch
make start # Launch services (after setup)
make test # Run integration test suite
make stop # Stop all services and cleanup
make clean # Reset volumes and cached data
```

## ๐Ÿ”ฎ Roadmap

### Performance & Reliability

- [ ] **Retry Strategies** - Exponential backoff with jitter for transient failures
- [ ] **Circuit Breakers** - Fault tolerance for downstream dependencies
- [ ] **Metrics & Observability** - Prometheus metrics and distributed tracing

### Infrastructure & Deployment

- [ ] **Kubernetes Deployment** - Helm charts for container orchestration
- [ ] **Auto-scaling** - Horizontal pod autoscaling based on queue depth
- [ ] **Health Checks** - Comprehensive readiness and liveness probes

### Testing & Quality

- [ ] **Expanded Test Coverage** - Unit tests for critical cryptographic functions
- [ ] **Load Testing** - Performance benchmarks under high concurrency
- [ ] **Security Audit** - Formal review of cryptographic implementations

---

**๐Ÿข Enterprise-Ready Features:** Structured logging โ€ข Graceful shutdowns โ€ข Database migrations โ€ข Configuration management โ€ข Error handling โ€ข Concurrent processing