Search
Lessons (40)
- 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 …
- Hexagonal Architecture (Ports & Adapters)
… Loan[] = []; async save(loan: Loan) { this.loans.push(loan); } async countActiveFor(memberId: string) { return this.loans.filter((l …
- Design a URL Shortener
… durable mappings, cache-backed redirects and asynchronous analytics](/img/system-design-l6/url-shortener.svg) Generate a Base62 …
- D — Dependency Inversion Principle
… A higher-order function works just as well: js const makePlaceOrder = ({ saveOrder, sendEmail }) = async (order) = { await saveOrder(order …
- 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 …
- Clean Architecture in Depth
… IdGenerator, ) {} async execute(request: PlaceOrderRequest): Promise<PlaceOrderResponse { const order = Order.create(this.ids.next(), request.customerId, request.lines …
- How Browsers Render a Page
… Use defer or async . - Changing geometry triggers expensive layout; transform and opacity are cheap. - Batch DOM reads and …
- 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 …
- 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 …
- Small Functions That Do One Thing
… one function doing everything js async function registerUser(req) { // validate if (!req.body.email !req.body.email.includes …
- Structural Patterns: How to Connect Objects
… each wraps a function and returns a function with the same shape const withLogging = (fn, name) = async (...args …
- 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 …
- Serverless Architecture
… create a thumbnail export const handler = async (event: S3Event) = { for (const record of event.Records) { const image = await …
- Premiere-Night Video Streaming
… Heartbeat progress to Redis for fast resume and persist asynchronously to durable storage. Include a timestamp/sequence so …
- Clean Error Handling
… js // routes just throw app.get("/users/:id", async (req, res) = { const user = await users.findById(req.params …
- Replication, Partitioning & Sharding
… Prefer colocating related data, asynchronous aggregates and explicit workflows. Do not shard because it sounds scalable; exhaust indexing …
- 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 …
- Kafka Producers
… 5 }); await producer.connect(); export async function publishOrderPlaced(order) { await producer.send({ topic: "shop.orders.placed", acks: -1 …
- 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 …
- Vertical Slice Architecture & the Modular Monolith
… simple, direct SQL export async function getOrderHistory(db: Pool, customerId: string) { const { rows } = await db.query( SELECT id …
- Caching & Redis
… SET product:42 (expires in 300 s) end js async function getProduct(id) { const key = product:${id} ; const …
- Data in Microservices: Sagas & the Outbox Pattern
… publish unsent outbox rows, then mark them as sent setInterval(async () = { const rows = await db.query( "SELECT FROM …
- Behavioral Patterns II: Chain, Template, Iterator, Mediator, Memento, Visitor
… fixed order of steps async run(source) { const raw = await this.read(source); const records = this.parse(raw …
- SOLID at a Glance
… injected abstractions this.repository = repository; this.notifier = notifier; } async publish(report, exporter) { const file = exporter.export(report); // L …
- KISS: Keep It Simple, Stupid
… new NotificationContext(user, TemplateRegistry.get("welcome"))); js // ✅ KISS async function sendWelcomeEmail(user) { await mailer.send({ to: user.email …
- How a Web Request Works
… Node.js (Express) endpoint app.get("/products/:id", async (req, res) = { const product = await productService.getById(req.params …
- What Is Apache Kafka?
… topic: "orders", fromBeginning: true }); await consumer.run({ eachMessage: async ({ partition, message }) = { const order = JSON.parse(message.value.toString …
- TypeScript Essentials
… string undefined ts // A typed API helper async function fetchJson<T (url: string): Promise<T { const response = await …
- API Gateway, BFF & Service Discovery
… one endpoint shaped exactly for the home screen app.get("/mobile/home", async (req, res) = { const [user, orders …
- Deploying & Operating Microservices
… in Node.js process.on("SIGTERM", () = { server.close(async () = { // stop accepting new requests, finish current ones await db …
- What Is Software Architecture?
… system shaped? Monolith or microservices, layers, sync vs async, which database, where the business logic lives 🔴 High Design …
- REST API Design
… return the SAVED response (no second charge ✅) js app.post("/payments", async (req, res) = { const key = req.get …
- Authentication, Authorization & API Security
… is logged in" app.get("/orders/:id", authenticate, async (req, res) = { const order = await orders.findById(req.params …
- Observability: Logs, Metrics & Traces
… res.statusCode })); next(); }); app.get("/metrics", async (req, res) = res.type("text/plain").send(await client.register.metrics …