Skip to main content

Posts

Showing posts from June, 2026

Software Design Patterns for LLD Interviews: A Complete Guide

Software Design Patterns for LLD Interviews: A Complete Guide In Software Development Engineer (SDE) interviews—especially for mid-level and senior roles—low-level design (LLD) rounds assess your ability to write clean, reusable, maintainable, and extensible code. The foundation of resolving these architectural challenges lies in the standard Gang of Four (GoF) Design Patterns. Rather than memorizing theoretical definitions, interviewers expect you to apply these patterns to real-world scenarios, identifying the trade-offs of each. Below is a comprehensive guide to the 12 most frequently asked design patterns in LLD interviews, categorized by their classification (Creational, Structural, and Behavioral). Each pattern contains a concrete, real-world Java implementation and a detailed breakdown of design decisions. Creational Design Patterns Creational design patterns deal with object creation mechanisms. They abstract the instantiation process, making a system independent of how...

Design an AI Agent Tool Execution Coordinator

Problem Statement Design an autonomous AI Agent Tool Execution Coordinator (similar to the orchestration cores of LangChain, Semantic Kernel, or Claude Desktop agent runtimes). The engine must coordinate agents by parsing structured tool call requests emitted by a Language Model (LLM), invoking corresponding local Java code methods dynamically by name using reflection, appending execution outputs back to the context history, and driving the agentic loop iteratively until a final synthesized text answer is generated. Additionally, to prevent token limit errors in long-running sessions, the engine must perform proactive context-window pruning, dropping the oldest historical messages while strictly preserving the system instructions template at the head of the context. Asked In Companies OpenAI Anthropic Google Microsoft Design Decisions & Patterns Used Modern agentic AI systems use dynamic tool execution to interact with external databas...

Design an In-Memory Vector Search Engine (Vector Database-lite)

Problem Statement Design an in-memory high-dimensional Vector Search Engine (similar to the retrieval cores of Pinecone or Milvus). The engine must store vector embeddings (arrays of floating-point numbers representing semantic text meaning), support registering custom similarity distance algorithms (like Cosine Similarity or Euclidean Distance), and execute K-Nearest Neighbors (K-NN) query searches using priority queues to retrieve the Top-K matching documents with their corresponding similarity scores. Asked In Companies Pinecone OpenAI Google AWS Design Decisions & Patterns Used Modern generative AI systems use vector databases to implement Retrieval-Augmented Generation (RAG) and long-term memory. When an LLM needs context, we convert the query into a vector embedding and search our database for the closest match. To design this in Java, we need a flat structure of vector entries, a similarity metric interface to calculate scores, ...

Design a Prompt Management & Template Engine

Problem Statement Design an in-memory Prompt Management and Template Engine (similar to prompt registry databases in LangChain or prompt-ops engines). The engine must allow developers to register multi-turn conversational templates with message roles ( SYSTEM , USER , ASSISTANT ), extract required variables (using double-curly brackets e.g., {{user_name}} ) using regular expressions, validate and compile prompts by dynamically injecting variable maps, and support prompt versioning registries to retrieve specific configurations at runtime. Asked In Companies OpenAI Anthropic LangChain Design Decisions & Patterns Used Working with Large Language Models (LLMs) requires structured prompt formatting. Instead of concatenating raw strings, modern architectures use structured message lists with roles. Additionally, prompts are treated as code artifacts: they are versioned, validated, and compiled. We separate the template parsing logic (extracting ...

Design a Model Context Protocol (MCP) Router

Problem Statement Design a Model Context Protocol (MCP) Tool Router (similar to the integration bridges in Claude Desktop or modern IDE agents). The protocol Router must allow developers to register custom tools (capabilities) with specified parameter schemas, parse incoming standardized JSON-RPC 2.0 requests from an AI client, validate input arguments, route the execution dynamically to the matching tool, and return a structured content response following the MCP specification. Asked In Companies Anthropic Vercel Slack Design Decisions & Patterns Used The Model Context Protocol (MCP) is an open standard designed to let AI models connect securely to tools and data. An MCP server exposes capabilities (Tools) using a standard message format over JSON-RPC 2.0. To build this in Java, we need a registry that registers tools by name, validates input maps against declared parameter types (e.g., asserting that an integer parameter was not passed as...