Modular Architecture Interview Questions

4 questions developers actually get asked about modular architecture — with clear, practical answers you can use to prepare.

Q1. What is modular architecture and why does it matter for AI coding assistants?

Modular architecture is the practice of splitting a codebase into small, self-contained modules that each have a single responsibility and communicate through a narrow public interface. It matters for AI coding assistants because models have a limited context window: a 300-line module fits cleanly and gets accurate suggestions, while a 5,000-line monolith forces the AI to guess about code it cannot see. Smaller, well-bounded modules also mean fewer unintended cascades when the AI edits code, so its changes stay on target.

Q2. What is the difference between a module and a file?

A file is a single source file on disk, while a module is a logical unit of functionality with a defined public interface that the rest of the codebase depends on. A module can live in one file or span an entire folder of files, as long as it exposes a consistent public API and hides its internals. The distinction matters because splitting code across many files does not give you modular architecture unless those files share a clear boundary and a stable contract.

Q3. How do you decide when to split code into a new module?

Split when a chunk of code has a single cohesive responsibility that could change for reasons different from the rest of the codebase. Common signals: the same function is imported in many unrelated places, a feature is large enough that you keep scrolling past it, or the code mixes concerns (database access next to HTTP parsing, for example). A good rule of thumb is that each module should fit comfortably in an AI assistant's context window, roughly 300 to 500 lines.

Q4. What is a circular dependency, and how do you break one?

A circular dependency happens when module A imports from module B and module B also imports from module A, directly or through a chain. It causes tightly coupled code that is hard to test in isolation and often leads to runtime import errors in languages like Python and JavaScript. Typical fixes are extracting the shared types or functions into a third neutral module, inverting one of the dependencies through an interface or callback, or merging the two modules if the separation was artificial to begin with.

Want the full concept, analogies, and AI prompts for modular architecture?

Read the full Modular Architecture block →