Skip to content
kauand3vPublic

About

Ultra-low latency real-time platform for critical event monitoring, built with Go, Next.js, WebSockets, and Redis

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

Pulse-Ops

Real-time, low-latency operations monitoring and control, built on Go, WebSockets, and Redis.

Go PostgreSQL Redis WebSocket License

Pulse-Ops is an event-driven control plane for operators who need to see system state as it happens and act on it immediately. The backend (Go + Redis + PostgreSQL) is the core of the project. The frontends are thin clients that consume its event stream.


The Problem

Most operational dashboards are built on request/response polling. Under real load, that model fails in predictable ways:

  • Stale data. The operator sees the world as it was up to one polling interval ago. During an incident, that gap is the difference between a contained failure and an outage.
  • Wasted capacity. Every client polls whether or not anything changed. Database and network load scale with clients × poll rate, not with actual events.
  • Unsafe controls. Commands sent over flaky networks get retried. Without idempotency, a retried "pause" or "reroute" can be applied twice.
  • Cascading failures. When a downstream dependency degrades, consumers keep hammering it and turn a partial failure into a full one.

The Solution

Pulse-Ops replaces polling with a push-based, event-driven pipeline and treats operator commands as first-class, reliable operations.

Concern Approach
Latency Persistent WebSocket connections. State changes are pushed to clients as they occur, with no polling loop.
Throughput Go goroutines handle connections and event processing concurrently with a small memory footprint.
Fan-out Redis Pub/Sub broadcasts state changes to every connected Hub instance.
Durability Redis Streams provide a persistent queue with consumer groups. PostgreSQL stores events and audit records in ACID transactions.
Data consistency Every command carries an idempotency key. The processor deduplicates before applying, so retries are safe.
Failure containment "Panic Mode" is a built-in circuit breaker. One action halts queue consumption to stop cascading failures under stress. gobreaker isolates Redis and PostgreSQL faults.
Perceived latency Clients apply optimistic updates and reconcile against the authoritative server event, rolling back deterministically on failure.

Use cases

  • Industrial IoT: monitor machinery sensors and intervene before failures.
  • E-commerce and fintech: manage order and transaction spikes with anomaly visibility.
  • Logistics: real-time fleet state and dynamic rerouting.

Architecture

flowchart LR
    subgraph Clients
        FE["Frontend clients<br/>Next.js / Angular"]
    end

    subgraph Hub["WebSocket Hub (Go)"]
        WS["Gorilla WebSocket server<br/>JWT auth, rate limiting,<br/>payload validation"]
    end

    subgraph Bus["Redis"]
        PS["Pub/Sub<br/>real-time broadcast"]
        ST["Streams<br/>durable command queue"]
    end

    subgraph Proc["Event Processors (Go)"]
        EP["Consume commands<br/>Enforce idempotency keys<br/>Publish state changes"]
    end

    DB[("PostgreSQL 16<br/>event store, snapshots,<br/>audit log")]

    FE -- "commands (wss://)" --> WS
    WS -- "validated commands" --> ST
    ST -- "consumer group" --> EP
    EP -- "ACID transactions" --> DB
    EP -- "state change events" --> PS
    PS -- "fan-out" --> WS
    WS -- "real-time events (wss://)" --> FE
Loading

Lifecycle of a critical command

  1. The operator triggers an action, for example Pause Processing. The client updates its UI optimistically.
  2. The command, with its idempotency key, is sent over WebSocket to the Go Hub, which authenticates, rate-limits, and validates it.
  3. The Hub enqueues the command in Redis.
  4. An Event Processor consumes it, checks the idempotency key, and persists the intent in PostgreSQL inside a transaction.
  5. The processor publishes the resulting state change (for example system:paused) to Redis Pub/Sub.
  6. The Hub broadcasts the event to all connected clients. Each client reconciles with its optimistic state, or rolls back if the command was rejected.

Tech Stack

Backend (core)

Component Technology Why
Language Go 1.22+ Native concurrency, low memory footprint, strong network performance
WebSocket Gorilla WebSocket Mature, with upgrade handling and frame-level control
Messaging Redis Pub/Sub + Streams Pub/Sub for broadcast, Streams for durable queues with consumer groups
Persistence PostgreSQL 16 ACID transactions, JSONB payloads, partial indexes for recent events
Auth JWT (golang-jwt) Validated at WebSocket upgrade
Resilience gobreaker Circuit breaking for Redis and PostgreSQL
Observability Prometheus client, OpenTelemetry Metrics for connections, throughput, and latency

Frontend clients

Both frontends speak the same WebSocket protocol and contain no business logic. Use whichever fits your environment.

Client Focus Notes
frontend-nextjs SEO, SSR, general-purpose operator UI Next.js 14, Zustand, TanStack Query, native WebSocket API
frontend-angular Enterprise dashboards with heavy stream processing Angular 17+, RxJS (bufferTime, auditTime), Signals, D3.js

Repository layout

pulse-ops/
├── backend-go/          # Core: WebSocket Hub, event processors
├── frontend-nextjs/     # Client: SSR-oriented UI
├── frontend-angular/    # Client: enterprise dashboard
└── docker-compose.yml   # PostgreSQL and Redis for local development

Project Status

Pulse-Ops is under active development. This table reflects what is implemented versus planned, so you can evaluate it accurately.

Area Status
Bidirectional WebSocket communication + Redis Pub/Sub Done
Optimistic updates on the main data grid In progress
JWT authentication with continuous token renewal Planned
Prometheus/Grafana telemetry export Planned
Multi-instance WebSocket cluster on Redis Streams Planned

Quick Start

Prerequisites

  • Docker and Docker Compose
  • Go 1.22+
  • Node.js 20+ (only if running a frontend)
  • Angular CLI 17+ (only for frontend-angular)

1. Clone

git clone https://github.com/kauandias747474-hue/Pulse-Ops.git
cd Pulse-Ops

2. Start PostgreSQL and Redis

docker compose up -d
docker compose ps   # both services should report "healthy"

3. Run the backend

cd backend-go
cp .env.example .env
go mod tidy
go run cmd/main.go

Make sure the connection strings in .env match the credentials in docker-compose.yml.

4. Run a frontend (pick one)

Next.js at http://localhost:3000

cd frontend-nextjs
cp .env.example .env.local
npm install
npm run dev

Angular at http://localhost:4200

cd frontend-angular
npm install
ng serve

Testing

# Backend (with race detector)
cd backend-go && go test ./... -race -v

# Next.js
cd frontend-nextjs && npm test

# Angular
cd frontend-angular && ng test

Future Work

  • Security hardening: role- and attribute-based access control, signed WebSocket commands, and an immutable audit log.
  • Observability: distributed tracing with OpenTelemetry, structured logs with correlation IDs, and alerting rules.
  • Horizontal scaling: multi-instance Hub coordinated through Redis Streams, with graceful degradation when PostgreSQL is unavailable.
  • Event sourcing and CQRS: versioned event store, materialized projections, and snapshotting.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss the proposal.

License

Distributed under the MIT License. See LICENSE for details.

About

Ultra-low latency real-time platform for critical event monitoring, built with Go, Next.js, WebSockets, and Redis

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages