Markdown Editor

Software Design Document Template

Lean feature design doc: context, goals and non-goals, design, API and data changes, alternatives, cross-cutting concerns, rollout

使い方: Use before building a feature or contained change, while the design is still cheap to change; for large systems use architecture/technical-design-doc. Write context and goals/non-goals first, then the design and rejected alternatives. The main pitfall is a document with no alternatives or trade-offs, which reviewers cannot challenge.

プレビュー

Design Doc: [Feature name]

Lean design document for a feature or a contained change, in the style many engineering teams use for everyday work: context, goals and non-goals, the design, alternatives, cross-cutting concerns, testing and rollout. Aim for 3 to 10 pages. For a large new system or a multi-team platform, use architecture/technical-design-doc instead. Replace every [bracketed] value and every row marked Example.

FieldValue
Title[Feature name]
Author(s)[@name]
Reviewers[@name, @name]
Approver[@tech-lead]
Status[Draft / In review / Approved / Implemented / Abandoned]
CreatedYYYY-MM-DD
Last updatedYYYY-MM-DD
Related[RFC-NNNN, epic link, PRD link]

1. Context and scope

Example: Customers can save carts on the web but not on mobile. The mobile app stores carts in local storage only, so carts are lost when a user switches device or reinstalls the app. Support receives about 300 contacts per month about lost carts, and mobile cart abandonment is 12 points higher than on the web. The cart service (cart-api) already persists web carts in PostgreSQL; the mobile backend (mobile-bff) does not call it.

This design covers syncing carts between the mobile app and cart-api. It does not change checkout or pricing.

2. Goals and non-goals

The goals and non-goals below bound the design and give reviewers a test for every proposal.

TypeStatementMeasure
GoalExample: A logged-in user sees the same cart on any device within 5 secondsSync lag p95 < 5 s
GoalExample: Carts survive app reinstallLost-cart tickets reduced by 80%
GoalExample: Works offline; changes sync when back onlineNo data loss in offline tests
Non-goalExample: Carts for anonymous users across devicesn/a
Non-goalExample: Real-time collaborative cartsn/a

3. Design

3.1 Overview

Example: The mobile app keeps a local cart and an operation log. When online, mobile-bff forwards operations to cart-api, which applies them to the server cart with a version number. Conflicts are resolved per line item, last write wins, with quantity merges for concurrent additions.

3.2 API changes

New endpoint on cart-api, called by mobile-bff:

POST /v1/carts/{cart_id}/ops
If-Match: "17"
Content-Type: application/json

{"ops": [{"op": "add", "sku": "SKU-123", "qty": 1, "client_ts": "2026-01-10T09:00:00Z"}]}

Responses: 200 with the new cart and version; 409 with the server cart when the version does not match and the client must rebase its pending operations.

3.3 Data model

Table / fieldChangeMigration
carts.versionExample: New integer, incremented on every changeDefault 0, online migration
cart_opsExample: New table, 30-day retention, for idempotency by op_idCreate table
[Table][Change][Plan]

3.4 Failure modes

FailureBehaviourRecovery
Example: cart-api unavailableApp keeps working from local cartOp log replays on reconnect
Example: Duplicate op after retryIgnored using op_idNone needed
Example: Version conflictClient receives server cart, rebases opsAutomatic

3.5 Dependencies and effort

Dependency or work itemOwnerEstimateNotes
Example: Ops endpoint and versioning in cart-apiTeam Cart2 weeksIncludes migration
Example: Sync client and op log in mobile appTeam Mobile3 weeksiOS and Android in parallel
Example: Push notification on cart.updatedTeam Mobile Platform1 weekReuses existing push service
[Item][Team][Estimate][Notes]

The largest risk is the merge logic on the client; the team will build a prototype first and review it before the server work is finished.

4. Alternatives considered

OptionProsConsWhy not chosen
Example: Sync full cart snapshotsSimpleOverwrites concurrent changesData loss on two devices
Example: CRDT-based cartStrong merge semanticsNew library, team unfamiliarComplexity beyond need
Example: Server-only cart, no local copyNo conflictsFails offlineViolates offline goal

5. Cross-cutting concerns

ConcernAssessment
SecurityExample: Ops endpoint requires user token; cart ownership checked server-side. Threat model delta in [security/threat-model]
PrivacyExample: Cart contents are personal data; same retention as web carts (90 days)
Performance and costExample: +40 requests/s at peak; within current cart-api capacity
ObservabilityExample: Metrics for sync lag, conflict rate, rejected ops; dashboard panel added
AccessibilityExample: No UI change beyond a sync status indicator with text label
ReliabilityExample: New endpoint included in the cart-api SLO (see dev/slo-doc)

6. Testing

The test approach covers the merge logic, the API contract and real devices.

  • Example: Unit tests for the merge function with property-based tests on random op sequences.
  • Example: Contract tests between mobile-bff and cart-api.
  • Example: End-to-end: two devices edit offline, reconnect, carts converge.
  • Example: Load test at 3x peak on the ops endpoint.

7. Rollout

  1. Example: Ship server endpoint dark; enable for internal users (feature flag cart_sync).
  2. Example: 5% of mobile users for one week; watch conflict rate (< 1%) and sync errors (< 0.1%).
  3. Example: 50%, then 100% over two weeks.
  4. Example: Remove flag after 30 days at 100%.

Rollback: turn off cart_sync; the app falls back to local-only carts with no data loss on the device.

8. Open questions

QuestionOwnerStatus
Example: Should we notify the user when a merge changes quantities?@productOpen
[Question][@name][Open / Resolved]

After implementation, add a short note here on where the build differed from this design and why, then set the status to Implemented.

Based on common industry practice for lightweight software design documents. Template licence: MIT.

関連テンプレート