← Early-stage Startup Interview Insights

Early-stage Startup·Backend Engineer·Onsite - Coding / Algorithms·Intermediate

IntermediatePrefer not to say
Apr 2026

Summary

Machine coding round for a backend role, 90 minutes to build a train booking system from scratch. Decent challenge but the time pressure was real and the bonus cancellation/refund feature was basically a pipe dream.

Questions Asked (3)

Q1

Design a Train Booking System with APIs for searching trains between stations, checking seat availability, booking tickets, and optionally handling cancellations with refunds.

System DesignAPI & IntegrationsData Modeling
Author's notes

Spent the first 15 minutes just figuring out the schema before writing a single line of code, which was probably the right call but felt slow in the moment.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying functional and non-functional requirements, then design a high-level architecture with core entities and APIs. Dive into data modeling for trains, routes, schedules, and bookings, and discuss concurrency and consistency for seat booking. Optionally cover cancellation/refund flow and scalability considerations.

Pro tip: Emphasize idempotency and transactional integrity in booking APIs to prevent double-booking, and discuss how you'd handle race conditions with database locks or optimistic concurrency control.

1. Clarify Requirements

Ask about scale (users, trains, bookings per day), read/write ratio, consistency needs, and whether cancellations/refunds are in scope. Define core use cases and constraints.

2. High-Level Design

Outline main components: API gateway, booking service, search service, payment service, and databases. Sketch API endpoints for search, availability, booking, and cancellation.

3. Data Modeling

Design schemas for stations, trains, routes, schedules, seats, bookings, and payments. Consider indexing for search and availability queries.

4. Booking & Concurrency

Explain how to handle seat locking, transactions, and idempotency to avoid double-booking. Discuss isolation levels and failure handling.

5. Cancellation & Refunds

Describe the cancellation flow, refund policies, and how to update seat availability and payment status atomically.

Key Points to Mention

  • Database choice (SQL vs NoSQL) and indexing for search/availability
  • Concurrency control (optimistic/pessimistic locking, transactions)
  • Idempotency keys for booking and cancellation APIs
  • Caching strategies for search results and seat availability
  • Handling refunds and payment gateway integration
  • Scalability and partitioning (e.g., by route or date)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

How would you design the database schema to support train routes, seats, and bookings?

Data ModelingTechnical Trade-offsSystem Design
Author's notes

This was the part I felt most shaky on.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the core entities and their relationships: trains, routes, stations, schedules, seats, and bookings. Then propose a normalized schema with appropriate keys and constraints, and discuss trade-offs like denormalization for read performance and handling concurrency for seat reservations.

Pro tip: Emphasize that seat availability should be derived from bookings rather than stored as a mutable count, to avoid race conditions and ensure consistency. Also, mention that for an early-stage startup, you'd start with a simple normalized schema and only denormalize when performance metrics demand it.

1. Clarify Requirements and Assumptions

Ask about scale, read/write patterns, and whether routes are fixed or dynamic. State assumptions like daily trains, seat classes, and booking lifecycle.

2. Identify Core Entities and Relationships

List entities: Train, Route, Station, Schedule, Seat, Booking, Passenger. Define relationships: a route has many stations, a schedule has many seats, a booking references a schedule and seats.

3. Design Tables and Keys

Propose tables with primary keys, foreign keys, and indexes. For example: trains(id, name), routes(id, train_id, origin_station_id, destination_station_id, departure_time, arrival_time), seats(id, train_id, seat_number, class), bookings(id, user_id, schedule_id, status, created_at), booking_seats(booking_id, seat_id).

4. Address Concurrency and Consistency

Discuss how to prevent double-booking: use transactions with SELECT FOR UPDATE or unique constraints on (schedule_id, seat_id) in booking_seats. Mention optimistic vs pessimistic locking.

5. Discuss Trade-offs and Scalability

Talk about normalization vs denormalization for read-heavy workloads, caching seat availability, and sharding by route or date if needed.

Key Points to Mention

  • Normalization to reduce redundancy, but consider denormalization for performance.
  • Use of foreign keys and indexes to ensure data integrity and query speed.
  • Handling seat reservations with transactions and unique constraints to avoid double-booking.
  • Modeling seat availability as a derived value from bookings, not a stored count.
  • Considering read vs write patterns: e.g., frequent reads for seat maps, writes for bookings.
  • Scalability: partitioning by date or route, and caching strategies.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

Walk through your API interface design for the booking system, explaining your choices.

API & IntegrationsTechnical Trade-offs
Author's notes

Talked through REST endpoints, explained why I kept search and booking separate.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the core booking flow and constraints (e.g., double-booking prevention, concurrency, early-stage speed vs. correctness). Then walk through your API design choices—resource modeling, endpoints, idempotency, error handling—and explicitly tie each choice to trade-offs relevant to a startup (e.g., simplicity, scalability, developer velocity).

Pro tip: Show you think about failure modes and idempotency upfront—mention how you'd handle duplicate booking requests and race conditions, since that's where most booking APIs break in production.

1. Clarify requirements and constraints

Ask about expected scale, concurrency, and whether the system needs to support real-time availability or can tolerate eventual consistency. This shows you design based on context, not dogma.

2. Define core resources and endpoints

Model the domain with clear resources (e.g., /bookings, /availability) and use RESTful or RPC-style endpoints. Explain why you chose that style (e.g., REST for simplicity, gRPC for performance).

3. Address concurrency and idempotency

Describe how you prevent double-booking (e.g., optimistic locking, database constraints, distributed locks) and ensure idempotent booking creation (e.g., idempotency keys).

4. Handle errors and edge cases

Outline consistent error responses (e.g., 409 Conflict for double-booking, 400 for invalid input) and how clients should retry or recover. Mention rate limiting and validation.

5. Discuss trade-offs and evolution

Explain choices like synchronous vs. asynchronous booking, versioning strategy, and how the API might evolve as the startup scales. Show awareness of simplicity vs. future-proofing.

Key Points to Mention

  • Idempotency keys for safe retries of booking creation
  • Optimistic concurrency control (e.g., versioning or ETags) to prevent double-booking
  • Clear resource modeling (e.g., /bookings, /availability) and appropriate HTTP methods/status codes
  • Error handling with specific status codes (409 Conflict, 422 Unprocessable Entity) and structured error bodies
  • Trade-offs between REST and gRPC/GraphQL for early-stage velocity vs. performance
  • Versioning strategy (e.g., URL versioning, header versioning) and backward compatibility

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.