ArchitectMind
  1. Home
  2. Java Ecosystem
  3. Book 9 · Cloud, Containers, DevOps & Production Architecture
  4. Volume VIII
  5. Build vs Buy
Book 9 · Volume VIII — Cloud Architecture Design, Cost & Migration · Topic 1.4

Build vs Buy

Build what differentiates, buy what doesn't — and integrate both well

11 min readStage 4 · Production & architecture10 interview questions
Chapter
Chapter 1 — Cloud Architecture Design
Prerequisites
Topics 1.1–1.3; Book 7 domain-driven design
You will be able to
Classify capabilities by differentiation, run fit-gap and multi-year TCO analyses, evaluate vendors and contracts, design integration with anti-corruption layers, avoid customisation traps, and record build/buy decisions
Covers
Build vs buy
On this page
  1. 1. Concept / Definition
  2. 2. Why It Exists
  3. 3. Core Concepts — Build vs Buy
  4. 4. How It Works Internally — Decision Process
  5. 4A. Deep Dive — Total Cost of Ownership
  6. 4B. Deep Dive — Integration Architecture for Bought Systems
  7. 4C. Deep Dive — Vendor Evaluation
  8. 4D. Deep Dive — Customisation Traps
  9. 4E. Deep Dive — Contracts and Exit
  10. 5. APIs / Features / Syntax
  11. 6. Practical Examples
  12. 7. Common Problems & Mistakes
  13. 8. Performance & Production Considerations
  14. 9. Architecture & Design Considerations
  15. 10. Interview Questions & Answers

1Concept / Definition

Build vs buy decides whether a capability is developed in-house, purchased (SaaS, commercial product, managed service) or assembled (open source or a hybrid of bought core plus built extensions). The guiding principle: build what differentiates the business; buy what is commodity — then integrate bought systems cleanly so they don't distort your own domain.

Differentiation vs commodity
Figure 1 — Differentiation vs commodity
Build vs buy decision
Figure 2 — Build vs buy decision
VocabularyMeaning
Core domainCapability that differentiates the business
Generic subdomainNeeded but common to many businesses
Fit-gapComparison of requirements with product capabilities
Anti-corruption layer (ACL)Translation layer protecting your model from a vendor's
Table 1 — Terms

2Why It Exists

Poor decisionConsequence
Building an in-house CRM/ticketing toolYears of maintenance, inferior features
Buying a "platform" for the core pricing engineCan't innovate; vendor roadmap controls differentiation
Heavy customisation of SaaSUpgrade pain, lock-in, cost
No exit clausePrice increases with no leverage
Table 2 — Why

3Core Concepts — Build vs Buy

OptionStrengthRisk
BuildFit, control, differentiationCost, time, maintenance forever
Buy SaaSSpeed, vendor maintains, best practicesFit gaps, data residency, lock-in, price
Buy product (self-hosted)Control of hostingYou run it; upgrades
Open sourceNo licence, communityOperations, support, security patching
HybridBuy core, build differentiators on topIntegration complexity
Table 3 — Options
Domain classification (ShopNow)ExamplesDefault
CorePricing and promotions, search ranking, checkout experience, seller toolsBuild
SupportingOrder management, inventoryBuild (lean) or configure
GenericCustomer support ticketing, HR, email delivery, CRM, identity (partly)Buy
Table 4 — Classification

4How It Works Internally — Decision Process

StepDetail
ClassifyCore, supporting or generic; strategic importance
RequirementsMust-have vs nice-to-have; NFRs (residency, SLA, security)
Market scanSaaS, products, open source
Fit-gapScore candidates; list gaps and workarounds
TCO3–5 years for each option incl. integration and exit
RiskVendor viability, lock-in, security, residency
PoCCritical integrations, performance
Decide + ADRWith exit plan and review date
Table 5 — Process

4ADeep Dive — Total Cost of Ownership

5-year cost: customer support platform
Figure 3 — 5-year cost: customer support platform
Cost elementBuildBuy (SaaS)
InitialTeam of 8 for 12 monthsLicences + implementation partner
IntegrationInternalAPIs, events, SSO
RunInfra + 3 FTE maintenanceSubscription (per seat/usage)
EnhancementsYour backlogVendor roadmap + config
ExitN/AData export, migration
HiddenSecurity, compliance, on-callPrice escalators, add-ons
Table 6 — TCO elements

4BDeep Dive — Integration Architecture for Bought Systems

PatternPurpose
Anti-corruption layer serviceTranslate vendor model to domain model
Events from vendor (webhooks) → internal event busDecouple consumers
APIs behind your gatewaySecurity, rate limiting, observability
Master data ownership rulesAvoid dual sources of truth
Configuration over customisationStay on upgrade path
Table 7 — Integrate without infection

4CDeep Dive — Vendor Evaluation

AreaChecks
FunctionalFit-gap score, demo with your scenarios
Non-functionalSLA, performance, scalability, regional hosting
SecuritySOC 2/ISO 27001, pen tests, SSO/SCIM, encryption, data residency
IntegrationAPIs, webhooks, rate limits, sandbox
CommercialPricing model, escalators, minimums, exit fees
ViabilityFinancials, customer base, roadmap
ExitData export formats, assistance, timelines
Table 8 — Evaluation checklist

4DDeep Dive — Customisation Traps

TrapConsequenceAlternative
Deep code customisation of productBlocked upgradesExtensions via APIs
Replicating legacy processes exactlyLosing vendor best practiceAdapt processes
Vendor as system of record for core dataLock-inOwn core data; sync
Building UI replacementsDouble maintenanceUse vendor UI where possible
Table 9 — Stay close to standard

4EDeep Dive — Contracts and Exit

ClauseWhy
Data ownership and export (formats, frequency)Exit and analytics
Data residency commitmentsRegulation
SLA with credits and termination rightsReliability leverage
Price caps/escalator limitsBudget predictability
Security incident notificationCompliance
Termination assistanceSmooth exit
Table 10 — Negotiate for the exit on day one

5APIs / Features / Syntax

JAVA
// Anti-corruption layer: translate vendor ticket webhooks into ShopNow domain events
@RestController
class SupportWebhookController {
    private final DomainEvents events;
    @PostMapping("/webhooks/support")
    ResponseEntity<Void> onTicket(@RequestBody VendorTicketEvent e,
                                  @RequestHeader("X-Signature") String sig) {
        verifier.verify(sig, e);                                   // authenticity
        var event = switch (e.type()) {
            case "ticket.created" -> new CustomerIssueRaised(orderId(e), e.priority());
            case "ticket.solved"  -> new CustomerIssueResolved(orderId(e));
            default -> null;
        };
        if (event != null) events.publish(event);  // internal model only
        return ResponseEntity.accepted().build();
    }
}
YAML
# Build-vs-buy scorecard (architecture repo)
capability: customer-support-ticketing
classification: generic
options:
  build:        { fit: 5, tco_5y_cr: 14.5, time_to_value_months: 12, risk: medium }
  saas_vendor_a: { fit: 4, tco_5y_cr: 6.2, time_to_value_months: 3, risk: low }
  saas_vendor_b: { fit: 3, tco_5y_cr: 5.1, time_to_value_months: 3, risk: medium }
decision: saas_vendor_a
exit_plan: nightly export to S3 (JSON), contract termination assistance 90 days
YAML
# Gateway route: vendor API accessed only via ShopNow gateway (auth, limits, telemetry)
- id: support-vendor
  uri: https://api.support-vendor.example
  predicates: [ "Path=/internal/support/**" ]
  filters:
    - StripPrefix=2
    - name: RequestRateLimiter
      args:
        redis-rate-limiter.replenishRate: 50
        redis-rate-limiter.burstCapacity: 100

6Practical Examples

6.1 Support platform bought

ShopNow's in-house ticketing tool needed 5 engineers to maintain and lacked omnichannel features. A SaaS platform with an ACL and event integration went live in 3 months at less than half the 5-year cost.

6.2 Fraud engine: hybrid

PayGrid bought a fraud platform for rules management and case handling but built its own ML scoring service for merchant-specific signals — differentiation kept in-house.

6.3 NovaBank loan origination

NovaBank bought a loan origination product (regulatory workflows) but kept customer experience (mobile journeys) in-house, integrating via APIs and events.

6.4 Worked example — fit-gap

RequirementVendor AGap handling
Order context in ticketsVia APIACL enrichment
Arabic support✔—
Data in India✔ (region option)Contract clause
Table 11 — Gaps with workarounds

6.5 Worked example — classification workshop

CapabilityClass
Promotions engineCore
Email deliveryGeneric
Table 12 — Shared understanding

6.6 Worked example — open source choice

CapabilityChoice
Workflow engineTemporal (open source) self-hosted → later Temporal Cloud
Table 13 — Open source then managed

6.7 Worked example — interview whiteboard

PromptAnswer outline
"How do you decide build vs buy?""Classify capability (core/supporting/generic, DDD). Build core differentiators; buy generic. For candidates: fit-gap on must-haves and NFRs (residency, SLA, security), 3–5 year TCO incl. integration, customisation, run, people, exit; risk (viability, lock-in, security); PoC. Integrate bought systems via ACL, events, gateway; configure rather than customise; own core data. Negotiate data export, residency, SLA, price caps, termination assistance. Record ADR with exit plan and review."
Table 14 — Structured answer

6.8 Worked example — identity

NeedDecision
Customer identity (CIAM)Buy (security depth, compliance) with custom UI
Table 15 — Security-sensitive commodity

6.9 Worked example — anti-patterns

Anti-patternEffect
Not-invented-hereWasted engineering
Buying for core differentiationStrategic dependency
Heavy customisationUpgrade lock
No exit planPrice leverage lost
Table 16 — Common mistakes

6.10 Worked example — time-to-market value

OptionLaunchRevenue impact
Buy3 monthsEarlier benefits
Table 17 — Time has value

6.11 Worked example — data ownership

DataSystem of record
OrdersShopNow
TicketsVendor (with nightly export)
Table 18 — Clear ownership

6.12 Worked example — security questionnaire

ItemEvidence
SOC 2 Type II, pen test summary, SSO/SCIMVendor documents
Table 19 — Due diligence

6.13 Worked example — reversal

CaseDecision
Bought recommendation engine couldn't use proprietary signalsRebuilt in-house (core)
Table 20 — Re-classify when strategy changes

6.14 Worked example — maintenance of builds

Built systemOngoing cost
Promotions engine2 squads permanently
Table 21 — Builds are forever

6.15 Worked example — vendor SLA mapping

Vendor SLAOur SLO dependency
99.9%Support tooling tier-2 — acceptable
Table 22 — Match criticality

6.16 Worked example — interview follow-ups

Follow-upAnswer
"When is building justified for generic capabilities?"Rarely — unusual scale, cost or regulatory needs
"How to avoid vendor lock-in?"Own data, ACLs, export clauses, standards
Table 23 — Common probes

6.17 Worked example — checklist

Item✔
Classification✔
Fit-gap✔
TCO 3–5 yrs✔
Risk + security✔
Integration design (ACL)✔
Contract + exit✔
Table 24 — Build/buy baseline

6.18 Worked example — pricing model risk

ModelRisk
Per API callCost scales with success
Table 25 — Model future volumes

6.19 Worked example — vendor residency

RequirementCheck
NovaBank customer data in IndiaVendor Indian hosting + contract
Table 26 — Regulatory fit

6.20 Worked example — review cadence

TriggerAction
Contract renewalRe-run build/buy with current market
Table 27 — Periodic reassessment

6.21 Worked example — interview scenario

QuestionAnswer
"Engineers want to build their own feature flag system"Generic → buy/managed; unless unique needs proven
Table 28 — Challenge NIH

6.22 Worked example — hybrid integration diagram

LayerOwner
Vendor coreVendor
ACL + eventsShopNow
Differentiating UI/logicShopNow
Table 29 — Clear boundaries

7Common Problems & Mistakes

MistakeFix
NIH syndromeClassification
CustomisationConfiguration + ACL
Ignoring exitContract clauses
Partial TCOFull model
Table 30 — Mistakes and fixes

Most build-versus-buy regrets come from how the decision was made rather than which option was chosen. Teams compare a vendor's subscription price with the salaries of a build team for the first year, ignoring five years of maintenance on one side and integration, customisation and exit on the other. Requirements are written as a copy of the legacy system, so every vendor scores badly and the build option wins by default, or the bought product is customised until it is effectively a fork that cannot be upgraded. Pricing is modelled on today's volumes, so per-transaction or per-seat charges explode as the business grows. Security, residency and SSO checks happen after the contract is signed. And decisions are never revisited: a capability classified as generic five years ago may now be core, as ShopNow found when its bought recommendation engine could not use proprietary signals.

8Performance & Production Considerations

ConsiderationPractice
Vendor rate limitsGateway throttling
Vendor outagesDegraded modes
Data syncMonitoring
Table 31 — Operating bought systems

A bought system becomes one of your production dependencies, so operate it like one. Route every call through the gateway, so you control authentication, enforce your own rate limits below the vendor's, and get consistent metrics and traces; alert before you reach the vendor's API quota rather than after it starts returning 429s. Give the integration a degraded mode for vendor outages, for example queueing ticket creation in SQS and retrying, or showing a static contact page, so a support platform incident does not break order flows. Monitor data synchronisation explicitly, with counts and lag between the vendor and your system of record, and reconcile nightly so drift is caught in hours rather than discovered in an audit. Map the vendor's SLA to the SLO of every capability that depends on it, and track vendor incidents and response times as evidence for contract renewal.

9Architecture & Design Considerations

GuidelineDetail
Build core, buy genericDDD
Protect your modelACL
Own your dataExports
Table 32 — Design guidance

10Interview Questions & Answers

Q1L1 · BasicConcept

What is the build vs buy principle?

Build what differentiates the business and buy what is commodity, then integrate both cleanly. Engineers who understand your domain are the scarcest resource, so spend them on capabilities that create competitive advantage, such as ShopNow's pricing, promotions, search ranking and checkout. Generic capabilities like ticketing, CRM, HR and email delivery are solved problems, and vendors spread their development cost across thousands of customers. The opposite mistakes are both expensive: building a commodity wastes years on maintenance, while buying a differentiator hands your edge to a vendor's roadmap. Bought systems should sit behind anti-corruption layers and contracts that protect your data, so buying does not distort your own model.

Q2L1 · BasicConcept

What is a core domain?

In domain-driven design, the core domain is the part of the business that creates competitive advantage and justifies your best engineers and most investment. It is what customers choose you for, and what competitors cannot simply buy. Supporting subdomains are specific to your business but not differentiating, such as order management, while generic subdomains are common to many businesses, such as ticketing or payroll. The classification is strategic, not technical, so it needs product and business leaders in the room. For ShopNow, pricing and promotions and search ranking are core; for PayGrid, merchant-specific fraud scoring is core, which is why it is built in-house while case management is bought.

Q3L2 · IntermediateConcept

What is fit-gap analysis?

Fit-gap analysis compares your requirements with what each candidate product actually does, to expose the gaps and how each would be handled before you commit. Start with prioritised requirements, separating must-haves from nice-to-haves and including non-functional needs such as data residency, SLA, security and integration APIs. Score each candidate on each requirement, ideally from a demo using your own scenarios rather than the vendor's script. For every gap, record the workaround, such as configuration, an extension through APIs, an anti-corruption layer enrichment or a contract clause, and its cost. ShopNow's support platform fit-gap covered order context through the API, Arabic support, and India-hosted data by contract.

Q4L2 · IntermediateEstimation

What belongs in build vs buy TCO?

Total cost of ownership should cover the full life of the decision, typically three to five years, for every option. For building, include the initial team, infrastructure, permanent maintenance and enhancement, security, compliance, on-call and the opportunity cost of those engineers. For buying, include licences or subscriptions with expected volume growth and price escalators, implementation partners, integration such as APIs, events and SSO, configuration and any customisation, add-ons, internal run and administration effort, and the eventual exit cost of data migration. Add risk-weighted costs of vendor or project failure. ShopNow's support platform came to ₹14.5 crore over five years to build against ₹6.2 crore for the chosen SaaS.

Q5L3 · Senior EngineerDesign

What is an anti-corruption layer?

An anti-corruption layer is a translation boundary between your domain and an external system, so the vendor's model, terminology and quirks never leak into your services. It is usually a small service or adapter that calls the vendor's API and receives its webhooks, then converts vendor objects into your own domain events and commands, for example turning ticket.created into CustomerIssueRaised. It also verifies signatures, handles retries and absorbs API changes. Because your services depend only on the layer's contract, you can change vendor versions, or even vendors, by rewriting one component instead of every consumer. It comes from domain-driven design and is essential for bought systems.

Q6L3 · Senior EngineerTricky

Why avoid heavy customisation?

Heavy customisation turns a product you bought into software you maintain without the freedom of owning it. Code-level changes or deep scripts must be re-tested and often rewritten at every vendor upgrade, so teams fall behind versions, miss security fixes and eventually get stuck on an unsupported release. Custom data structures make migration harder, deepening lock-in, and the cost of the customisation is rarely in the original TCO. It also usually means you have copied legacy processes instead of adopting the vendor's proven ones. Prefer configuration, adapt your processes where the capability is generic, and build any genuinely needed behaviour outside the product through APIs and events.

Q7L4 · Technical ArchitectDesign

What contract clauses matter?

Negotiate for the exit and for risk on day one, while you still have leverage. Data ownership and export clauses define formats, frequency and full access to your data, ideally including automated exports such as nightly JSON to S3. Data residency commitments specify where data is stored and processed, which is mandatory for regulated firms like NovaBank. The SLA should come with service credits and termination rights for repeated breaches. Price caps limit escalators at renewal. Security incident notification timelines must support your regulatory reporting duties, such as DPDP breach notification. Termination assistance, for example 90 days of support and continued access, makes leaving feasible rather than theoretical.

Q8L4 · Technical ArchitectTrade-off

When is a hybrid approach best?

A hybrid is best when a capability has a commodity core but your differentiation lives in specific parts of it. You buy the product for the generic workflows, compliance features or case management that vendors do well, and build the differentiating pieces yourself, connected through APIs, events and an anti-corruption layer. PayGrid bought a fraud platform for rules management and case handling but built its own ML scoring on merchant-specific signals; NovaBank bought loan origination for regulatory workflows but kept mobile customer journeys in-house. The cost is integration complexity, so define clear ownership boundaries and keep core data in your own systems rather than the vendor's.

Q9L5 · Solution ArchitectBehavioural

How do you counter not-invented-here?

Counter not-invented-here with shared criteria and evidence, not authority. First agree the capability's classification with product and business leaders, so the conversation is about strategy rather than engineering preference. Then put the numbers side by side: a five-year TCO including permanent maintenance and on-call for the build option, and the opportunity cost of the features those engineers would otherwise deliver. Acknowledge real gaps and test them in a proof of concept, so concerns are answered rather than dismissed. When engineers proposed building a feature flag system at ShopNow, classifying it as generic and comparing costs settled it, while leaving room to build if unique needs were proven.

Q10L5 · Solution ArchitectScenario

When revisit build/buy?

Revisit a build-or-buy decision at planned points and whenever its assumptions change. Planned points include contract renewals, when you rerun the analysis against the current market and have negotiating leverage, and the review date written into the ADR. Unplanned triggers include a change in strategy that turns a generic capability into a core one, as when ShopNow rebuilt its recommendation engine to use proprietary signals; large changes in scale or pricing that alter the TCO; vendor viability problems, acquisitions or roadmap shifts; repeated SLA breaches; and new regulation such as residency requirements. Keep exit plans current, so a revisit can actually lead to change.

Test your knowledge on this topic →Flashcards from this topic's 10 questions, filtered by level and type.

Free question pack

Get 100 free Core Java interview questions

Subscribe for the Book 1 question pack (PDF, every answer explained) and new tutorials once a week. No spam, unsubscribe anytime. What is in the pack?

Almost done! Check your inbox and click the confirmation link. Your download link arrives as soon as you confirm.