Design a Chatbot with Object-Oriented Principles
Company: OpenAI
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Technical Screen
# Design a Chatbot with Object-Oriented Principles
Create an object-oriented design for a chatbot system. Define the responsibilities and relationships needed to manage conversations, participants, messages, delivery, and provider-specific model behavior without coupling every class to one implementation.
### Constraints & Assumptions
- Focus on domain and interface design rather than distributed deployment scale.
- A conversation contains ordered messages and may receive streamed assistant output.
- The design should permit a model provider or storage adapter to be replaced.
### Clarifying Questions to Ask
- Can multiple users participate in one conversation?
- Must message edits or retries be retained?
- Is streaming part of the domain contract or an adapter concern?
```hint Assign ownership
Give each object one reason to change and keep infrastructure behind interfaces.
```
### What a Strong Answer Covers
- Core entities, invariants, and object relationships.
- Interfaces for generation, storage, delivery, and observability.
- Conversation ordering, retries, cancellation, and partial streamed messages.
- Extension points and tests that avoid a monolithic manager class.
### Follow-up Questions
1. How would you add tool calls without changing every existing message type?
2. Where would authorization checks belong?
Quick Answer: Study an extensible object-oriented chatbot design with clean entities, replaceable providers, streaming states, and testable boundaries.