Design Retail Stock Brokerage

Retail stock brokerage inspired by Robinhood-style brokers: orders validated against buying power and acknowledged immediately, routed asynchronously over FIX to market makers and exchanges, fills booked to a double-entry ledger, and live quotes streamed over WebSockets. A teaching design.

Functional requirements

  • Place buy/sell orders (market, limit, stop-loss) for listed equities; receive order confirmation with order ID
  • Cancel or modify a pending order before it is matched
  • View real-time portfolio: current holdings, unrealised P&L, available margin
  • Receive real-time order fill notifications (WebSocket push)
  • Stream live market data: best bid/ask, last traded price, volume for any instrument
  • View order history and past trades with timestamps and execution prices

Non-functional requirements

  • Order placement latency < 10ms p99 from API receipt to exchange acknowledgement
  • Market data freshness < 100ms lag from exchange tick to client display
  • Zero duplicate order fills — matching engine must be strictly serialised
  • All trades immutably logged for regulatory audit within 500ms of execution
  • 99.99% availability during market hours (9:15 AM – 3:30 PM IST / 9:30 AM – 4:00 PM EST)
  • Portfolio P&L calculations consistent within 1 second of a trade execution

How the design evolves

Stage 1: Single Server, Orders Sent While the User Waits

See why a synchronous order path and per-holding quote lookups can't handle market open.

What was missing: Nothing yet.

Why that's risky: At market open, order volume and quote updates spike together; orders wait on exchange round trips, a retry can submit the same order twice, and the feed competes with users for one server.

What gets added: One server that checks cash, sends each order to the exchange while the user waits, and values portfolios by fetching a quote per holding.

Trade-offs: Simple, but the slowest external system sets the user's latency.

Stage 2: Orders Recorded First, Routed Asynchronously, Booked to a Ledger

Acknowledge orders fast and safely, and keep money and shares in a ledger that always balances.

What was missing: Orders waited on the exchange, retries could duplicate them, and holdings weren't kept as a ledger.

Why that's risky: Portfolio views read the ledger on every refresh, and prices only update when the user refreshes.

What gets added: An order service that validates, reserves buying power atomically, records the order with an idempotency key and acknowledges it; a routing queue and smart order router that send orders over FIX to market makers or exchanges; and a position updater that books each fill to a double-entry ledger. Market data has its own ingest path into a latest-quotes cache. Like most retail brokers, it routes orders to venues rather than matching them itself.

Trade-offs: Users see 'received' first and the fill a moment later, rather than waiting for both.

Stage 3: Positions Cache and Live Quotes over WebSockets

Make portfolio views instant and stream prices to the app.

What was missing: Portfolios read the ledger every time, and prices weren't live.

Why that's risky: Users don't find out an order filled unless they look.

What gets added: A positions cache updated on every fill, a quote stream, and quote gateways that hold each app's WebSocket and push updates for watched symbols, conflated to a few per second.

Trade-offs: Conflating quotes drops intermediate ticks the eye can't follow anyway.

Stage 4: Fill Notifications

Tell users the moment their order fills.

What was missing: Fills were silent.

Why that's risky: There's no way to find an instrument by name, nothing limits runaway clients, and nobody watches routing latency.

What gets added: A fill alerts queue and a notifier that sends a push notification and email for every fill.

Trade-offs: Notifications are sent after booking, so they never announce a fill the ledger doesn't have.

Stage 5: Instrument Search, Rate Limits and Monitoring

Let users find instruments, contain runaway clients, and watch every step.

What was missing: No search, no per-account limits, no monitoring.

Why that's risky: Remaining risk is regulatory and regional: audit trails and a hot standby region.

What gets added: Instrument search over symbols and company names, rate limits on order submission per account, and monitoring of acknowledgment latency, routing time, fill booking lag, quote freshness and ledger balance checks. End-of-day reconciliation with the clearing firm checks the ledger against the official record.

Trade-offs: Strict order limits can block a legitimate burst; limits are per account and visible to the user.

PRISM
System Design Interview
Round 1 of 4 · Architecture Design · 60:00 remaining
PRISM logo PRISM logo
Problems
AI Interview
Interview Challenges
Build & Stress Test NEW
System Architectures
Design & Fix NEW
Interactive Roadmap
System Design Guides Interview Prep Guide
Problems
Today's mission
Notifications
    Theme
    Pricing Community NEW Send feedback Report a problem NEW
    Sign in
    Theme
    Community NEW Send feedback Report a problem NEW
    All problems
    Phase
    Build & Stress Test
    Phase 01: Thinking in Systems
    Upcoming

    Components

    User
    CDN
    Load Balancer
    Server
    Cache
    Database
    Blob Storage
    Search Index
    Queue
    Worker
    Rate Limiter
    Service
    API Gateway
    Reverse Proxy
    WebSocket Server
    Third-party API

    Inspector

    Notes
    Use clear names so your design intent is easy to understand.
    Good
    Name by business meaning
    "Order API", "Restaurant Service"
    Avoid
    Generic names = zero signal
    "Server 1", "API", "Queue"
    A short description for each component makes feedback much better.
    100%
    Start by identifying:
    • Users & entry points
    • APIs & services
    • Databases & storage
    • Traffic flow & scale

    Round 1 of 4 Architecture Design

    Run a simulation to see results.

    Time Remaining
    60:00
    System Design Interview

    What are the core functional requirements?
    What are the key non-functional constraints?

    Questions

    Start Evaluation to unlock questions.

    EVALUATE MODE

    Test yourself like it's the real thing.

    A structured 4-module evaluation that mirrors how top companies assess system design candidates.

    Architecture Design
    Draw your system on the canvas. Define components, connections, and data flow.
    FR & NFR Requirements
    Answer functional and non-functional requirement questions about your design.
    MCQ Round
    Multiple choice questions testing your depth on the chosen system.
    Tradeoff Analysis
    Justify your design decisions and defend your architectural tradeoffs.
    AI Report Generated
    Choose a Problem
    No problem selected
    • 30 min
    • 45 min
    • 60 min
    Round 2 of 4
    MCQ Round
    Answer multiple-choice questions based on your design.

    Exit Interview?

    You're in the middle of an interview session. Leaving now will end your current attempt.

    Your progress will be saved.

    Open a saved design

    Select a design to load into the canvas.

    My Evaluations

    Your past evaluation sessions

    Here’s a simple request flow that follows the expected layer order.

    External User
    →
    Edge CDN → API Gateway → Load Balancer
    →
    Compute App Servers / Services
    →
    DataAccess Cache
    →
    Storage Database / Search Index
    →
    Async Queue → Worker

    Tip: keep arrows moving forward through layers (Edge → Compute → Storage). Avoid sending storage back to compute.

    Evaluation Instructions

    Read the rules carefully before starting. The test auto-submits on refresh.

    Before you start

    • Build your architecture on the canvas. The timer starts when you click Start Evaluation.
    • Don't forget to answer Functional Requirement and Non Functional Requirements.
    • When satisfied with your design, click Next to lock it and view the questions.
    • Please answer final step questions to complete the evaluation.

    Dos

    • Do read each question carefully before answering.
    • Do include required components to maximize component coverage.
    • Do save a copy of your design if you want to keep it before submission.

    Don'ts

    • Don't refresh or close the tab during an active evaluation — this will auto-submit your answers.
    • Don't switch app modes or open another tab while the evaluation is running.
    • Don't attempt to edit the design after clicking Next; the workspace will be locked.

    All the best!!

    Confirm

    Input

    Notice

    Evaluation Report
    Report a problem

    Evaluation Complete

    Generating Your Report

    Hang tight — our AI is evaluating your design…

    Did you know?

    Loading…

    Share feedback

    Tell us what worked well and what we can improve.

    Let's personalize this

    Answer a couple of quick questions so we can tailor your journey and missions.

    Your welcome gift: of Full PRISM Access

    Your Pro access starts as soon as you press Start my journey.

    SYSTEM BRIEF

    System Constraints

    What the system must do — every item is a user-facing behaviour your architecture must support.

      ↑ Engineering Constraints

      These are the failure modes you must design against — latency SLAs, durability targets, traffic ceilings.

        ⇆ Architecture Constraints

        Core Concepts to Master

        Your Journey
        PHASE – –
        0 / 0 0%
        0
        Mock Interview Checklist

        Pick a topic to start

        Explore concept overviews, real-system examples, key tradeoffs, and interview talking points for each roadmap section.

        Phase Mastered

        You've conquered this phase. These are the skills you now own:

          +500 XP

          Company Interview Paths

          Progress Summary