Software Design Document Template
Lean feature design doc: context, goals and non-goals, design, API and data changes, alternatives, cross-cutting concerns, rollout
Cara menggunakan: 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.
Pratinjau
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.
| Field | Value |
|---|---|
| Title | [Feature name] |
| Author(s) | [@name] |
| Reviewers | [@name, @name] |
| Approver | [@tech-lead] |
| Status | [Draft / In review / Approved / Implemented / Abandoned] |
| Created | YYYY-MM-DD |
| Last updated | YYYY-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.
| Type | Statement | Measure |
|---|---|---|
| Goal | Example: A logged-in user sees the same cart on any device within 5 seconds | Sync lag p95 < 5 s |
| Goal | Example: Carts survive app reinstall | Lost-cart tickets reduced by 80% |
| Goal | Example: Works offline; changes sync when back online | No data loss in offline tests |
| Non-goal | Example: Carts for anonymous users across devices | n/a |
| Non-goal | Example: Real-time collaborative carts | n/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 / field | Change | Migration |
|---|---|---|
carts.version | Example: New integer, incremented on every change | Default 0, online migration |
cart_ops | Example: New table, 30-day retention, for idempotency by op_id | Create table |
| [Table] | [Change] | [Plan] |
3.4 Failure modes
| Failure | Behaviour | Recovery |
|---|---|---|
Example: cart-api unavailable | App keeps working from local cart | Op log replays on reconnect |
| Example: Duplicate op after retry | Ignored using op_id | None needed |
| Example: Version conflict | Client receives server cart, rebases ops | Automatic |
3.5 Dependencies and effort
| Dependency or work item | Owner | Estimate | Notes |
|---|---|---|---|
Example: Ops endpoint and versioning in cart-api | Team Cart | 2 weeks | Includes migration |
| Example: Sync client and op log in mobile app | Team Mobile | 3 weeks | iOS and Android in parallel |
Example: Push notification on cart.updated | Team Mobile Platform | 1 week | Reuses 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
| Option | Pros | Cons | Why not chosen |
|---|---|---|---|
| Example: Sync full cart snapshots | Simple | Overwrites concurrent changes | Data loss on two devices |
| Example: CRDT-based cart | Strong merge semantics | New library, team unfamiliar | Complexity beyond need |
| Example: Server-only cart, no local copy | No conflicts | Fails offline | Violates offline goal |
5. Cross-cutting concerns
| Concern | Assessment |
|---|---|
| Security | Example: Ops endpoint requires user token; cart ownership checked server-side. Threat model delta in [security/threat-model] |
| Privacy | Example: Cart contents are personal data; same retention as web carts (90 days) |
| Performance and cost | Example: +40 requests/s at peak; within current cart-api capacity |
| Observability | Example: Metrics for sync lag, conflict rate, rejected ops; dashboard panel added |
| Accessibility | Example: No UI change beyond a sync status indicator with text label |
| Reliability | Example: 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-bffandcart-api. - Example: End-to-end: two devices edit offline, reconnect, carts converge.
- Example: Load test at 3x peak on the ops endpoint.
7. Rollout
- Example: Ship server endpoint dark; enable for internal users (feature flag
cart_sync). - Example: 5% of mobile users for one week; watch conflict rate (< 1%) and sync errors (< 0.1%).
- Example: 50%, then 100% over two weeks.
- 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
| Question | Owner | Status |
|---|---|---|
| Example: Should we notify the user when a merge changes quantities? | @product | Open |
| [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.
Templat terkait
CI/CD Pipeline Design Template (SLSA, NIST SP 800-204D)
CI/CD design: stages and gates, environments and promotion, OIDC secrets, SBOM and provenance, rollout and rollback, CICD-SEC review, DORA metrics, traceability
Perangkat Lunak & RekayasaSLO Document Template
Critical user journeys, SLI specifications and queries, targets, error budget maths, burn-rate alerts per the alerting policy, error budget policy summary, review
Perangkat Lunak & RekayasaArchitecture Decision Record (ADR) Template
Lightweight Nygard-style ADR: status, context, decision, consequences, alternatives, related decisions, lifecycle and log