udsl-sdk
v1.0.7
Published
Crash-safe data recovery SDK (WAL + Snapshot based)
Maintainers
Readme
UDSL - Universal Data Safety Layer
Crash-safe persistence layer powered by Write-Ahead Logging (WAL) and Snapshots.
UDSL helps applications recover instantly after crashes while maintaining a complete audit trail of state changes.
Features
- Write-Ahead Logging (WAL)
- Snapshot-based Recovery
- Crash-safe State Persistence
- Instant Recovery Engine
- Audit Logging
- Multi-Tenant Support
- Docker-powered Server
- TypeScript SDK
Installation
Install the SDK:
npm install udsl-sdkPrerequisites
Before using UDSL, make sure you have:
- Node.js 18+
- Docker Desktop installed and running
Download Docker:
https://www.docker.com/products/docker-desktop/
Start UDSL Server
Start the server using the CLI:
npx udsl-sdk startThis command automatically:
- Pulls the latest UDSL Docker image
- Creates a container named
udsl-server - Starts the server on port
3001
Expected output:
🚀 Starting UDSL...
📦 Pulling UDSL image...
🔥 Starting server...
✅ UDSL running at http://localhost:3001Starting an Existing Server
After the first setup, you can simply run:
docker start udsl-serverNo need to run npx udsl-sdk start every time.
Stopping the Server
docker stop udsl-serverBasic Usage
const { UDSL } = require("udsl-sdk");
UDSL.init({
baseUrl: "http://localhost:3001",
apiKey: "test-key-123"
});
async function main() {
await UDSL.save("companyA:user1", {
name: "Om",
age: 22
});
const result = await UDSL.get("companyA:user1");
console.log(result);
}
main();Output:
{
key: "companyA:user1",
state: {
name: "Om",
age: 22
},
eventsCount: 1,
mode: "INSTANT_RECOVERY"
}Recovery Example
Save data:
await UDSL.save("companyA:profile", {
name: "Om",
city: "Mumbai"
});Stop the server:
docker stop udsl-serverRestart:
docker start udsl-serverRead data again:
const data = await UDSL.get("companyA:profile");Your data is automatically recovered from snapshots and WAL.
Docker Image
UDSL Server Image:
docker pull omghadage/udsl-server:latestManual start:
docker run -d -p 3001:3001 --name udsl-server omghadage/udsl-server:latestArchitecture
Application
│
▼
udsl-sdk
│
▼
UDSL Server
│
┌───┼─────────┐
│ │ │
▼ ▼ ▼
WAL Snapshot Audit
Log Store LogData Flow
- Application sends state updates.
- UDSL appends events to WAL.
- Events update in-memory state.
- Periodic snapshots are created.
- Recovery loads snapshot first.
- Recent WAL entries are replayed.
- State is restored instantly.
Example Use Cases
- Notes Applications
- Offline-first Apps
- Document Editors
- Workflow Engines
- State Synchronization
- Audit-heavy Systems
- Recovery-critical Applications
Troubleshooting
Port 3001 already allocated
Find running containers:
docker psStop existing server:
docker stop udsl-serverOr remove it:
docker rm -f udsl-serverDocker not running
Start Docker Desktop and retry:
npx udsl-sdk startAuthor
Om Ghadage
License
MIT
