Scrivio Interview library

Designing Java backend systems

44 questions in 10 subtopics.

Payment system

CodingFoundations6 min read
In a Spring Boot payment service, a method charges a card through an external provider and then saves a Payment entity. Sometimes the provider charge succeeds but the save fails, and the customer is charged with no record. How would you restructure the code?
DesignIntermediate7 min read
Design a double-entry ledger for a wallet product in a Spring Boot service, where users can top up, pay merchants and receive refunds. How do you guarantee balances are always correct under concurrency?
DesignIntermediate7 min read
Design a payment service in Java and Spring Boot that accepts payment requests from a checkout service, charges cards through two external providers, and must never double-charge. Cover the data model, idempotency, provider failures and reconciliation.
ScenarioAdvanced6 min read
Finance reports that your payment records and the provider's settlement reports disagree for about 0.1 percent of transactions each month. As the architect of the payments platform, how would you investigate and fix the process?
DesignAdvanced6 min read
Your company processes payments in 12 countries through 6 providers, and each country team has built its own integration. Design a payments platform that country teams can build on, and explain how you would migrate to it.
LeadershipPrincipal6 min read
The company must decide whether to build its own payment orchestration and ledger or buy a payment platform from a vendor. As the senior technical leader, how do you frame the decision, and what risks do you weigh over five years?

Order management

ConceptFoundations6 min read
In an order service built with Spring Boot and JPA, an Order has a status field and many code paths change it directly with setStatus. Bugs appear where orders move from SHIPPED back to PAID. How would you model order state to prevent invalid transitions?
DesignIntermediate6 min read
Design an order management service for an e-commerce site that takes orders, coordinates payment, inventory and shipping services, and lets customers cancel before shipping. Use Java and Spring Boot and explain consistency and failure handling.
DesignAdvanced6 min read
Your order management system is a single Spring application used by web, mobile, marketplace sellers and store staff, with 15 teams changing it. Design how you would split responsibilities into services, and how you would decide boundaries.
LeadershipPrincipal6 min read
The business wants to add marketplace sellers, buy-online-pickup-in-store and subscriptions to an order platform designed for simple web orders. As the senior technical leader, how do you decide whether to evolve the existing platform or build a new one?

Notification service

DebuggingFoundations6 min read
A Spring Boot notification service sends emails from a @TransactionalEventListener after an order is saved. Some customers get no email, and logs show the email provider was down for 10 minutes. How would you make delivery reliable?
DebuggingIntermediate6 min read
Users report receiving the same push notification three times. The notification worker consumes from Kafka and calls a push provider. How would you find and fix the cause?
DesignIntermediate6 min read
Design a notification service in Java and Spring Boot that sends email, SMS and push notifications for many internal services, respects user preferences and quiet hours, and handles provider outages.
DesignAdvanced6 min read
Notifications in your company are sent by 25 services directly through different providers, and users complain about duplicate and excessive messages. Design a central notification platform and its adoption plan.
LeadershipPrincipal6 min read
As the senior technical leader, how would you decide whether to buy a customer engagement platform or keep building your own notification platform, given marketing and product both want more features?

Rate limiter

ConceptFoundations7 min read
Explain the token bucket, fixed window and sliding window algorithms for rate limiting, and one weakness of each.
DesignIntermediate8 min read
Design a distributed rate limiter service used by an API gateway and 40 Java services, with limits per API key and per endpoint, handling 200,000 checks per second at low latency.
DesignAdvanced6 min read
Your company offers a public API with free, standard and enterprise plans. Design the rate limiting and quota architecture across gateway, services and billing, including multi-region operation.
LeadershipPrincipal6 min read
A large enterprise customer demands guaranteed throughput far above your standard limits, and sales has agreed in principle. As the senior technical leader, how do you handle the technical and business decision?

URL shortener

CodingFoundations6 min read
In a URL shortener written in Java, how would you turn a numeric id from a database sequence into a short code, and what are the drawbacks of sequential ids?
DesignIntermediate7 min read
Design a URL shortener in Java and Spring Boot that handles 1,000 new links per second and 100,000 redirects per second, with custom aliases and expiry.
DesignAdvanced6 min read
Your URL shortener is now used by marketing teams worldwide, and the business wants five-nines availability for redirects in all regions. How would you design multi-region operation?
LeadershipPrincipal6 min read
Your company's link service has become a target for phishing links, and the security team asks whether to keep running it publicly. As the senior technical leader, how do you decide?

Job scheduler

CodingFoundations6 min read
You are writing the worker loop of a simple job scheduler backed by a PostgreSQL jobs table in Spring Boot, and you run 4 worker pods. How do you make sure each due job is picked up by only one worker?
DesignIntermediate7 min read
Design a distributed job scheduler service in Java that lets internal teams schedule one-off and recurring HTTP or message-based jobs, with at-least-once execution, retries and a history of runs.
DesignAdvanced6 min read
Scale the job scheduler to 10 million scheduled jobs per day with jobs owned by hundreds of teams. What changes in your design, and how do you keep one team's jobs from affecting others?
LeadershipPrincipal6 min read
Your company runs Quartz, Kubernetes CronJobs, an enterprise scheduler and a home-built job service. As the senior technical leader, how would you set a long-term direction for scheduling?

Inventory and reservation

DebuggingFoundations6 min read
A Spring Boot inventory service decrements stock with this flow: read the product row, check quantity > 0, then save quantity - 1. During a flash sale, stock went negative. Explain the bug and two fixes.
DesignIntermediate7 min read
Design an inventory reservation service for an online store where items are reserved when added to checkout and released if payment does not complete within 15 minutes.
DesignAdvanced6 min read
Inventory for your retailer lives in warehouses, stores and third-party sellers, each with different update latency. Design an availability and reservation architecture across these sources.
LeadershipPrincipal5 min read
Overselling during peak events costs your company millions in cancellations and customer trust, while underselling leaves stock unsold. As the senior technical leader, how do you set the strategy?

Search

ConceptFoundations6 min read
A product search in a Spring Boot app uses a JPA query with LIKE '%term%' and is slow on 5 million rows. Why, and what are the options?
DesignIntermediate6 min read
Design product search for a catalogue of 20 million items with facets, typo tolerance and near-real-time updates, using Spring Boot services and Elasticsearch or OpenSearch.
ScenarioAdvanced6 min read
A full reindex of your product search index takes 14 hours and must happen whenever the mapping changes, blocking releases. How would you redesign indexing?
DesignAdvanced5 min read
Several teams run their own Elasticsearch clusters for search features, with high cost and frequent incidents. Design a shared search platform.
LeadershipPrincipal6 min read
Product leaders want semantic search with embeddings and generative answers on top of the existing keyword search. As the senior technical leader, how do you decide the investment and sequence?

Multi-tenant SaaS backend

CodingFoundations7 min read
In a multi-tenant Spring Boot application using a shared database with a tenant_id column, how would you make sure every query is filtered by tenant?
DesignIntermediate6 min read
Design the backend for a B2B SaaS product built with Spring Boot that serves 2,000 small customers and 20 large enterprise customers with stricter isolation needs. Cover data isolation, tenancy routing and noisy neighbours.
DesignAdvanced6 min read
Your SaaS platform has grown to 20,000 tenants in one region, and incidents affect all tenants at once. Design a cell-based architecture to limit blast radius.
LeadershipPrincipal6 min read
Enterprise customers ask for data residency in their region and single-tenant deployments. As the senior technical leader, how do you weigh this against the cost of a shared platform?

Real-time feed

CodingFoundations7 min read
How would you push new notifications to a browser from a Spring Boot application using server-sent events, and what happens when you run several instances?
DesignIntermediate7 min read
Design a real-time activity feed for a social application in Java: users follow others and see new posts within seconds. Discuss fan-out on write vs fan-out on read and how you deliver updates to clients.
DesignAdvanced7 min read
Your real-time feed must support 5 million concurrent WebSocket connections. How would you design the connection layer and message routing?
LeadershipPrincipal7 min read
Product wants to add ranked, personalised feeds instead of chronological ones. As the senior technical leader, what organisational and technical changes would you plan?