Refactoring Switchain: From Legacy to Microservices
1. WHY (Why) - The Problem
The legacy system after 7 years
Technical challenges:
- Monolithic architecture in Meteor.js difficult to maintain
- Accumulated technical debt compromising development
- Limited scalability for individual components
Business challenges:
- Unsustainable operational costs ($40-50K/year on rates alone)
- Operational risks in a system processing billions of USD
- Slowed development velocity
- Difficulty onboarding new developers
The reality: A critical system that works, but can't evolve at the pace the business needs.
2. WHAT (What) - The Solution
Complete refactoring with modern architecture
From this:
Meteor.js Monolith
├── admin/
├── interface/
├── crons/
├── partners/
└── lambdas/ (💸 $50K/year)To this:
Microservices + DDD
├── apps/
│ ├── admin (Next.js)
│ ├── sw-api
│ ├── rates (💰 $85/month)
│ └── specialized workers
└── packages/
├── shifts (bounded context)
├── wallets (bounded context)
├── rates (bounded context)
└── more contexts...Modern stack:
- Node.js/TypeScript with Bun
- Domain-Driven Design
- Hexagonal Architecture (Ports & Adapters)
- Monorepo organized by domains
3. THE STRATEGY: Mikado Method + Value-First
What is the Mikado Method?
Inspired by the Japanese game Mikado (pick-up sticks):
- 🎋 You have a pile of intertwined sticks
- 🎯 Goal: Remove one stick without moving any other
- ⚠️ If something moves, you lose your turn
- 🔄 Keep trying until all sticks are removed
Applied to software:
Legacy System (pile of sticks)
↓
Extract one responsibility (one stick)
↓
Without breaking anything else ← CRITICAL!
↓
Everything else keeps working
↓
Repeat until migration completeKey principle: Never break the system in production. The reality: It's like tying your shoelaces… while running.
Our adaptation: Value-First Approach
We don't migrate by technical ease, but by business impact.
Prioritization based on:
- Economic value (cost savings, revenue generation)
- Risk reduction (critical components)
- Enablers (unlocks other migrations)
- Learning (strategy validation)
🚀 Success Case #1: Rates System
Context:
- January 2025 Hackathon as catalyst
- Need to renew contract with Vercel
- Rates system running on expensive lambdas
The problem:
💸 Current cost: $40,000 - $50,000 per year
📈 Trend: Growing with volume
⚠️ Risk: Unsustainable long-termThe action:
- First component extracted from legacy
- Migrated to optimized dedicated server
- Implemented with new architecture
The result:
✅ New cost: $85 per month = $1,020 per year
💰 Savings: ~$49,000 annually
📊 ROI: 98% cost reduction
⚡ Bonus: Better performance and controlStrategy validation
What we learned:
✅ It works: Mikado Method is effective in production ✅ Immediate ROI: No need to wait until the end to see value ✅ Confidence: Team validated that migration is viable ✅ Momentum: Quick wins generate energy to continue
📊 The Real Result: Zero Downtime Migration
The ultimate proof:
📅 Period: January 2025 → August 2025 (8 months)
💰 Daily volume: ~$2,000,000 USD
📈 Total volume: ~$480,000,000 USD migrated
⏱️ Downtime: 0 minutesThe technical feat:
Migrating a complete system that processes $2M daily, without stopping for a single second, is like tying your shoelaces while running a marathon.
Migrated components:
- ✅ Rates System → $49K/year savings
- ✅ Wallets API → New architecture
- ✅ Specialized workers → Better scalability
- ✅ Core business logic → DDD implemented
- ✅ System virtually complete in production
Next wave of migrations:
- Admin panel (improved user experience)
- Final optimizations
- Complete legacy deprecation
4. WHO (Who)
Project stakeholders
Critical system impacting:
- 👥 End users: Crypto exchanges without interruptions
- 🤝 Partners: Integrated APIs and services
- 🛠️ Tech team: Better developer experience
- 📊 Operations: Reduced costs, greater efficiency
- 💼 Business: Agility for new features and markets
Key requirement: Team training in DDD and hexagonal architecture
5. WHEN (When)
Project timeline
Q4 2024 ✅ Completed
- Analysis and design of new architecture
- Definition of bounded contexts
- POC and technical validation
Q1 2025 ✅ Completed
- January Hackathon: Rates System migrated
- Implementation of core services
- Pattern establishment
- Zero-downtime migration begins
Q2 2025 ✅ Completed
- Migration of main APIs
- Wallets and Shifts contexts
- Processing $2M daily in parallel
Q3 2025 ✅ Virtually completed
- Workers and auxiliary services
- Performance optimization
- System migrated in August
- Zero downtime throughout the process
Q4 2025 🎯 In progress
- Final refinement
- Legacy system deprecation
- Documentation and handover
6. WHERE (Where)
Scope and context
Industry: Cryptocurrency exchange platform
System scale:
- 💰 Billions USD processed
- ⏱️ 7 years of continuous operation
- 🌍 Global users and partners
- 🔒 24/7 critical system
Technical scope:
From: 6 monolithic applications
To: 15+ specialized microservices
+ 8 bounded contexts
+ Scalable architecture7. HOW (How)
Migration principles
Zero Downtime
- Deployments without interruptions
- Fast rollback if necessary
- Feature flags for granular control
Backwards Compatibility
- Compatible APIs during transition
- Coexistence period legacy + new
- Gradual migration of consumers
Data Integrity
- Continuous data validation
- Synchronization during transition
- Exhaustive edge case testing
Risk Mitigation
- Real-time monitoring
- Proactive alerts
- Contingency plan for each phase
Technical stack
Runtime & Language:
- Node.js with Bun (speed and efficiency)
- TypeScript (type safety)
Frontend:
- Next.js 14 + Shadcn/UI
- React Server Components
Architecture:
- Domain-Driven Design
- Hexagonal Architecture (Ports & Adapters)
- Independent Bounded Contexts
Monorepo:
- Bun workspaces
- Shared packages for cross-cutting concerns
- Independent apps per service
Success metrics
Technical:
- 📊 Code coverage: 80%+
- ⚡ Build time: -50%
- 📦 Bundle optimization per app
- 🧹 Technical debt reduced
Business:
- ✅ Uptime: 99.9%+
- 🚀 Response time: +30% improvement
- 📈 Development velocity: +40%
- 🐛 Bug rate: -60%
- 💰 Costs: We already saw the rates case
Continuous validation:
- Legacy vs new comparison in parallel
- A/B testing of critical features
- User feedback loops
Real Risks and Challenges
Technical risks faced
⚠️ Migration complexity
- Critical system in production 24/7
- Mitigation: Small phases, fast rollback
- Result: Zero downtime achieved ✅
⚠️ Loss of functionality
- Risk of omitting legacy features
- Mitigation: Feature parity checks, exhaustive testing
- Result: All functionalities migrated ✅
⚠️ Performance regression
- Possible temporary degradation
- Mitigation: Continuous monitoring, benchmarks
- Result: Performance improved ✅
😰 The biggest human challenge: The Support team
The problem:
January - August: Coexistence of TWO systems
├── Legacy Admin (old functionalities)
└── New Admin (new functionalities)The daily reality of support:
- 🔄 "Do I do this in the old or new admin?"
- 🤔 Memorizing where each functionality is
- 📝 Duplicate documentation
- 🐛 Debugging in two parallel systems
- 😵 Constant confusion for the team
Impact on developers:
- Maintaining two codebases
- Bugs appearing "in which system?"
- Duplicate testing
- Constant context switching
🎉 The light at the end of the tunnel
September 2025:
✅ Admin migration complete
✅ Single source of truth
✅ Support can be happy again
✅ Developers can sleep peacefullySpecial thanks:
To the Support team for their infinite patience during 8 months of "which admin do I use?"
Now there's only ONE admin. 🙏
Current status:
- Single system in production
- Incremental improvements ongoing
- Pending details that don't affect operations
- Team morale: 📈📈📈
Conclusion
Speed matters: A temporal analysis
Original system (Legacy):
📅 Intensive development: 3-4 years
👥 Team building from scratch
🛠️ 2018 technologies
📚 Learning on the goNew system (Complete refactoring):
📅 Total migration: 8 months (January - September 2025)
💰 Value from month 1: $49K saved/year
👥 Team with accumulated know-how
🤖 AI as key acceleratorThe equation:
3-4 years → 8 months = 5x faster
🤖 The AI factor: The invisible copilot
How AI accelerated us:
January 2025:
- DDD boilerplate generation
- Architecture suggestions
- Legacy code refactoring
September 2025:
- More powerful and accurate AI
- Better context understanding
- More effective assisted debugging
Continuous evolution:
AI in January ───→ AI in September ───→ AI today
│ │ │
Good Very good ExcellentReflection:
If we started today, with current AI and acquired knowledge, we would do it faster and better.
Lesson: Development speed is not linear when you combine:
- Accumulated know-how
- Well-thought architecture
- Exponentially evolving tools
The journey virtually completed
What we've achieved:
- ✅ Modern and scalable architecture designed and implemented
- ✅ Migration strategy validated in production
- ✅ $49K saved/year on rates alone
- ✅ $480M processed during migration
- ✅ Zero downtime in 8 months of active migration
- ✅ System migrated in September 2025
- ✅ 5x faster than building from scratch
- ✅ Team trained, confident… and happy
- ✅ Support with a single admin (finally!)
What's next:
- 🎯 Complete legacy system deprecation
- 🎯 Final performance optimizations
- 🎯 Documentation and knowledge transfer
- 🎯 Prepare platform to scale 10x
- 🎯 Apply learnings to future projects
The three technical feats
1. The availability feat:
Migrating a critical system that processes $2M daily, for 8 months, with zero downtime, is like changing a plane's engine… mid-flight.
2. The speed feat:
Recreating in 8 months what originally took 3-4 years, significantly improving it, is like running a marathon at sprint speed.
3. The human feat:
Maintaining two systems, two admins, two realities, without losing sanity or service, is like juggling… with chainsaws.
The future has arrived
Expected impact:
A system that has moved billions and lasted 7 years, now with modern architecture prepared for:
- The next 7+ years of growth
- Scale 10x without structural changes
- Easily adopt new technologies
- Onboard new developers in days, not months
The promise fulfilled:
- ✅ Faster system
- ✅ Costs drastically reduced
- ✅ More productive team
- ✅ Platform ready for the future
- ✅ And all without stopping for a second
Q&A
Questions?
Contact: [Your information]
Documentation: [Link to repo/docs]
