Immutable Graphs and Clojure: How Nubank Scaled to 131 Million Customers
Nubank hit 131 million customers in just 12 years using Clojure, Datomic, and immutable data. Their stack handles 4,000 microservices, 72 billion daily Kafka events, and 2.5 billion Datomic transactions. This approach slashes complexity while delivering built-in audit trails—no extra infrastructure needed.
Brazil's Banking Landscape and Nubank's Launch
Brazil's banking scene was dominated by five major players controlling 84% of the credit market, with sky-high interest rates up to 450% annually. Around 34 million adults were unbanked, and opening an account could take months. In 2013, a team led by David Vélez (Sequoia Capital), Cristina Junqueira (Itaú), and Edward Wible (Princeton) launched Nubank with a no-fee credit card via mobile app, starting with limits as low as $10.
Seed funding: $2 million. Explosive growth followed: 12 million customers by 2019, 48 million at the 2021 IPO, 100 million by 2024, and 131 million by 2025 (covering 62% of Brazil's adult population). Success driven by word-of-mouth referrals.
The Pitfalls of Mutable Data in Banking Systems
Mutable data makes auditing a nightmare: regulators demand a customer's exact state at any moment—credit limit, scoring model, input data. Disputes arise without full history. Machine learning models become unreproducible after updates.
Traditional fixes like audit tables, triggers, and versioning pile on thousands of lines of code with zero business value.
The immutable approach: Every change is a new fact with a timestamp. Query any point in time for the state. Auditing is free, reproducibility guaranteed.
Why Datomic and Clojure
CTO Edward Wible drew from Out of the Tarpit, prioritizing minimal mutable state. He chose Datomic—an immutable database by Rich Hickey in EAVT format (Entity-Attribute-Value-Transaction).
- Nothing gets deleted.
- Every change is a timed fact.
- State is a time slice, just like in Git.
Datomic led to Clojure: the team ditched OOP and RDBMS. Tech stack: Clojure (backend), Kafka (async), Datomic (data), Flutter (mobile), AWS/K8s (infra).
2025 scale: 4,000 microservices, 72 billion Kafka events/day, 2.5 billion Datomic transactions/day, 85+ K8s clusters, 50+ deploys/day (master to prod in 30 minutes).
Nubank acquired Cognitect (Clojure/Datomic creators) in 2020; Hickey joined. Datomic went fully open-source under Apache 2.0 in 2023.
Rich Hickey's Philosophy
Rich Hickey built Clojure solo in 2.5 years. Key ideas from Simple Made Easy:
- Simple means untangled; easy means familiar. The industry trades simplicity for ease.
- Values over objects. Time is a sequence of facts.
- Identity is a series of states; facts are immutable.
Implications:
- No locks/mutexes, trivial concurrency.
- Deterministic testing.
- Databases like Git: time travel built-in.
Victor Oliveira notes Hickey's influence transcends the language, reshaping software design.
Conway's Law in Nubank's Architecture
Conway's Law (1968): Systems mirror the organization's communication structure. Three teams build a three-pass compiler; siloed groups create clunky interfaces.
Nubank deliberately shapes its org around the stack: small cross-functional teams, uniform tech. This keeps complexity low while scaling to 131 million customers.
Key takeaways:
- Immutability eliminates audit infrastructure, simplifying compliance.
- Datomic's EAVT + time = Git for banking data.
- Clojure + Conway's Law deliver simplicity across 4,000 services.
- Nubank's growth proves functional programming works for high-scale fintech.
- Open-sourcing Datomic boosts adoption.
— Editorial Team
No comments yet.