Design Stack Overflow
| Difficulty: Easy | Source: awesome-low-level-design |
Requirements
- Post questions, answer questions, comment on both
- Vote on questions and answers
- Questions have tags
- Search by keywords, tags, or user profiles
- Track reputation scores
- Handle concurrent access
Class Diagram

Classes, Interfaces and Enumerations
| Class/Interface | Description |
|---|---|
| User | id, username, email, reputation |
| Question | id, title, content, author, answers, comments, tags, votes, creation date |
| Answer | id, content, author, question, comments, votes, creation date |
| Comment | id, content, author, creation date |
| Tag | id, name |
| Vote | Associated with question or answer |
| StackOverflow | Main class: user creation, posting, voting, searching |
Design Patterns Used
| Pattern | Application |
|---|---|
| Singleton | StackOverflow main class ensures a single system instance |
| Composite/Hierarchy | Questions contain answers which contain comments, forming a tree |
| Observer-like | Reputation updates triggered by votes on questions/answers |
| Facade | StackOverflow class provides a simplified interface to the subsystems |
Code Implementations
| Language | Source Code |
|---|---|
| Java | View on GitHub |
| Python | View on GitHub |
| C++ | View on GitHub |
| C# | View on GitHub |
| Go | View on GitHub |