Search

Lessons (40)

  • Async JavaScript: Promises, async/await and Node's Event Loop

    From callbacks to promises to async/await: running work in parallel, handling errors, timeouts and cancellation with AbortController …

  • Service Communication: Sync vs Async

    … If they don't pick up, you're stuck. - Email (asynchronous): you send a message and carry on …

  • Backend Languages: Node.js, Go, Python & Rust

    … Express js import express from "express"; const app = express(); app.get("/users/:id", async (req, res) = { const user …

  • Python Web APIs: FastAPI and Django

    … user.email} async def or plain def ? Endpoint does… Write Why --- --- --- await s async libraries (httpx, asyncpg) async …

  • Hexagonal Architecture (Ports & Adapters)

    … Loan[] = []; async save(loan: Loan) { this.loans.push(loan); } async countActiveFor(memberId: string) { return this.loans.filter((l …

  • D — Dependency Inversion Principle

    … A higher-order function works just as well: js const makePlaceOrder = ({ saveOrder, sendEmail }) = async (order) = { await saveOrder(order …

  • Python Fundamentals

    … async with httpx.AsyncClient(timeout=5) as client: responses = await asyncio.gather( (client.get(u) for u in …

  • Abstraction

    … string) { // call Stripe's API… return "pi 123"; } async refund(paymentId: string) { / … / } } class FakeGateway implements PaymentGateway { async charge …

  • Rust: Types, Errors and Concurrency

    … That's the compiler catching a race before it exists. Async with Tokio For thousands of concurrent network …

  • Clean Architecture

    … null; } async save(user) { / INSERT … RETURNING id / } } // adapters/UserController.js export const userController = (registerUser) = async (req, res) = { const …

  • Frontend Testing Strategy

    … 201 })), ]; tsx it("lists products from the API", async () = { render(<ProductsPage / ); expect(await screen.findByText("Keyboard")).toBeInTheDocument(); // findBy …

  • Interfaces vs Abstract Classes

    … number; } // A class can implement MANY interfaces class EmailNotifier implements Notifier, Retryable { maxRetries = 3; async send(to: string …

  • Clean Architecture in Depth

    … IdGenerator, ) {} async execute(request: PlaceOrderRequest): Promise<PlaceOrderResponse { const order = Order.create(this.ids.next(), request.customerId, request.lines …

  • NestJS Core Concepts

    … Repository<Order ) {} async findOne(id: number) { const order = await this.repo.findOneBy({ id }); if (!order) throw new NotFoundException …

  • Next.js Rendering: CSR, SSR, SSG, ISR & Server Components

    … the default when a page uses no request-specific data export default async function Page() { / … / } // ISR: regenerate at …

  • How Browsers Render a Page

    … Use defer or async . - Changing geometry triggers expensive layout; transform and opacity are cheap. - Batch DOM reads and …

  • MVC, MVP & MVVM

    … routes/products.js (Express) router.get("/products/:id", async (req, res) = { const product = await Product.findById(req.params …

  • CQRS & Event Sourcing

    … rules and state changes async function changeShippingAddress({ orderId, address }) { const order = await orderRepository.load(orderId); order.changeAddress(address …

  • Node.js and Express

    … routing, the middleware pipeline, validation, async error handling, project structure, configuration, security, rate limiting, logging and graceful shutdown …

  • Small Functions That Do One Thing

    … one function doing everything js async function registerUser(req) { // validate if (!req.body.email !req.body.email.includes …

  • Advanced TypeScript for Frontend

    … string } }; type ApiResult<T = ApiSuccess<T ApiFailure; async function request<T (url: string): Promise<ApiResult<T { const response …

  • Structural Patterns: How to Connect Objects

    … each wraps a function and returns a function with the same shape const withLogging = (fn, name) = async (...args …

  • Multi-Region and Disaster Recovery

    … Can it meet an RPO of zero ? <details <summary Show answer</summary No. Asynchronous means the main region …

  • Layered (N-Tier) Architecture

    … OrderService) {} async create(req: Request, res: Response) { const order = await this.orders.placeOrder(req.body.customerId, req.body …

  • Message Queues & RabbitMQ

    … true }); channel.prefetch(10); // at most 10 unacknowledged messages per worker channel.consume("emails", async (msg) = { const job …

  • Choosing a Programming Language

    … GC Concurrency Event loop + async/await asyncio , threads (GIL), processes Goroutines + channels Threads + async (Tokio), no data races …

  • Serverless Architecture

    … create a thumbnail export const handler = async (event: S3Event) = { for (const record of event.Records) { const image = await …

  • Design a URL Shortener

    … durable mappings, cache-backed redirects and asynchronous analytics](/img/system-design-l6/url-shortener.svg) Start with the …

  • Serverless: Lambda and API Gateway

    … For failed asynchronous work, configure a dead-letter queue or failure destination so messages are not silently lost …

  • Clean Error Handling

    … js // routes just throw app.get("/users/:id", async (req, res) = { const user = await users.findById(req.params …

  • Kafka for Backend Services

    … true }); // no duplicates from producer retries export async function runRelay() { await producer.connect(); while (true) { const client = await …

  • JavaScript Essentials: Event Loop, Closures & this

    … Split heavy work into chunks, or move it to a Web Worker . async/await is promises underneath js …

  • Delivery Guarantees: At-Most, At-Least & Exactly Once

    … remember processed event IDs (same transaction as the business change) await db.transaction(async (tx) = { const inserted = await …

  • Replication, Partitioning & Sharding

    … Prefer colocating related data, asynchronous aggregates and explicit workflows. Do not shard because it sounds scalable; exhaust indexing …

  • Kafka Producers

    … 5 }); await producer.connect(); export async function publishOrderPlaced(order) { await producer.send({ topic: "shop.orders.placed", acks: -1 …

  • What Is Apache Kafka?

    … Services publish events to it and other services consume them asynchronously, so producers and consumers don't need …

  • Consumers & Consumer Groups

    … orders.placed" }); await consumer.run({ autoCommit: false, eachMessage: async ({ topic, partition, message }) = { const eventId = message.headers.eventId.toString …

  • Event-Driven Architecture

    … Handler<E ) { this.handlers.set(type, [...(this.handlers.get(type) ?? []), handler]); } async publish(event: { type: string }) { await Promise …

  • Event-Driven Patterns, Step Functions and Reliable Lambdas

    … Standard and synchronous/asynchronous Express have distinct semantics; see [workflow types](https://docs.aws.amazon.com/step-functions …

  • Vertical Slice Architecture & the Modular Monolith

    … simple, direct SQL export async function getOrderHistory(db: Pool, customerId: string) { const { rows } = await db.query( SELECT id …