GAZAR

Principal Engineer | Mentor | Educator

System Design

20 items
Outbox Pattern: Guarantee DB-to-Broker Atomicity
Outbox Pattern: Guarantee DB-to-Broker Atomicity

October 24, 2025

Starting a new article on the outbox pattern — a simple idea that saved one of my teams from a lot of late-night firefighting.What the outbox buys youI’ve used both a transactional outbox (app writes to an outbox table + a poller publishes) and CDC-based approaches (Debezium streaming DB changes into Kafka). Both work — the choice depends on operational constraints. For smaller teams or when you control the DB and app, transactional outbox is low-friction. For large, polyglot environments where you can't change app code easily, CDC can be better.Here's the core idea in plain terms:A few lessons I've learned the hard wayA few implementation details worth highlightingWhen to prefer transactional outboxChecklist before you ship an outboxClosing thoughtsThe outbox pattern isn't glamorous, but it's one of those engineering practices that earns its keep. It forces you to acknowledge the reality of distributed systems — that side effects can fail independently — and gives you a pragmatic, testable way to make your system more reliable.I publish these kinds of notes on gazar.dev and in my "Monday by Gazar" newsletter — if you follow them, you'll see the practical follow-up with code and infra diagrams. And if you’re dealing with a tricky outbox problem right now, tell me about it — I’ll share what I’d do.
System Design Interview Playbook: 10-20min Structure and TypeScript
System Design Interview Playbook: 10-20min Structure and TypeScript

October 20, 2025

I get asked about system design interviews a lot — partly because I’ve both interviewed at and conducted interviews for big teams, and partly because I run workshops through PersiaJS and on my newsletter, Monday by Gazar. Over the last decade I’ve learned that doing well in these interviews isn’t about memorizing buzzwords; it’s about a repeatable, clear thought process and being able to justify trade-offs under time pressure.Below is the playbook I use and teach. I’ll walk through the structure I follow in interviews, give concrete examples (including TypeScript snippets), and share real mistakes I’ve made so you can avoid them.High-level principle I live byI used to jump straight into diagrams and then realize I hadn’t clarified a crucial constraint (e.g., “Is eventual consistency acceptable?”). That wasted time and sometimes lost the interviewer’s trust. Now I always spend the first 2–3 minutes asking clarifying questions.Interview structure I use (repeatable, 10–20 minute timing)1. Clarify requirements (2–3 min)2. High-level design (3–5 min)3. Define APIs and data model (2–3 min)4. Capacity, scaling & bottlenecks (3–5 min)5. Deep dive into one component (5–10 min)6. Operational concerns & trade-offs (2–3 min)7. Wrap up, alternatives, and follow-up questions (1–2 min)This structure maps nicely to how interviewers score: clarity, trade-offs, architecture, scalability, and operational awareness.Concrete example: URL shortener (short walkthrough)I use this example in workshops because it touches on hashing, collision handling, data model, caching, and analytics.ClarifyHigh-level componentsAPIs and data modelGenerating codesSimple base62 encoder example in TypeScript:Scaling notesReal-world trade-offs I’ve seenExample deep-dive I often pick: rate limiting (since interviewers like algorithms & distributed state)Common approaches: fixed window, sliding window, token bucket, leaky bucket. For distributed systems, you either use a centralized store (Redis) or embed tokens in clients with consistent coordination.In interviews, mention the distributed design:What interviewers are actually listening forCommon mistakes I've made and seenA short cheat-sheet of common building blocks (one-line descriptions)How I recommend practicing (actionable plan)Resources I actually read or send peopleFinal advice — what I tell candidates before an interviewIf you want, we can do a mock system design now: pick a prompt (news feed, chat, ecommerce search, or video streaming) and I’ll walk you through how I’d tackle it in a 30-minute interview. I’ll even provide follow-up feedback and a short TypeScript prototype for key pieces.
The Map That Made Me Rethink My System Design Approach
The Map That Made Me Rethink My System Design Approach

August 10, 2025

Last week, I stumbled upon a visual “System Design Topic Map” from ByteByteGo that instantly caught my attention. As someone who’s built products, led teams, and spent too many late nights debugging scaling issues, this map felt like a cheat sheet for everything I wish I’d had years ago.Why It Hit MeWhen you work on real-world systems, you quickly realize that “system design” isn’t just one skill — it’s a whole ecosystem. This map lays it out beautifully, covering application design, communication, scalability, security, data layers, and infrastructure.Looking at it, I immediately started recalling moments from my own career:That time I learned the hard way why rate limiting is not optional after a DDOS attempt on one of our APIs.When our “quick prototype” grew into a monolith so big that moving to microservices felt like open-heart surgery.The painful week I spent implementing leader election in a distributed system — wishing I’d studied it sooner.My Takeaways From the MapHere’s how I see it breaking down:Mini Lesson: Real-Time Communication — 3 Strategies I’ve UsedReal-time communication is one of those things that looks simple on the surface, but in reality, the implementation depends heavily on your requirements, scale, and infrastructure. The map highlights three key strategies:1. Long PollingHow it works:When I’ve used it:Tips from experience:2. Server-Sent Events (SSE)How it works:When I’ve used it:Pros:Cons:Server (Node.js with Express) Example:3. WebSocketsHow it works:When I’ve used it:Best practices:Server (Node.js with ws library) Example:How I choose between them:How I’m Using This MapI’ve bookmarked it as a self-audit tool. Whenever I start a project, I’ll run through each category and ask:If you’re building anything beyond a hobby app, I recommend keeping a similar map on hand. It’s like having a senior architect whispering in your ear, minus the coffee breath.
How would you design system a frontend like Trello?
How would you design system a frontend like Trello?

May 8, 2024

Trello is known for its intuitive user interface (UI) and flexible task management system. In this article, we'll explore the key principles and strategies for designing a user-friendly UI for Trello-like productivity apps.The foundation of a Trello-like app's UI is its layout, which typically consists of boards, lists, and cards. This layout provides users with a visual representation of their tasks and projects, making it easy to organize and prioritize.Boards serve as the primary containers for organizing tasks or projects. Users can create multiple boards, each representing a different project or category. Customization options, such as board backgrounds and titles, add a personal touch to the user experience.Within each board, lists help users categorize tasks or items based on their status or workflow stage. Users can add, rename, rearrange, and delete lists as needed, providing flexibility in organizing their work.Cards represent individual tasks or items within lists. Users can add descriptions, due dates, labels, attachments, and comments to cards, making it easy to track and manage details. Drag-and-drop functionality enables users to move cards between lists and reorder them within a list, facilitating task management.A well-designed navigation system is essential for seamless user interaction. A navigation bar or sidebar provides easy access to boards and other features, while breadcrumbs or a hierarchical structure helps users navigate within boards and lists.Robust search functionality allows users to quickly find boards, lists, or cards based on keywords. Filtering options enable users to narrow down tasks by attributes such as labels, due dates, or assigned members, enhancing efficiency.Collaboration is a key feature of Trello-like apps, allowing multiple users to work together on boards and cards in real-time. User permissions and roles ensure secure access control and editing rights.Notification features keep users informed of updates, comments, or due date reminders related to boards and cards. Customizable notification settings allow users to manage their preferences effectively.Accessibility considerations ensure that the UI is inclusive and usable for all users, including those with disabilities. Features such as keyboard shortcuts and screen reader compatibility enhance accessibility.Incorporating feedback mechanisms such as surveys or user feedback forms enables continuous improvement of the UI based on user input and preferences.Designing a user-friendly interface for Trello-like productivity apps requires careful consideration of layout, navigation, customization options, collaboration features, and accessibility. By adhering to these key principles and incorporating user feedback, developers can create UIs that enhance productivity, streamline task management, and improve overall user experience.
How would you design an expense app?
How would you design an expense app?

May 2, 2024

Designing an expense app with varying approval flows based on user levels requires a thoughtful approach to user experience and system architecture. Here's a step-by-step guide on how to design such an app:Approval Workflows:Develop distinct approval workflows for each user level. For example:Allow for customization of approval workflows to accommodate variations in organizational structure and policies.You can see in the picture above: that we need an ERD of the database, including flow, flowDetails, flowTracker and expenseEach expense needs tobe marked a flow (flow detection) and then later to be examined on that and to be showed to the boss.By following these steps, you can design an expense app that meets the needs of users at different levels within the organization and streamlines the approval process for expense management.
Demystifying Oauth2 Sequence Diagrams
Demystifying Oauth2 Sequence Diagrams

May 1, 2024

Understanding OAuth2 can be daunting, especially when diving into its intricate mechanisms and protocols. However, breaking down its functionalities, such as through sequence diagrams, can illuminate its inner workings. In this article, we will unravel OAuth2 and explore how sequence diagrams serve as invaluable tools in comprehending its processes.OAuth2, at its core, is an authorization framework that enables secure access to resources without revealing user credentials. It operates through a series of interactions between multiple entities, including the resource owner, client application, authorization server, and resource server. These interactions are orchestrated seamlessly, ensuring robust security and streamlined access control.To visualize OAuth2's flow, sequence diagrams provide a graphical representation of the message exchange between these entities. Let's dissect a typical OAuth2 sequence diagram to grasp its essence:By visualizing these interactions through sequence diagrams, developers gain a comprehensive understanding of OAuth2's dynamics. Each step in the sequence represents a crucial aspect of the authentication and authorization process, elucidating the intricate dance between various entities involved.Moreover, sequence diagrams serve as invaluable tools for system architects, aiding in the design and implementation of OAuth2-compatible systems. They facilitate clear communication and collaboration among development teams, ensuring a cohesive approach to OAuth2 integration.In conclusion, OAuth2, though complex, becomes more approachable when dissected through sequence diagrams. These diagrams provide a visual roadmap, guiding developers through the intricacies of authentication and authorization processes. Embracing sequence diagrams as educational aids unlocks the potential to master OAuth2 and harness its capabilities effectively.
How would you design Netflix?
How would you design Netflix?

March 31, 2024

Netflix is a leading streaming platform that provides on-demand access to a vast library of movies, TV shows, and original content. Behind its user-friendly interface lies a sophisticated system architecture designed to deliver high-quality streaming experiences to millions of users worldwide. In this article, we'll delve into the system design considerations for Netflix, covering both non-technical and technical requirements, as well as low-level and high-level designs.Non-Technical RequirementsTechnical RequirementsLow-Level DesignHigh-Level DesignConclusionNetflix's system design embodies a combination of innovative technologies, scalable architectures, and data-driven insights to deliver a world-class streaming experience to users worldwide. By addressing both non-technical and technical requirements, Netflix continues to revolutionize the entertainment industry, setting the standard for on-demand streaming platforms and personalized content recommendations.
How would you design Dropbox?
How would you design Dropbox?

March 31, 2024

Dropbox is a cloud-based file storage and collaboration platform that allows users to store, share, and synchronize files across multiple devices. Behind the scenes, Dropbox's system architecture is designed to handle massive amounts of data, ensure data security and privacy, and provide a seamless user experience. In this article, we'll explore the system design considerations for Dropbox, covering both non-technical and technical requirements, as well as low-level and high-level designs.Non-Technical RequirementsTechnical RequirementsLow-Level DesignHigh-Level DesignConclusionDropbox's system design reflects a careful balance of scalability, reliability, security, and usability to meet the needs of its diverse user base and ensure a seamless file storage and collaboration experience. By addressing both non-technical and technical requirements, Dropbox has established itself as a leading cloud storage and collaboration platform, empowering users to work more efficiently and collaboratively across devices and platforms.
How would you design Instagram?
How would you design Instagram?

March 31, 2024

Instagram, a popular social media platform, enables users to share photos, videos, and stories with their followers and engage with content from others. Behind the scenes, Instagram's robust system architecture handles a massive volume of media uploads, user interactions, and content delivery. In this article, we'll delve into the system design considerations for Instagram, covering both non-technical and technical requirements, as well as low-level and high-level designs.Non-Technical RequirementsTechnical RequirementsLow-Level DesignHigh-Level DesignClient Applications: Instagram's mobile app, web interface, and third-party clients serve as the primary interfaces for users to upload media, view feeds, and interact with content.ConclusionInstagram's system design reflects a careful balance of scalability, reliability, and performance to meet the demands of its vast user base and media-centric nature. By addressing both non-technical and technical requirements, Instagram has established itself as a leading social media platform, connecting users worldwide and inspiring creativity through visual storytelling.
How would you design Twitter?
How would you design Twitter?

March 31, 2024

Twitter, a popular social media platform, enables users to share short messages, known as tweets, with their followers in real-time. Behind the scenes, Twitter's robust system architecture handles a massive volume of tweets, user interactions, and content delivery. In this article, we'll delve into the system design considerations for Twitter, covering both non-technical and technical requirements, as well as low-level and high-level designs.Non-Technical RequirementsTechnical RequirementsLow-Level DesignHigh-Level DesignConclusionTwitter's system design reflects a careful balance of scalability, reliability, and performance to meet the demands of its vast user base and real-time nature. By addressing both non-technical and technical requirements, Twitter has established itself as a leading social media platform, connecting users worldwide and facilitating meaningful interactions in the digital realm.
How would you design an app like Uber?
How would you design an app like Uber?

March 30, 2024

Uber, the renowned transportation network company, operates at a massive scale, connecting millions of riders with drivers across the globe. Behind the scenes, Uber's intricate system architecture powers its platform, handling millions of requests, coordinating logistics, and ensuring a seamless experience for users. In this article, we'll explore the system design considerations for Uber, covering both non-technical and technical requirements, as well as low-level and high-level designs.Non-Technical RequirementsTechnical RequirementsUber's system design embodies a sophisticated blend of cutting-edge technologies, scalable architectures, and user-centric features to deliver a seamless transportation experience to millions of users worldwide. By addressing both non-technical and technical requirements, Uber has established itself as a pioneer in the on-demand transportation industry, setting the standard for reliability, efficiency, and innovation in system design.
How would you design a resource allocation app?
How would you design a resource allocation app?

March 24, 2024

In urban infrastructure, chambers serve as crucial connection points, facilitating various utilities. With the increasing demand for high-speed internet services, efficiently managing chambers becomes imperative. In this article, we'll delve into designing a web application using the Command Query Responsibility Segregation (CQRS) pattern to streamline chamber management.And a bit more data in a table format:The ProblemWe've had an influx of new customers wanting our 10Gbps internet product! We need a way of identifying theclosest chamber to the potential customer, ensuring we have capacity to connect them, and give us a headsup when we might need to increase capacity near a chamber.Write a web application that allows a Vorboss sales team member to enter details about a new customerordering our 10Gbps internet product. The application should call a backend API that does the following:Persist the details of the new customer in a data storeProvide the user with the ID of the closest chamber that has available capacity.Alert the user if the nearest chamber doesn't have capacity, but still provide the next closest that does have capacity.Alert the user if the provided chamber is now at capacity with the addition of the new customer.Then High Level Architecture Design:High Level API DesignPlease have a look at our swagger here and These will be the listsTwo roles: sales | customerUI layout and the User Flow:The Key points of implementations:If you want to know the little issues and technical solutions:Implementing CQRS in our chamber management application allows for efficient handling of commands and queries, optimizing resource allocation and enhancing user experience. By leveraging robust backend APIs and modern frontend frameworks, we can provide Vorboss sales team members with a streamlined order process while ensuring optimal chamber utilization.
How would you design a delivery app?
How would you design a delivery app?

March 9, 2024

Designing a delivery app that seamlessly connects users with their desired products requires careful consideration of functional requirements, technical needs, and high-level design principles. In this article, we'll explore the intricacies of system design for a delivery app, shedding light on the key components and considerations that drive its architecture.Functional Requirements:Technical Needs:High-Level Design:ConclusionDesigning a delivery app involves a harmonious blend of user-centric features, robust technical infrastructure, and efficient logistics management. By prioritizing functionality, scalability, and reliability, developers can create a delivery app that not only meets user expectations but also drives business growth and operational efficiency in the rapidly evolving landscape of on-demand services.
How would you design a messaging app?
How would you design a messaging app?

March 8, 2024

Designing a messaging app that offers a seamless user experience requires careful consideration of functional requirements, technical needs, and high-level design principles. In this article, we embark on a journey to explore the intricacies of system design for a messaging app, uncovering the key components and considerations that drive its architecture.Business Requirements:Technical Needs:High-Level Design:The messaging app follows a client-server architecture, with clients (mobile apps, web clients) interacting with server-side components to exchange messages and manage user accounts.The backend comprises services responsible for user authentication, message routing, storage management, and push notification delivery. These services are deployed on scalable cloud platforms and communicate with clients via APIs.A message queueing system facilitates asynchronous message delivery and ensures reliable message processing. Technologies like RabbitMQ or Apache Kafka handle message queuing and distribution.Persistent storage for user profiles, message history, and metadata is managed using scalable databases such as PostgreSQL or MongoDB. Data replication and sharding strategies are employed for fault tolerance and scalability.Messaging Queue wil helps us to do those tasks after realtime messaging between Client A and B. also later we can use Message Service to retrieve the history.ConclusionDesigning a messaging app entails a meticulous balance of functional requirements, technical considerations, and architectural decisions. By prioritizing real-time messaging, security, scalability, and reliability, developers can create an app that fosters seamless communication and connectivity among users. As messaging technology continues to evolve, innovations in artificial intelligence, chatbots, and augmented reality hold the promise of enriching the messaging experience further, paving the way for a future where communication knows no bounds.
How would you design an autocomplete for a search engine?
How would you design an autocomplete for a search engine?

March 8, 2024

In this discourse, we embark on a structured exploration of autocomplete, unravelling its underlying mechanisms and technical intricacies that propel it to the forefront of modern search functionality.Business Requirements:Technical Needs:ChallengesWhich is pretty simple to explain, User requests for suggestions to the server through API gateway and load balancers, and server if it has the answer from the past will return it, or request it from Database. The point is it should be some sort of task that helps up with indexing.How to Implement the Index?A Trie (or Prefix Tree) is a tree-like data structure that is used to store a dynamic set or associative array where the keys are usually strings. All the descendants of a node have a common prefix of the string associated with that node, and the root is associated with the empty string. An inverted index is a data structure used to create a full-text search. In an inverted index, there is a record for each term or word, which contains a list of documents that this term appears in. This approach is used by most full-text search frameworks such as Elasticsearch.Predictive models use machine learning algorithms to predict future outcomes based on historical data. In the context of the typeahead system, we could use a predictive model to suggest the most likely completions of a given prefix, based on the popularity of different completions in the past. This predicative nature is fundamentally how popular tools like ChatGPT works.Conclusion:Autocomplete systems represent a convergence of business imperatives, technical exigencies, and user-centric design principles in the realm of online search. By harmonizing the pursuit of enhanced user experiences with the technical challenges of scalability, real-time indexing, and semantic understanding, autocomplete systems emerge as indispensable tools for navigating the vast expanse of digital information. As the search landscape continues to evolve, the evolution of autocomplete remains intrinsically linked to the relentless pursuit of precision, relevance, and user empowerment in information retrieval.
How would you design an online file-sharing system?
How would you design an online file-sharing system?

March 8, 2024

In this article, we'll explore the intricacies of designing a robust and user-friendly online file-sharing system that meets the demands of today's users and businesses.Understanding the LandscapeBefore diving into the design process, it's crucial to understand the landscape of online file sharing. From individual users sharing personal files to enterprises collaborating on sensitive documents, the requirements for file-sharing systems vary widely. Key considerations include:Functional Requirements:Non-functional requirementsHigh Level Design How to have a better Block Server?To set up a block upload server using cloud storage services:What is the best way to have a Metadata Server?To create a metadata server:Synchronisation ServiceFor every new update, synchronisation service is responsible to efficiently process updates and apply changes to other subscribed devices to keep their local db and remote db in sync.Synchronisation service should be designed to transmit as less data as possible to avoid unnecessary network bandwidth and achieve a better response time. Server and client can calculate a hash (SHA-256) to check if chunk is updated or not. On server also, if we have the chunk with similar hash(even from another user), we can use the same chunk instead of creating a new copy to avoid data deduplication.ConclusionDesigning a seamless online file-sharing system requires careful consideration of user needs, security requirements, scalability, and performance. By leveraging modern technologies, best practices, and a user-centric approach, organizations can develop file-sharing solutions that enhance productivity, foster collaboration, and meet the evolving needs of users and businesses in today's digital landscape.
How would you design a URL-shortening service?
How would you design a URL-shortening service?

March 8, 2024

In the vast landscape of the internet, long URLs can often resemble tangled webs, making sharing cumbersome and inefficient. Enter the humble URL shortener service, a nifty tool that transforms lengthy links into compact, shareable snippets. Inspired by the likes of TinyURL, let's embark on a journey to design a scalable URL shortener service that can stand the test of time. Business Requirements:Technical Needs:High Level DesignImprove the SystemWhat algorithm to use for shortening URL?One commonly used algorithm for shortening URLs is the Base62 encoding algorithm. Here's how it works:For example:What database to use?For a URL shortener service, considering the need for fast retrieval and scalability, NoSQL databases like MongoDB or key-value stores like Redis are commonly used due to their high performance and flexibility. These databases excel in handling large volumes of data and offer efficient lookup operations, making them ideal choices for storing mappings between original URLs and their shortened versions. Additionally, they can be easily scaled horizontally to accommodate growing traffic and data storage requirements.ConclusionIn the vast expanse of the internet, a scalable URL shortener service plays a vital role in simplifying and streamlining the sharing of links. By leveraging modern technologies and best practices in system design, we can build a service that not only meets the demands of today but also scales gracefully to meet the challenges of tomorrow. So, the next time you encounter a lengthy URL, remember: with a little bit of magic from our URL shortener service, sharing links becomes as easy as a click of a button.
How would you design a parking lot?
How would you design a parking lot?

March 8, 2024

Ever circled a parking lot like a lost explorer searching for buried treasure? Fear not, for the age of tech has dawned upon the parking scene, promising smoother rides and fewer headaches. Let's take a dive into the geeky gears and gadgets powering the design of modern parking lot systems.Understanding the ChallengePicture this: a jam-packed parking lot, cars vying for spots like contestants in a game show. Designing a parking lot system isn't just about fitting more cars; it's about creating a stress-free journey for drivers. We're talking about: Simple ERD of the System:Components of the System DesignThe UI serves as the primary point of interaction between drivers and the parking lot system.It should be intuitive, mobile-friendly, and provide features such as real-time availability updates, reservation options, and payment processing.The backend infrastructure handles the core functionalities of the parking lot system, including data management, business logic, and communication with external services.It encompasses databases, servers, and APIs that facilitate seamless integration between different system components.An efficient database management system is crucial for storing and retrieving parking lot data, including information about available spots, reservations, and user accounts.It should be designed for scalability, reliability, and fast query processing to handle large volumes of data and concurrent user requests.This component is responsible for tracking the availability of parking spots in real-time.It may utilize sensors, cameras, or other IoT devices to detect occupancy and update spot status accordingly.The reservation system allows drivers to book parking spots in advance, ensuring availability upon arrival.It should support features such as flexible booking options, reservation modifications, and cancellation policies.Seamless payment processing is essential for enabling drivers to pay for parking securely and conveniently.It should support multiple payment methods, including credit/debit cards, mobile wallets, and contactless payments.Robust security measures, such as surveillance cameras, access gates, and authentication protocols, help ensure the safety of vehicles and drivers.Access control mechanisms prevent unauthorized entry and enforce parking regulations.ConclusionThe design of a parking lot system is a multifaceted endeavor that requires careful consideration of user requirements, operational constraints, and technological capabilities. By leveraging innovative technologies and best practices in system design, parking lot operators can create an ecosystem that not only optimizes space utilization and operational efficiency but also enhances the overall parking experience for drivers. As urban centers continue to evolve, the role of technology in reimagining the parking landscape will become increasingly prominent, paving the way for smarter, more sustainable transportation solutions.
How would you design a social media app?
How would you design a social media app?

March 8, 2024

Designing a social media app involves considering various aspects such as user experience, scalability, security, and features. Here's a high-level system design for a social media app:Business requirements:Technical Requirements:Data Structure:High Level Architecture:Which will be few layers of services. Bit More Detailed Architecture:More Things to ConsiderIn conclusion, building a social media app requires careful consideration of various components and considerations. From designing a robust architecture to implementing features that enhance user engagement and privacy, every aspect plays a crucial role in creating a successful platform. By prioritizing scalability, real-time updates, content moderation, accessibility, and user privacy, developers can ensure that the app meets the evolving needs and expectations of its users. Additionally, incorporating features such as offline functionality, analytics, and developer support can further enhance the app's functionality and user experience. Ultimately, a well-thought-out social media app that addresses both technical and user-centric aspects has the potential to captivate audiences, foster community engagement, and make a meaningful impact in the digital landscape.