Skip to content

squad0011/Open-Audit

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

223 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Open-Audit

The Google Translate for Soroban β€” an open-source transparency tool for the Stellar/Soroban ecosystem.

License: MIT Contributions Welcome Built on Stellar


What is Open-Audit?

Smart contracts on Stellar/Soroban emit events as cryptic, hex-encoded binary data. To the average user β€” or even most developers β€” these events are completely unreadable. Open-Audit solves this by:

  1. Fetching raw contract events from the Stellar network via Horizon/RPC.
  2. Translating them into plain English sentences using a community-maintained Translation Registry.
  3. Displaying the results in a clean, searchable dashboard anyone can use.

Example:

Before (Raw) After (Translated)
0x000000000000000000000000... Public Key [GABC...1234] transferred 100 USDC to [GXYZ...5678]

Tech Stack

  • Framework: Next.js 14 (App Router) + TypeScript
  • Design System: Tailwind CSS + shadcn/ui
  • Stellar Integration: stellar-sdk
  • State Management: React Context + Server Components

Getting Started

Prerequisites

  • Node.js >= 18
  • npm >= 9

Installation

git clone https://github.com/your-org/open-audit.git
cd open-audit
npm install
npm run dev

Open http://localhost:3000 in your browser.

For the custom server with WebSocket support and /metrics, run:

npm run dev:ws

Environment Variables

Copy .env.example to .env.local and fill in the values:

cp .env.example .env.local

For microservices architecture, use:

cp .env.microservices.example .env.local
Variable Description Default
NEXT_PUBLIC_HORIZON_URL Stellar Horizon endpoint https://horizon-testnet.stellar.org
NEXT_PUBLIC_SOROBAN_RPC_URL Soroban RPC endpoint https://soroban-testnet.stellar.org
NEXT_PUBLIC_NETWORK_PASSPHRASE Network passphrase Testnet passphrase
REDIS_URL Redis connection URL (microservices) redis://localhost:6379
REDIS_CHANNEL Redis Pub/Sub channel (microservices) stellar:events
PORT HTTP server port 3000

Available Scripts

Development:

npm run dev              # Standard Next.js dev server
npm run dev:ws           # Legacy monolithic server with WebSocket
npm run dev:decoupled    # Microservices web server (requires Redis)
npm run worker:indexer   # Microservices indexer worker (requires Redis)
npm run test:websocket   # Test WebSocket connection

Production (Microservices):

npm run docker:build     # Build Docker images
npm run docker:up        # Start all services with Docker Compose
npm run docker:down      # Stop all Docker services
npm run docker:logs      # View Docker logs

npm run start:pm2        # Start services with PM2
npm run stop:pm2         # Stop PM2 services
npm run monit:pm2        # Monitor PM2 processes
npm run logs:pm2         # View PM2 logs

Testing & Quality:

npm run test             # Run all tests
npm run lint             # Run ESLint
npm run lint:registry    # Validate translation registry
npm run format           # Format code with Prettier

Telemetry

The custom server exposes Prometheus metrics on http://localhost:3000/metrics when running npm run dev:ws.

You can configure OpenTelemetry to export spans to Jaeger by setting:

export JAEGER_ENDPOINT="http://localhost:14268/api/traces"
export OTEL_SERVICE_NAME="open-audit"

The default Jaeger endpoint is http://localhost:14268/api/traces.


Architecture

Open-Audit supports two deployment architectures:

πŸ†• Microservices Architecture (Recommended for Production)

Decoupled, scalable, fault-isolated system using Redis Pub/Sub:

Stellar Network β†’ Indexer Worker β†’ Redis Pub/Sub β†’ Web Server β†’ WebSocket Clients

Benefits:

  • βœ… Zero CPU starvation (indexer runs in separate process)
  • βœ… Independent horizontal scaling
  • βœ… Fault isolation (crashes don't affect other services)
  • βœ… Auto-reconnect and message queuing
  • βœ… Zero-downtime deployments

Quick Start:

# Option 1: Docker Compose (Easiest)
npm run docker:up

# Option 2: PM2 Process Manager
npm run start:pm2

# Option 3: Manual
Terminal 1: redis-server
Terminal 2: npm run dev:decoupled
Terminal 3: npm run worker:indexer

πŸ“š Documentation:

Legacy Monolithic Architecture

Single-process system (for simple deployments):

Stellar Network β†’ Event Indexer β†’ Translation Engine β†’ WebSocket Server β†’ Frontend Dashboard

⚠️ Known limitations: Under heavy load, indexing can starve the HTTP/WebSocket server of CPU cycles. See deprecation notice in server.ts.

npm run dev:ws

For new contributors wanting to understand the system's data flow and internal architecture, see the comprehensive ARCHITECTURE.md guide which includes:

  • πŸ“Š Interactive Mermaid diagrams showing data flow
  • πŸ” Component deep dives for each service
  • πŸ“ Step-by-step event journey from blockchain to UI
  • πŸ› οΈ Development guides for adding new features

Quick Overview:

  1. Event Indexer (lib/stellar/, src/worker/) β€” Polls Stellar RPC with resilient rate limiting
  2. Translation Engine (lib/translator/) β€” Converts XDR to human-readable text
  3. Redis Pub/Sub (microservices only) β€” Message broker for event distribution
  4. WebSocket Server (server-decoupled.ts or server.ts) β€” Broadcasts events in real-time
  5. Frontend Dashboard (app/dashboard/, components/) β€” Interactive UI

Project Structure

open-audit/
β”œβ”€β”€ app/                    # Next.js App Router pages
β”‚   β”œβ”€β”€ dashboard/          # Main dashboard page
β”‚   β”œβ”€β”€ api/                # API routes (health checks, etc.)
β”‚   β”œβ”€β”€ layout.tsx          # Root layout with theme provider
β”‚   └── page.tsx            # Landing / redirect
β”œβ”€β”€ components/             # Reusable UI components
β”‚   β”œβ”€β”€ ui/                 # shadcn/ui primitives
β”‚   β”œβ”€β”€ dashboard/          # Dashboard-specific components
β”‚   └── theme/              # Dark mode toggle
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ translator/         # πŸ”‘ The Translation Registry core logic
β”‚   β”‚   β”œβ”€β”€ types.ts        # RawEvent / TranslatedEvent interfaces
β”‚   β”‚   β”œβ”€β”€ registry.ts     # Registry lookup function
β”‚   β”‚   └── blueprints/     # Per-contract translation blueprints
β”‚   β”œβ”€β”€ stellar/            # Stellar SDK helpers
β”‚   β”‚   β”œβ”€β”€ indexer.ts      # Event polling with rate limit handling
β”‚   β”‚   └── client.ts       # RPC client configuration
β”‚   β”œβ”€β”€ resilience/         # ⚑ Rate limiting & circuit breaker
β”‚   β”‚   β”œβ”€β”€ token-bucket.ts # Token bucket rate limiter
β”‚   β”‚   β”œβ”€β”€ circuit-breaker.ts # Circuit breaker pattern
β”‚   β”‚   └── resilient-client.ts # Resilient RPC client wrapper
β”‚   β”œβ”€β”€ hooks/              # React hooks for live data
β”‚   └── utils.ts            # Shared utilities
β”œβ”€β”€ src/
β”‚   └── worker/             # πŸ†• Microservices architecture
β”‚       └── indexer.ts      # Standalone indexer worker
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ lint-registry.ts    # Translation registry validation
β”‚   └── test-websocket-client.js # WebSocket testing tool
β”œβ”€β”€ docs/
β”‚   └── good-first-issues.json
β”œβ”€β”€ server.ts               # Legacy monolithic server (deprecated)
β”œβ”€β”€ server-decoupled.ts     # πŸ†• Microservices web server
β”œβ”€β”€ ecosystem.config.js     # πŸ†• PM2 configuration
β”œβ”€β”€ docker-compose.microservices.yml # πŸ†• Docker Compose config
β”œβ”€β”€ Dockerfile.worker       # πŸ†• Indexer worker Docker image
β”œβ”€β”€ Dockerfile.web          # πŸ†• Web server Docker image
β”œβ”€β”€ ARCHITECTURE.md         # πŸ“– Detailed architecture guide
β”œβ”€β”€ MICROSERVICES_ARCHITECTURE.md # πŸ†• Microservices documentation
β”œβ”€β”€ QUICKSTART_MICROSERVICES.md   # πŸ†• Quick start guide
β”œβ”€β”€ MICROSERVICES_TESTING_GUIDE.md # πŸ†• Testing guide
└── public/

The Translation Registry

The heart of Open-Audit is the Translation Registry in /lib/translator/. Each contract gets a blueprint β€” a mapping from raw event topics/data to a human-readable template.

To add support for a new contract, create a file in /lib/translator/blueprints/ and register it in registry.ts. See CONTRIBUTING.md for a step-by-step guide.


Contributing

We welcome contributions of all sizes! See CONTRIBUTING.md to get started.

Good first issues are listed in /docs/good-first-issues.json.


License

MIT Β© Open-Audit Contributors

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 83.3%
  • Rust 8.5%
  • JavaScript 4.3%
  • Dafny 2.2%
  • Dockerfile 0.8%
  • PLpgSQL 0.4%
  • Other 0.5%