How to identify core entities and design clean APIs in system design interviews.
Finished this lesson?
Sign in to save your progress across devices.
Tip: use β and β to move between lessons.
Was this lesson helpful?
Rehearse this with a Staff+ engineer
45-minute mock with a Staff+ engineer who interviews at your target company. Premium members save $20.
After gathering requirements, the next step is to identify the core entities in your system and design the APIs that allow users and services to interact with them. This foundational work shapes everything that follows.
Before diving into architecture diagrams, you need to answer two fundamental questions:
Getting this right makes the high-level design almost obvious. Getting it wrong leads to awkward architectures and confused interviewers.
Think of entities as your nouns and APIs as your verbs. Together, they tell the story of what your system does.
Entities are the fundamental data objects your system manages. They emerge naturally from your requirements.
From the requirements (posting, following, viewing feed), we can identify:
| Twitter Core Entities | |
|---|---|
| Name | Description |
| User | People who use the platform - have profile, followers, following |
| Tweet | The content users create - text, media, timestamps |
| Follow | Relationship between users - who follows whom |
| Like | User engagement with tweets |
| Timeline | Aggregated feed of tweets for a user (can be derived/cached) |
| E-Commerce Core Entities | |
|---|---|
| Name | Description |
| User | Customers and sellers |
| Product | Items for sale - name, price, inventory |
| Order | Purchase transaction - items, total, status |
| Cart | Temporary holding for items before checkout |
| Payment | Financial transaction details |
| Review | |
What interviewers expect varies significantly by level:
| Entity Design Expectations by Level | |
|---|---|
| Name | Description |
| Mid-Level (L4) | Identify 3-5 obvious entities with basic attributes. Show understanding of primary keys and simple relationships. |
| Senior (L5) | Consider entity lifecycle, denormalization for read performance, and how entities map to storage choices. Discuss trade-offs. |
| Staff+ (L6+) | Think about entity evolution over time, multi-tenancy implications, cross-service entity ownership, and data governance. |
| Engineering Manager | Focus on how entity design affects team boundaries, API contracts between teams, and long-term maintainability. |
Entity Identification Practice
For a ride-sharing app like Uber, what are the core entities? Consider: What data needs to persist? What relationships exist? What might need to be denormalized for performance?
Core Entities:
Key Insight: Location data is often handled separately from traditional entities because it's high-frequency, time-series data that benefits from specialized storage (like Redis or a time-series database).
Once you have entities, design the APIs that allow interaction with them. Focus on the most critical operations first.
# User APIs
POST /users # Create user (signup)
GET /users/{id} # Get user profile
PUT /users/{id} # Update profile
DELETE /users/{id} # Delete account
# Tweet APIs
POST /tweets # Create tweet
GET /tweets/{id} # Get single tweet
DELETE /tweets/{id} # Delete tweet
GET /users/{id}/tweets # Get user's tweets (paginated)
# Follow APIs
POST /users/{id}/follow # Follow a user
DELETE /users/{id}/follow # Unfollow a user
GET /users/{id}/followers # Get followers (paginated)
GET /users/{id}/following # Get following (paginated)
# Timeline API
GET /timeline # Get authenticated user's feed (paginated)
# Engagement APIs
POST /tweets/{id}/like # Like a tweet
DELETE /tweets/{id}/like # Unlike a tweet
| API Style Guide | |
|---|---|
| Name | Description |
| REST | Best for: CRUD operations, resource-oriented systems, public APIs. Most common choice. |
| GraphQL | Best for: Complex queries, mobile apps needing flexibility, reducing over-fetching. |
gRPC | Best for: Internal service-to-service communication, high-performance needs, streaming. |
| WebSocket | Best for: Real-time bidirectional communication like chat, live updates, gaming. |
| API Design Expectations by Level | |
|---|---|
| Name | Description |
| Mid-Level (L4) | Design basic CRUD endpoints with clear naming. Understand REST conventions. Include pagination for lists. |
| Senior (L5) | Consider rate limiting, authentication/authorization, versioning, error handling, and idempotency for mutations. |
| Staff+ (L6+) | Discuss API evolution strategy, backward compatibility, deprecation policies, and cross-service API contracts. |
| Engineering Manager | Focus on API governance, documentation standards, and how API design affects team velocity and external developers. |
Every list endpoint needs pagination at scale. Without it, you'll timeout or OOM.
# Bad
GET /users/{id}/followers # Returns all 10M followers
# Good
GET /users/{id}/followers?cursor=abc&limit=20
For important writes, consider idempotency keys:
# Without idempotency - double-charge risk
POST /payments {amount: 100}
# With idempotency - safe to retry
POST /payments {amount: 100, idempotency_key: "user123-order456"}
Use opaque, non-sequential IDs for security:
# Bad - reveals information, easy to guess
GET /users/12345
# Better - opaque ID
GET /users/usr_a1b2c3d4e5
At scale, you'll need batch endpoints:
# Inefficient - N API calls
GET /users/1
GET /users/2
GET /users/3
# Efficient - 1 API call
GET /users?ids=1,2,3
# or
POST /users/batch {ids: [1, 2, 3]}
Don't over-engineer your API in the interview. Start simple, then mention: "We could add bulk endpoints, rate limiting, and versioning as the system matures."
Here's how to present entities and APIs in your interview:
You: "Based on our requirements, let me identify the core entities. For this Twitter-like system, we have Users, Tweets, and Follows as our primary entities. Users have profiles and credentials. Tweets have content, timestamps, and reference their author. Follows represent the relationship between users.
For our API, I'll focus on the critical paths. We need endpoints to create and read tweets, follow/unfollow users, and most importantly, fetch the timeline. The timeline endpoint will be our most called API and needs pagination with cursor-based navigation.
Should I sketch out the key API signatures, or shall we move to the high-level architecture?"
This presentation takes about 2-3 minutes. It shows structured thinking without getting lost in details. Always offer the interviewer a chance to redirect.
With entities and APIs defined, you have a clear contract for what the system does. Next, we'll design the high-level architecture that makes it all work at scale.
| User feedback on products |