Structural Design Problems
Structural Design Problems
Problem Statements
Problem 1:
You are architecting a high-traffic enterprise API gateway. Incoming HTTP requests require vary-
ing levels of processing depending on the endpoint, client tier, and current network load. Some
requests need SSL termination and gzip decompression; others require strict OAuth validation,
rate limiting, and request payload caching. You cannot create a monolithic handler, nor can you
create a static class hierarchy for every possible combination of processing rules. The system
must allow operations to be dynamically chained and executed sequentially at runtime while
maintaining the same core request handler interface.
→ Jump to Solution
Problem 2:
You are developing the core rendering pipeline for a modern 3D graphics engine. The engine
must manipulate individual geometric primitives (like spheres and cubes) but also handle mas-
sive hierarchical constructs, such as a fully articulated human character containing thousands
of sub-meshes grouped into limbs and joints. When the engine issues a spatial transform or
render command, it must propagate correctly through the entire hierarchy without the client
needing to query whether an object is a leaf primitive or a massive complex group.
→ Jump to Solution
Problem 3:
A global enterprise SaaS application features a multi-channel notification engine. The system
supports various abstract messaging tiers (e.g., Critical Security Alerts, Weekly Marketing Di-
gests, Transactional Receipts). Simultaneously, it utilizes multiple delivery platforms (SMS Gate-
ways, SMTP Email Servers, APNS Push Notifications). Coupling the message tier directly to the
delivery platform leads to an unmaintainable Cartesian product of classes. You need a structure
where the message type logic and the transmission platform logic can vary and scale indepen-
dently.
→ Jump to Solution
Problem 4:
A massive legacy ERP system processes all supply chain transactions using an archaic SOAP-
based XML API. The company has recently acquired a cutting-edge fleet management AI that ex-
clusively exposes its predictive routing capabilities via a modern RESTful JSON interface. Rewrit-
ing the core ERP’s transaction bus is impossible due to millions of lines of dependent code and
regulatory compliance. You must integrate the AI into the ERP’s workflow seamlessly, allowing
the ERP to call the AI exactly as if it were an old SOAP service.
→ Jump to Solution
Problem 5:
A MMORPG engine must calculate a player’s real-time combat statistics. A character’s base stats
are influenced by dozens of overlapping, dynamic states: active magical buffs, area-of-effect
1
debuffs, passive guild bonuses, and equipped items. Hardcoding all combinations or creating
a monolithic calculation method is unscalable. The architecture must allow these statistical
modifiers to be dynamically attached, detached, and stacked at runtime, augmenting the base
character’s behavior transparently.
→ Jump to Solution
Problem 6:
An international conglomerate requires a human resources platform to model its vast organiza-
tional structure. The system needs to calculate budget allocations and generate reporting lines.
The structure includes individual contributor employees, squads, departments, and entire re-
gional divisions. A budget calculation operation invoked on a regional division must seamlessly
aggregate the budgets of all underlying departments, squads, and individual employees with-
out the client writing deeply nested, type-checking loops.
→ Jump to Solution
Problem 7:
A high-performance Object-Relational Mapping (ORM) library is being built. It provides high-
level query abstractions (e.g., AggregatedQuery, PaginatedQuery). However, the library must
support multiple distinct backend database engines (MySQL, MongoDB, PostgreSQL), each with
radically different connection handling and query execution semantics. The query abstractions
must remain completely decoupled from the specific database driver implementations so that
a new database can be supported without rewriting any query logic.
→ Jump to Solution
Problem 8:
An aerospace simulation software relies on a mature, highly validated physics core that strictly
accepts inputs and returns outputs in the Metric system (meters, kilograms). A newly integrated
avionics UI module, provided by an American defense contractor, exclusively outputs control
signals and expects telemetry in the Imperial system (feet, pounds). You cannot alter either the
physics core or the external UI module, yet they must communicate bi-directionally in real-time.
→ Jump to Solution
Problem 9:
A live-streaming video processing server handles high-bitrate ingested feeds. Depending on
the broadcaster’s tier and audience platform, the stream must pass through a dynamic chain of
real-time filters: dynamic resolution scaling, logo watermarking, deep-learning noise reduction,
and color correction. The system must construct these filtering pipelines on-the-fly per stream,
ensuring that each filter cleanly wraps the next and modifies the video frame without requiring
a hardcoded massive class of all filter combinations.
→ Jump to Solution
Problem 10:
A cloud-native file storage system must manage resources via an administrative dashboard. The
storage architecture consists of individual binary files, standard directories, and virtual mounted
volumes. The administrative client needs to execute operations like permission adjustments
and space calculations on a single file, a directory containing millions of files, or an entire virtual
volume interchangeably, treating both scalar files and massive collections uniformly.
→ Jump to Solution
Problem 11:
You are developing a cross-platform UI framework. It features various high-level interactive ab-
stractions like ModalWindow, FloatingToolbar, and DraggablePanel. However, the framework
must render natively on Windows (using Win32 API), macOS (using Cocoa), and Linux (using
GTK). You must prevent a massive hierarchy explosion by fundamentally separating the UI con-
2
trol abstractions from the OS-specific drawing and event-handling implementations.
→ Jump to Solution
Problem 12:
A mature enterprise microservice currently validates user tokens against an internal security
library that conforms to an old, proprietary OAuth 1.0 standard. A company-wide mandate re-
quires migrating to a newly deployed, external Identity and Access Management (IAM) provider
that strictly uses OAuth 2.0 with JWTs. You must route the legacy microservice’s authentica-
tion calls to the new IAM provider without altering the microservice’s extensive internal security
logic.
→ Jump to Solution
Problem 13:
A fintech payment gateway dynamically calculates transaction fees. A base wire transfer has a
fixed cost, but the final fee must be dynamically modified by multiple runtime factors: foreign
exchange conversion margins, high-risk country surcharges, weekend processing fees, and VIP
client discounts. These pricing modifiers must be flexibly composable so the system can attach
any combination of them to a transaction before the final cost is executed.
→ Jump to Solution
Problem 14:
An enterprise agile project management tool tracks work progress. The system contains gran-
ular tasks, which are grouped into user stories, which are clustered into epics, which roll up into
massive multi-year projects. When an executive views a project’s completion metrics, the sys-
tem must natively aggregate these metrics down the entire hierarchy, treating a leaf task and
a complex epic identically from the caller’s perspective.
→ Jump to Solution
Problem 15:
A global e-commerce platform processes different configurations of payments, including Recur-
ringSubscription and EscrowTransaction. Simultaneously, it must route these through various
payment gateways like Stripe, PayPal, and a proprietary Crypto gateway. Creating a tightly cou-
pled architecture would require rigid classes for every combination. The transactional workflow
must be entirely decoupled from the actual payment processing APIs.
→ Jump to Solution
Problem 16:
An industrial IoT platform standardizes all incoming telemetry using a strict interface. A factory
has just installed a batch of highly advanced, proprietary vibration sensors from a new vendor.
These new sensors use a completely different, non-standard protocol and expose methods that
do not match the expected system interface. You must integrate the new hardware into the
existing monitoring dashboard without rewriting the dashboard or the vendor’s closed-source
SDK.
→ Jump to Solution
Problem 17:
A self-driving vehicle’s telemetry system streams raw Lidar and optical data. Before this data
reaches the neural network, it must be dynamically pre-processed depending on weather con-
ditions. Operations include thermal noise reduction, rain-glare filtering, and predictive smooth-
ing. These operations must be stacked and reordered on the fly without changing the underly-
ing raw data stream component.
→ Jump to Solution
Problem 18:
3
A deep learning framework models complex neural network topologies. The architecture con-
sists of individual neurons, dense layers containing hundreds of neurons, and massive sub-
networks. During the forward propagation and backpropagation phases, the training loop must
call gradient and weight update commands. These commands must flow through a single neu-
ron or an entire sub-network interchangeably without the training loop analyzing the structural
depth.
→ Jump to Solution
Problem 19:
A sophisticated digital media player software supports various media abstractions, such as
PlaylistView, SingleTrackView, and ContinuousRadioView. Behind the scenes, the audio decod-
ing is handled by different low-level codecs (MP3, FLAC, OGG). The application must cleanly sep-
arate the user-facing media playback logic from the low-level bitstream decoding implementa-
tions, allowing developers to add new view abstractions without touching the codec logic.
→ Jump to Solution
Problem 20:
A legacy reporting dashboard was hardcoded to pull data using a highly specific local SQLite
connection wrapper. The backend infrastructure has just been fully migrated to a cloud-native
PostgreSQL cluster. The legacy dashboard cannot be decommissioned yet and its source code
is too fragile to refactor. You must route the dashboard’s bespoke SQLite-style querying calls
into the new PostgreSQL connection driver seamlessly.
→ Jump to Solution
Problem 21:
A distributed cloud logging system captures raw application events. Based on compliance rules,
the logs must be dynamically transformed before storage. Some logs need PII redaction, others
require strong cryptographic signing, and high-volume logs require aggressive compression.
These transformation responsibilities must be attached to the logging pipeline dynamically at
runtime, avoiding a combinatorial explosion of static log handler classes.
→ Jump to Solution
Problem 22:
A mathematical computation engine builds dynamic abstract syntax trees (AST) to evaluate com-
plex algebraic formulas. The tree consists of scalar numeric values (constants) and complex
operational nodes (Addition, Multiplication) that contain other nodes. An evaluate command
issued to the root of the equation must naturally execute across both simple constants and
deeply nested operational expressions uniformly.
→ Jump to Solution
Problem 23:
A military simulation platform models various autonomous entities, including ReconDrones and
ArmoredTransports. These entities rely on different navigation sub-systems (GPS-based, Iner-
tial Tracking). The simulation must permit any entity type to be dynamically paired with any
navigation sub-system without creating rigid classes. The entity logic and the navigation logic
must evolve independently.
→ Jump to Solution
Problem 24:
An algorithmic trading firm uses a high-speed internal event bus that expects all market tick
data in a standardized JSON format. They recently subscribed to a premium ultra-low-latency
market data feed that strictly outputs data in the financial FIX binary protocol. You must connect
this new feed to the internal bus, translating the FIX bitstreams into the expected JSON objects
on the fly.
4
→ Jump to Solution
Problem 25:
A cloud service provider’s dynamic billing engine calculates the hourly cost of a virtual machine.
The base compute instance cost is static, but users can hot-swap features: adding a static IP,
attaching NVMe block storage, or enabling DDoS protection. The billing engine must calculate
the total cost by dynamically encapsulating the base instance with these pricing modifiers at
runtime.
→ Jump to Solution
Problem 26:
An online retailer’s inventory system supports sophisticated product bundling. Customers can
buy individual items, pre-packaged boxed sets, or massive mega-bundles containing boxes and
individual items. When the checkout system calculates the total shipping weight, it must recur-
sively interrogate the cart contents, treating a single item and a mega-bundle identically via a
unified interface.
→ Jump to Solution
Problem 27:
A smart home IoT hub application controls appliances. The app features different control in-
terfaces: a BasicRemote and an AdvancedRemote. These remotes must interact with disparate
hardware implementations (e.g., Hue API, Nest API). The remote control logic must be cleanly
separated from the specific hardware API calls, preventing a monolithic tangle of device-specific
controllers.
→ Jump to Solution
Problem 28:
A modern game engine’s asset pipeline strictly imports 3D models using the open GLTF format.
A contracted art studio has delivered thousands of assets in an old, proprietary Autodesk .MAX
binary format. The engine’s core import logic cannot be rewritten. You must build a component
that intercepts the engine’s GLTF import calls and translates them to parse the .MAX binary data.
→ Jump to Solution
Problem 29:
A web-based rich text editor renders document blocks. A base text block can have multiple
dynamic visual styles applied sequentially: bolding, italics, URL hyperlinking, and syntax high-
lighting. The editor must render the final HTML by chaining these styling operations dynamically
based on user selection, preventing the need to hardcode classes for every possible style com-
bination.
→ Jump to Solution
Problem 30:
A headless web scraper builds a virtual Document Object Model (DOM) to parse pages. The
structure includes scalar text nodes and complex HTML container elements that hold other el-
ements or text. When the scraper runs a query traversal operation, it must traverse seamlessly
through the tree, interacting with both leaf nodes and complex container nodes using identical
method signatures.
→ Jump to Solution
Problem 31:
An enterprise logging framework requires different logger abstractions (e.g., DiagnosticLog-
ger, ComplianceLogger). It must also support multiple sink destinations (e.g., local rotating
files, AWS CloudWatch, Elasticsearch). The system must decouple the high-level logging intent
from the low-level destination transport mechanisms, allowing flexible log routing without rigid
5
subclasses.
→ Jump to Solution
Problem 32:
A corporate intranet application authenticates users via deep, legacy Windows Active Direc-
tory COM libraries. The IT department is forcing a migration to a cloud-based Identity Access
Management (IAM) utilizing standard SAML 2.0 assertions. You must integrate the SAML 2.0
workflow to satisfy the application’s existing AD-based authentication calls without altering the
legacy security flow.
→ Jump to Solution
Problem 33:
An airline reservation system prices tickets dynamically. The base fare is continually modified
by runtime add-ons: extra baggage fees, priority boarding, in-flight Wi-Fi, and travel insurance.
The checkout workflow must be able to dynamically accumulate these features, calculating the
total price and generating the itemized receipt by wrapping the base ticket layer by layer.
→ Jump to Solution
Problem 34:
A real-time strategy (RTS) game models military units. A player can select a single marine, a
squad of 12 marines, or an entire battalion of squads and tanks. When the player issues a
movement command, the game engine must distribute this command appropriately, treating
the selection identically whether it is a single leaf unit or a massive nested group.
→ Jump to Solution
Problem 35:
A financial reporting tool generates complex analytics. The reporting abstractions include Sum-
maryReport and PredictiveForecast. These reports must be output in vastly different formats:
highly styled PDF, raw CSV, and HTML5. You must decouple the report generation logic from the
rendering engine to prevent a combinatorial class explosion across report types and formats.
→ Jump to Solution
Problem 36:
A massive logistics dashboard aggregates weather data to predict shipping delays. It was built
relying heavily on an archaic government weather API that returns complex XML documents.
The government has replaced this API with a modern JSON-based REST service. You must bridge
the new JSON API to output the exact XML structures the legacy dashboard expects.
→ Jump to Solution
Problem 37:
An automotive software system configures the software limits of a newly manufactured car. The
base chassis has standard speed and power limits. Depending on the purchased digital pack-
ages, the system dynamically adds behaviors: unlocking maximum battery draw, or enabling
autonomous highway driving. These software unlocks must wrap the vehicle’s base control in-
terface dynamically.
→ Jump to Solution
Problem 38:
An industrial food manufacturing system tracks production recipes. A final product consists of
raw ingredients and complex sub-recipes (sauces, dough), which themselves may contain other
sub-recipes. When the system executes a nutritional calculation function, it must recursively
traverse the entire recipe tree, treating raw ingredients and complex sauces uniformly.
→ Jump to Solution
6
Problem 39:
An enterprise security gateway handles authentication flows. The workflows differ (e.g., Biomet-
ricLogin, PasswordlessLogin). Simultaneously, the backend verification providers differ (e.g.,
Apple FaceID, Corporate LDAP). The gateway must cleanly separate the high-level user login ex-
perience from the low-level provider verification calls.
→ Jump to Solution
Problem 40:
A legacy C++ physics simulation uses a highly optimized, proprietary linked-list implementa-
tion. A newly imported open-source collision detection library demands that all spatial data be
passed using the standard library vector interface. Rewriting the core simulation would destroy
performance. You must create an interface wrapper that makes the proprietary linked-list look
and behave exactly like a generic vector.
→ Jump to Solution
Problem 41:
A network security appliance inspects incoming traffic for threats. The base inspection involves
simple signature matching. Based on the threat level, the system dynamically layers on deeper
inspections: heuristic payload execution, IP reputation checks, and anomaly detection. The ap-
pliance must flexibly wrap the base inspection process with these heavy operations at runtime.
→ Jump to Solution
Problem 42:
An infrastructure-as-code (IaC) tool models data center topologies. The architecture includes
individual servers, blade chassis, and entire availability zones. An administrative command like
a patch deployment must execute recursively and safely across the topology, allowing an admin
to target a single server or an entire zone using the exact same interface.
→ Jump to Solution
Problem 43:
An industrial control system interfaces with various fluid sensors. The high-level usage patterns
vary (Continuous vs Threshold Alerting). The physical communication protocols also vary widely
based on the manufacturer (RS-485, Modbus TCP). The architecture must decouple the high-
level polling logic from the low-level hardware byte-reading protocols.
→ Jump to Solution
Problem 44:
A highly successful mobile app streams music using an old, reliable C-based MP3 decoding
library that relies on synchronous, blocking I/O calls. To support modern UI responsiveness,
the app’s architecture has been rewritten to use an asynchronous, reactive streamer interface.
You must integrate the old blocking C library into the new reactive architecture without freezing
the UI thread.
→ Jump to Solution
Problem 45:
A global shipping company’s routing engine calculates optimal paths. A base shipment calcu-
lates standard transit time. Customers can add dynamic logistical constraints: refrigeration
requirements, fragile handling, and high-security GPS escorting. The routing engine must dy-
namically modify the base shipment’s routing algorithm by composing these constraints at run-
time.
→ Jump to Solution
Problem 46:
A continuous integration (CI) server executes testing workflows. The structure consists of in-
7
dividual unit tests, test suites, and massive deployment pipelines. When the CI server triggers
an execution command, it must elegantly cascade down the hierarchy, aggregating states from
individual tests up to the master pipeline without hardcoding the traversal logic.
→ Jump to Solution
Problem 47:
A multi-cloud backup software handles massive data synchronization. The backup strategies
(abstractions) include IncrementalBackup and Snapshot. The target storage platforms (imple-
mentations) include AWS S3 and on-premise SANs. The system must decouple the complex logic
of determining what files to back up from the specific API calls of how to upload the bytes to
the target platform.
→ Jump to Solution
Problem 48:
An automated pharmacy dispensing robot relies on a legacy barcode scanner that outputs data
exclusively over a physical serial port using an interrupt-driven protocol. The robot’s new central
computer lacks serial ports and uses a modern USB Human Interface Device (HID) architecture.
You must interface the legacy serial protocol into the modern USB HID event bus seamlessly.
→ Jump to Solution
Problem 49:
A modern FPS game engine relies on a highly modular weapon system. A base assault rifle
has standard damage and recoil profiles. The player can dynamically attach modifications: a
suppressor, an extended magazine, and a laser sight. The engine must calculate the weapon’s
real-time statistics by dynamically composing these attachments over the base weapon.
→ Jump to Solution
Problem 50:
A distributed SQL database engine constructs complex query execution plans. The plan is an ab-
stract tree containing leaf nodes (TableScans) and complex operation nodes (HashJoins, Merge-
Sorts) that consume data from child nodes. The execution engine must stream rows by repeat-
edly calling a fetch method on the root node, completely agnostic to whether it is interacting
with a leaf scan or a massive join.
→ Jump to Solution
Problem 51:
A video conferencing platform adjusts bitrates dynamically. The connection abstractions in-
clude AudioOnly and ScreenShare. The underlying transmission implementations include We-
bRTC and a proprietary UDP protocol. The system must completely decouple the connection
state management and UI abstractions from the low-level socket and packet transmission im-
plementations.
→ Jump to Solution
Problem 52:
A critical scientific visualization tool was written using legacy OpenGL 1.1 fixed-function pipeline
calls. It must now run on modern environments that only support the Vulkan API, which requires
pre-compiled command buffers and explicit memory management. You must write a transla-
tion layer that catches the immediate-mode OpenGL calls and packages them into valid Vulkan
command buffers.
→ Jump to Solution
Problem 53:
A custom desktop environment renders application windows. A standard window is just a blank
rectangular canvas. The window manager dynamically adds visual decorators: a title bar, a
8
resizable border, drop shadows, and a scrollbar. The graphics engine must render the final
window by chaining these modular decorators at runtime based on the application’s request.
→ Jump to Solution
Problem 54:
A wealth management platform calculates the total risk and value of client portfolios. A portfolio
contains scalar assets (stocks, bonds) and complex, nested financial instruments (mutual funds,
ETFs containing various assets). When the system executes an assessment, it must recursively
navigate this financial hierarchy, treating a single share of stock and a massive mutual fund
interchangeably.
→ Jump to Solution
Problem 55:
An autonomous drone delivery fleet utilizes an advanced routing algorithm. The operational
modes (abstractions) include EmergencyMedicalDrop and SurveyFlight. The actual flight hard-
ware interfaces (implementations) vary between Quadcopters and Fixed-Wing VTOLs. The sys-
tem must decouple the high-level flight mission logic from the low-level motor control systems
of the specific drones.
→ Jump to Solution
Problem 56:
An enterprise portal integrates employee data. The old HR mainframe dumps employee status
updates nightly as heavily formatted CSV flat files. The modern portal’s backend is entirely
event-driven, expecting real-time GraphQL mutations for any state changes. You must integrate
the nightly CSV process into the portal by converting the flat-file rows into seamless GraphQL
network requests.
→ Jump to Solution
Problem 57:
A healthcare interoperability platform processes incoming raw patient data streams. Before the
data is committed to the database, it must pass through a dynamic gauntlet of processors: strict
anonymization, HL7 formatting, semantic validation, and cryptographic signing. The system
must allow administrators to dynamically construct these processing pipelines without altering
the base data ingestion logic.
→ Jump to Solution
Problem 58:
A responsive web design framework manages the layout of complex dashboards. The layout
engine processes individual UI elements (text boxes) and container elements (flex grids, vertical
stacks) which hold other elements. When the browser resizes, the engine must execute the
math recursively through the entire tree of containers and elements seamlessly.
→ Jump to Solution
Problem 59:
A sophisticated big data analytics tool provides dynamic data visualizations. The chart abstrac-
tions include TimeSeries and HeatMap. The rendering engines include an HTML5 Canvas im-
plementation and a high-performance WebGL renderer. The chart interaction logic must be
fundamentally decoupled from the actual pixel rendering implementations.
→ Jump to Solution
Problem 60:
An international e-commerce site processes transactions through a highly reliable, but legacy,
synchronous payment clearinghouse that blocks the executing thread. The e-commerce site
has migrated to a modern, fully reactive microservices architecture. You must encapsulate the
9
synchronous clearinghouse API within an asynchronous wrapper that emits events, bridging
the two paradigms.
→ Jump to Solution
10
Solutions
11
Solution 13: Decorator Pattern
Implement transaction fee modifiers as decorators that wrap the base transaction, dynamically
adding their specific algorithmic surcharges and discounts to the total before final execution.
12
lessly.
13
Solution 41: Decorator Pattern
Chain network security inspection protocols dynamically by wrapping the base packet inspector
with deep heuristic and machine learning detection layers at runtime based on load.
14
Solution 55: Bridge Pattern
Separate high-level flight mission abstractions (Survey, Emergency) from the low-level hardware-
specific motor and telemetry implementations of different physical drone configurations.
15