Application Data Models and API Design

A practical guide for enterprise data architecture.

BeginnerIntermediateExpert · 4 min read · Last updated:

In brief

Identify the business concepts, commands, queries and invariants the application must support. A persistence model and an API representation serve different purposes: an API can hide storage details, while a database schema can optimize transactions. Avoid making one shape serve every boundary by accident.

Model the domain before the endpoint

Identify the business concepts, commands, queries and invariants the application must support. A persistence model and an API representation serve different purposes: an API can hide storage details, while a database schema can optimize transactions. Avoid making one shape serve every boundary by accident.

Design stable resource meaning

Name resources and fields using agreed domain language. Define identifiers, optionality, units, enumerations, null behavior and relationships. Distinguish a missing value from an unknown, not applicable or intentionally withheld value when consumers need that difference.

Separate commands and queries where useful

A command requests a state change and must define validation and outcome. A query requests a representation and may support filters or pagination. Eventual consistency or asynchronous completion should be communicated in the interface instead of implied by response timing.

Evolve safely

Version or otherwise manage incompatible API changes, document deprecation and test consumer assumptions. Use idempotency for retried operations where duplicate effects would be harmful. Apply security and privacy controls to each endpoint based on purpose and authorization, not on obscurity of the URL.

SourcesSystems and events
PlatformContracts and controls
ConsumersProducts and workloads
Show ownership, contracts and controls at the boundaries.

Apply the guidance

Confirm requirements with system owners and representative consumers. Record assumptions, dependencies and unresolved decisions, then validate the design against realistic workload and failure scenarios.

Implementation depth Boundaries, risks and validation

Design around resource lifecycles

An application API exposes concepts and actions to clients. Model resources around stable identity and business lifecycle rather than exposing storage tables directly. Define which fields clients may create, update or observe, and which transitions are valid. Separate commands that cause a business event from queries that return a representation.

Version contracts and errors deliberately

Document required and optional fields, identifiers, enumeration behavior, validation errors, pagination and compatibility. Clients should know what happens when a new status appears or a formerly optional field becomes required. Use stable error codes and actionable messages without leaking internal details.

Handle concurrency and retries

Clients retry after timeouts, so create operations may need idempotency keys. Updates may need version checks or conditional requests to avoid overwriting concurrent changes. Define whether a request is atomic and how partial failures are reported. Test duplicate submissions, stale updates and repeated deletes.

Access and evolution

Apply authorization to resources and operations, not only to endpoints. Avoid returning fields a client does not need. Track usage and consumer dependencies before removing fields. Use additive transitions where possible and communicate deprecation with a migration window approved by service owners.

  • Are resource identities stable and scoped?
  • Are lifecycle transitions explicit?
  • Are retries and concurrent updates safe?
  • Are errors and schema changes predictable?
  • Are permissions tested at resource and field levels?

Worked example: resource and command design

A public API might expose an order resource for reading current state and a command to submit a cancellation request. The command expresses intent and can be accepted, rejected, or require additional processing; it should not imply that cancellation is complete. Model status transitions and response identifiers so clients can track the outcome.

Keep API representations stable and separate from internal storage tables. Define identifier scope, optional fields, null meaning, pagination, filtering, error shape, authorization, and versioning. If a response combines several domain sources, state which system owns each field and how freshness is communicated. Avoid exposing implementation details that become accidental contracts.

Test API contract evolution

Use consumer-driven examples, schema compatibility checks, and integration tests for normal and failure paths. Verify behavior with unknown fields, retries, duplicate commands, and authorization boundaries. Publish deprecation notices and migration examples before removing fields. Review API performance and data minimization together so the contract serves its use case without overexposing domain data.

Review API contracts operationally

Check rate limits, pagination stability, idempotency, authentication, error semantics, observability, and support ownership. Define how clients discover a change and how long deprecated behavior remains available. Include examples for success, validation failure, conflict, and asynchronous completion.

Monitor latency and error rates by operation without logging sensitive payloads unnecessarily. Test contract behavior across client versions. A domain API should preserve business meaning and not expose mutable storage details as public identifiers.

Assess API change impact

Before changing a resource or response field, identify active clients, integrations, and persisted consumers. Compare schema and semantic behavior, then choose an additive change, version, or migration. Publish examples and test older clients against the proposed response.

Track adoption and errors through the transition. Remove deprecated behavior only after the announced criteria are met. Record the owner and support route for each API contract.