Search
Lessons (40)
- Payment Retries: Prevent Duplicate Charges
When a payment request is retried, the customer must never be charged twice. Save the attempt first, reuse …
- Design an E-Commerce Checkout
… That could charge them twice. - ✅ Mark the payment UNKNOWN . Show the buyer an honest "Processing your payment...". Then …
- Resilient Service Calls: Retries, Breakers and Load Shedding
… the mobile app , then the API gateway , then the checkout service , which calls the payment service . Each layer …
- Abstraction
… Promise<string ; // returns a payment ID refund(paymentId: string): Promise<void ; } Any class that promises to follow the …
- Data in Microservices: Sagas & the Outbox Pattern
… No central coordinator. mermaid flowchart LR O[Orders] -- OrderCreated I[Inventory] I -- StockReserved P[Payments] P -- PaymentFailed I2 …
- Releases, Observability and Production Safety
… The 5 new servers work, but the new payment code sometimes sends a payment twice . 4. The dashboard …
- REST API Design
… A client sends POST /payments , the connection drops, and the client doesn't know if the payment happened …
- Flash Sale: 10 Million Buyers, No Oversell
… Now the first buyer may have paid with no phone . - ✅ When payment starts, move the reservation to PAYMENT …
- O — Open/Closed Principle
… Then Klarna → edit again… throw new Error("Unknown payment method"); } After: plug-in strategies js // ✅ Each payment method …
- The L6 System-Design Thinking Loop
… Tell the failure story. Payment may succeed while the reply gets lost. So: - save a lasting payment attempt …
- C4 Architecture Diagrams: Context, Container, Component and Code
… Order, paymentId: string) void } class CatalogService { +reservePricedItems(items: CheckoutItem[]) PricedItem[] } class PaymentGateway { <<interface +charge(amount: Money, token: string …
- Clean Architecture in Depth
… Promise<void ; } export interface PaymentGateway { charge(customerId: string, amountCents: number): Promise<{ paymentId: string } ; } export interface IdGenerator { next(): string …
- Monolith vs Microservices
… one deployable"] direction LR U[Users module] --- O[Orders module] --- P[Payments module] --- I[Inventory module] DB1[(One …
- Polymorphism
… payment methods ts interface PaymentMethod { pay(amount: number): string; } class CardPayment implements PaymentMethod { constructor(private last4: string) {} pay …
- Referrals, Cold Outreach and Tracking Applications
… I have 3 years with Node.js and PostgreSQL and built a payment service handling 2M requests/day …
- Observability: Logs, Metrics & Traces
… hard to search, no context console.log("Payment failed for user 42"); // ✅ Structured (pino): every field is searchable …
- Structural Patterns: How to Connect Objects
… inventory, payment, shipping, email… class CheckoutFacade { constructor({ inventory, payments, shipping, mailer }) { Object.assign(this, { inventory, payments, shipping, mailer …
- Resilience Patterns
… JSON.stringify(payment), signal: AbortSignal.timeout(2000), // give up after 2 s }); 💡 Base timeouts on the dependency's …
- Event-Driven Patterns, Step Functions and Reliable Lambdas
… A full payment saga must track confirmed charges, uncertain outcomes, and compensation failures rather than blindly refunding every …
- Service Communication: Sync vs Async
… dancers react to each other"] ORD[Orders] -- OrderPlaced INV2[Inventory] INV2 -- StockReserved PAY2[Payments] PAY2 -- PaymentCompleted SHIP2[Shipping …
- Kafka for Backend Services
… skip safely await client.query("ROLLBACK"); return; } await client.query( "INSERT INTO payments (order id, amount cents, status …
- Finding Service Boundaries with DDD
… auth, email, payments"] -- GenHow["Buy / use SaaS"] Put your best engineers and cleanest design into the core ; buy …
- Event-Driven Architecture
… Orders knows everyone"] O1[Orders] -- reserve I1[Inventory] O1 -- charge P1[Payments] O1 -- email E1[Email] O1 -- track …
- Delivery Guarantees: At-Most, At-Least & Exactly Once
… either both happen or neither does. mermaid sequenceDiagram participant Src as payments topic participant App as Transactional processor …
- Multi-Region and Disaster Recovery
… Check payments whose result was unknown with the payment provider (did the charge go through or not?). 3 …
- Domain-Driven Design: Strategic Design
… already Buy or use SaaS/open source Auth, payments, email, accounting mermaid quadrantChart title Where to invest effort …
- Proxies, APIs and Real-Time Protocols
… Whether every order/payment command succeeded exactly once . Dropping an old driver position is fine. Losing an order …
- Observability and Incident Response
… If checkout success is back up, you're recovering. Walk through a failure Checkout calls payment. Payment accepts …
- NestJS Core Concepts
… OrdersService }, // alias ] constructor(@Inject("PAYMENT GATEWAY") private readonly payments: PaymentGateway) {} Injection scopes Scope New instance Use when --- --- --- DEFAULT …
- Backend Design Scenarios
… How do you prevent a double charge?]( 7-a-payment-succeeds-at-the-gateway-but-your-service-times …
- Configuration, Secrets and Storage
… LOG LEVEL: "info" PAYMENTS URL: "http://payments-api" Use it as environment variables in a pod: yaml envFrom …
- VPC Networking Without the Confusion
… Then trace the app's outbound call to a third-party payment API. Expected result: the browser reaches …
- Timeouts, Retries & Backpressure
… If payment receives a request with only 20 ms left, it should not even start. Retries can make …
- Database Internals, Replication and Scaling
… Send critical reads (confirmation page, payment status) to the primary. 2. The primary is now busier. If it …
- Which Pattern Do I Need?
… 🗺️ Strategy — pluggable algorithms (payments, pricing, auth) 7. 🚦 State — order and payment workflows 8. 📞 Chain of Responsibility — request …
- Concurrency, Resilience & Distributed Workflows
… a webhook is delivered twice, a payment provider times out after charging the card, a queue grows faster …
- Kubernetes Cluster Architecture, Simply
… cluster ├── team-shop → shop-api, shop-web ├── team-payments → payments-api └── kube-system → Kubernetes own system components bash …
- Comments & Formatting
… const PAYMENT MAX RETRIES = 3; That second comment is gold: no amount of good naming could tell you …
- Batch vs Stream and Data Modeling
… Keep one trusted copy of the real records The purchase records (orders, payments) are the source of truth …
- AWS Databases: Choose the Right One
… Integer cents avoid floating-point rounding in this simple money example; real payment models also account for currency …