Architecting a BRICS-Ready Currency Exchange: Part 1 – Scalable Conversions with Go
Ruslan

Ruslan @ruslan-brics

About: 💻 Technologist for BRICS Software Evolution 🚀 Go • Python • Event-Driven Systems • Fintech 🛠️ Leading [TheBricsHub OSS](https://github.com/TheBricsHub) 🗣️ Languages: RU/NL/EN/FR/中文 (HSK2)

Joined:
Jul 20, 2025

Architecting a BRICS-Ready Currency Exchange: Part 1 – Scalable Conversions with Go

Publish Date: Jul 20
2 0

How to design a scalable, observable financial system for emerging markets.

The BRICS Opportunity

"While BRICS nations drive 45% of global remittances, their financial systems face unique technical challenges. As a multilingual engineer (RU/EN/FR/NL), I'm developing open-source solutions to bridge these gaps."

Core Architecture Decisions

Why Golang + NATS JetStream?

Key Requirements:

  • Cost efficiency: Affordable for startups and scale-ups
  • Predictable latency: Crucial for arbitrage-sensitive markets

Implementation:

func (s *server) Convert(ctx context.Context, req *pb.ConvertRequest) (*pb.ConvertResponse, error) {
  // 1. Validate idempotency key
  // 2. Thread-safe rate lookup 
  // 3. Async event publishing
  s.js.PublishAsync("transactions.currency", event, 
    nats.MsgId(req.IdempotencyKey)
  )
}
Enter fullscreen mode Exit fullscreen mode

Key Decisions:

  1. gRPC for Conversions: Binary protocol beats JSON for high-frequency ops
  2. JetStream Persistence: Guaranteed delivery during market volatility
  3. Async Processing: Decouples conversion logic from event streaming

Performance Outcome:

✅ 45,743 RPS sustained on single node (consumer hardware)
Enter fullscreen mode Exit fullscreen mode

Design Insight:

"Inspired by India's UPI requirements for sub-500ms settlements, our architecture prioritizes deterministic latency through Go's channels and JetStream's streamlined persistence."

Critical Reliability Features

Idempotent Event Processing

Challenge: Network retries can cause duplicate conversions

Solution:

  1. Idempotency Keys:
s.js.PublishAsync("transactions.currency",
  []byte(event),
  nats.MsgId(req.IdempotencyKey),
  nats.ExpectStream("TRANSACTIONS"),
)
Enter fullscreen mode Exit fullscreen mode
  1. Stream Configuration:
_, err := js.AddStream(&nats.StreamConfig{
  Name:        "TRANSACTIONS",
  Description: "BRICS currency conversion events",
  Subjects:    []string{"transactions.>"},
  Retention:   nats.InterestPolicy,
  MaxAge:      24 * time.Hour,
  Duplicates:  24 * time.Hour, // Matches Brazilian audit rules
  Storage:     nats.FileStorage,
  Replicas:    1,
})
Enter fullscreen mode Exit fullscreen mode

"Duplicate transactions in RUB/CNY conversions could mean significant losses. Our approach combines client-supplied ids with JetStream's deduplication window."

Performance Engineering

Benchmarking Under BRICS Conditions

Test Simulation:

func TestPerfConversionRPS(t *testing.T) {
  // 500 concurrent workers
  // 12-second sustained load
  // Dynamic idempotency keys
}
Enter fullscreen mode Exit fullscreen mode

Results:

=== RUN   TestPerfConversionRPS
    server_performance_test.go:89: Successful conversions: 548,922  
    server_performance_test.go:94: ✅ 45,743 RPS (Exceeds 30K target)
Enter fullscreen mode Exit fullscreen mode

Optimization Techniques:

  1. Zero-Copy Serialization: Protocol Buffers over JSON
  2. Lock Granularity: sync.RWMutex for concurrent rate access
  3. Connection Pooling: gRPC keep-alives
  4. Async I/O: Non-blocking JetStream publishing

Forward Momentum

Current Focus Areas

  • Real Time Monitoring with Prometheus and Grafana
  • Central Bank Integrations

Community Participation

Want to help? We'd love PRs for:

  • Currency modules
  • Real-world load testing

Get Involved

  1. ⭐ github.com/TheBricsHub/brics-currency-exchange
  2. 💬 Open issues with your BRICS payment experience
  3. 🛠️ Submit PRs

Coming in Part 2: Monitoring currency volatility with Prometheus and Grafana

Comments 0 total

    Add comment