Markdown Editor

Low-Level Design (LLD) Template (Detailed Component Design)

Modules and classes, API and event contracts, schema and mappings, sequences and states, rules, errors and retries, config, security, telemetry, tests

ArchitectureCompletIEEE 1016-2009 concepts; OpenAPI 3.2; AsyncAPI 3.1.0; RFC 9457lowleveldesign

Mode d'emploi: Use it when one component from an approved HLD needs a build specification that developers can implement and reviewers can check. Fill the fixed inputs from the HLD and the contracts first, then data, behaviour, error handling and the performance budget. The main pitfall is documenting only the happy path, with no timeouts, retry rules or idempotency.

Aperçu

Low-Level Design: [Component name]

Low-level design (LLD), also called detailed design, for one component of a solution: its internal modules and classes, the API and event contracts it provides and consumes, its data model and mappings, key sequences and states, business rules, error handling and retries, configuration, security implementation, telemetry, performance budget, test approach and build and deployment notes. It is the build specification that a developer can implement and a reviewer can check. Design views follow the concepts of IEEE 1016-2009 (design concerns, viewpoints and views); contracts are expressed in OpenAPI 3.2 and AsyncAPI 3.1.0, and error responses in the RFC 9457 problem details format. Replace every [bracketed] value and every row marked Example.

Document control

FieldValue
Document ID[LLD-002]
Component[CMP-002 Order service]
Parent HLD[HLD-001, version x.y]
Repository[Repository URL and path]
Version[0.1]
Status[Draft / In review / Approved / Superseded]
Owner[@component-tech-lead]
Approvers/reviewers[@solution-architect], [@security-champion], [@sre], [@qa-lead]
Owning team[Team name]
Last updatedYYYY-MM-DD
Classification[Internal / Confidential]

Approvals

RoleNameDecisionDate
Component technical lead (author)[@name][Submitted]YYYY-MM-DD
Solution architect[@name][Approve / Approve with conditions / Reject]YYYY-MM-DD
Security champion[@name][Decision]YYYY-MM-DD
SRE or operations[@name][Decision]YYYY-MM-DD
Quality lead[@name][Decision]YYYY-MM-DD

Revision history

VersionDateAuthorChange summary
0.1YYYY-MM-DD[@name]First draft
0.2YYYY-MM-DD[@name]Example: Added refund flow and error catalogue after review
1.0YYYY-MM-DD[@name]Example: Approved for implementation of release 1

Contents

1. Component identification and scope

ItemValue
ResponsibilityExample: Own the order lifecycle from submission to completion: validate, price snapshot, persist, transition states and publish order events
Must notExample: Call the payment provider directly, hold card data, write to the warehouse system
ProvidesExample: IF-001 Orders REST API, IF-003 order events
ConsumesExample: IF-005 Payment orchestrator create-intent API, IF-006 payment events, IF-004 daily price file (through the price cache), identity provider token keys
RuntimeExample: Containerised service on the platform Kubernetes cluster, [language and version], [framework and version]
Design concerns addressedExample: Correctness of state transitions, idempotent submission, latency budget, auditability

2. Design inputs and constraints

InputIDValue taken from sourceSource
Latency budget (Example)NFR-PE-001300 ms p95 inside the Order service for POST /orders; payment intent (IF-005) budgeted separately at 350 ms p95 with a 450 ms timeoutHLD section 9, ADR-004
Availability tier (Example)NFR-RE-001T1, 99.98 % allocation, three replicas over three zonesHLD sections 9 and 11
Throughput (Example)NFR-PE-00250 orders per second minimum, 60 target, sustained for 60 minNFR Catalogue
Recovery objectives (Example)NFR-RE-002RPO 5 min, RTO 1 h (database owned by platform)HLD section 11
Broker independence (Example)ADR-003Order capture continues while the broker is down; events wait in the outboxHLD section 11 failure table
Event publication (Example)ADR-003Transactional outbox, at-least-once deliveryDecision log
Audit (Example)NFR-SE-006Every agent change to an order is logged with actor and reasonNFR Catalogue
Coding standard (Example)Not applicableOrganisation coding standard version [x]Coding Standards (dev/coding-standards)
[Input][ID][Value][Source]

3. Internal structure

ModuleResponsibilityMay depend onMust not depend on
api (Example)Map HTTP to commands and queries, validate against OpenAPI schema, map errors to problem detailsapplicationadapters, database driver
application (Example)One class per use case, transaction boundary, authorisation checks on resource ownershipdomain, portsapi, framework web types
domain (Example)Order aggregate, value objects, state machine, pricing snapshot rulesNothing outside the standard libraryAny framework or I/O
ports (Example)Interfaces for repositories, payment client, clock, ID generatordomainadapters
adapters (Example)Implement ports: SQL repository, HTTP payment client, outbox relay, cache clientports, librariesapi
messaging (Example)Consume payment and shipment events, call use casesapplicationadapters directly
[Module][Responsibility][Allowed][Forbidden]

Enforce the dependency rules with an automated architecture test in the build (see Fitness Functions (architecture/fitness-functions)).

4. Classes and modules

TypeKindPurposeInvariants or notes
Order (Example)Aggregate rootHolds order state and enforces transitionsTotal equals sum of lines; status changes only through methods
Money (Example)Value objectAmount and ISO 4217 currencyNever a floating-point type; one currency per order
SubmitOrderHandler (Example)Use caseValidates command, checks idempotency key, creates order, requests payment intentSingle transaction for order row and idempotency record
OutboxRelay (Example)AdapterReads unpublished outbox rows and publishes themPublishes in commit order per order ID
[Type][Kind][Purpose][Notes]

5. Interfaces and contracts

5.1 Provided API (IF-001)

Contract file: [path]/orders-v1.openapi.yaml (OpenAPI 3.2). Rules: see API Design Guidelines (architecture/api-design-guidelines).

OperationMethod and pathRequestSuccessErrorsIdempotentAuth scope
Submit order (Example)POST /v1/ordersLines, delivery address, channel ID, Idempotency-Key header201 with order ID and payment redirect400, 401, 403, 409, 422, 429, 503Yes, by key for 24 horders:write
Get order (Example)GET /v1/orders/{id}Path ID200 with order401, 403, 404Yesorders:read
List my orders (Example)GET /v1/orders?cursor=Cursor, page size up to 50200 with page and next cursor400, 401Yesorders:read
Cancel order (Example)POST /v1/orders/{id}/cancelReason code200 with updated order404, 409 when picking has started or the order is shipped (BR-003)Yesorders:write
[Operation][Method path][Request][Response][Codes][Yes / No][Scope]

5.2 Published events (IF-003)

Contract file: [path]/order-events.asyncapi.yaml (AsyncAPI 3.1.0). Envelope: [CloudEvents 1.0.2 attributes, or the organisation envelope].

EventTriggerKeyPayload summaryOrderingConsumers
OrderConfirmed (Example)Payment authorisedOrder IDOrder ID, lines, totals, delivery address referencePer order IDFulfilment, notification, analytics
OrderCancelled (Example)Cancel acceptedOrder IDOrder ID, reason codePer order IDFulfilment, notification, analytics
[Event][Trigger][Key][Payload][Ordering][Consumers]

5.3 Consumed interfaces

DependencyOperationTimeoutRetriesFallbackContract
Payment orchestrator, IF-005 (Example)Create payment intent450 ms (at measured p99; p95 budget 350 ms)None on the request pathReturn 503 with Retry-After; order stays PENDING_PAYMENT and the client retries with the same keypayments-internal-v1 OpenAPI file
Price cache (Example)Get price by SKU20 ms1Read from databaseCache key spec
PaymentAuthorised and PaymentFailed events, IF-006 (Example)ConsumeNot applicableRedelivery by broker, 5 attempts then dead letterAlert and manual replay; reconciliation job queries the payment orchestrator for orders pending over 10 minpayment-events AsyncAPI file
[Dependency][Operation][ms][Policy][Fallback][File]

Versioning: additive changes are allowed within a major version; removing or renaming a field needs a new major version and the deprecation period in API Deprecation Policy (architecture/api-deprecation-policy).

6. Data design and mappings

TableKey columnsPurposeIndexesRetention
orders (Example)id (UUID), customer_id, status, total_minor, currency, version, created_atOrder header(customer_id, created_at desc), (status) partial for open states7 years, then anonymise personal fields
order_lines (Example)order_id, line_no, sku, quantity, unit_price_minorLinesPrimary key (order_id, line_no)With order
order_status_history (Example)order_id, from_status, to_status, actor, reason, atAudit trail(order_id, at)With order
outbox (Example)id, aggregate_id, type, payload, created_at, published_atPending events(published_at) where nullDelete 7 days after publish
idempotency_keys (Example)key, caller_id, request_hash, order_id, expires_atDuplicate submit detectionUnique (caller_id, key)24 hours
[Table][Columns][Purpose][Indexes][Retention]

6.1 Access patterns

IDQueryFrequencyServed by
AP-01 (Example)Get order with lines by IDHighPrimary key lookups
AP-02 (Example)Customer's latest orders, newest firstHigh(customer_id, created_at desc)
AP-03 (Example)Unpublished outbox rows in orderEvery 200 msPartial index on published_at
[AP-NN][Query][Frequency][Index]

6.2 Field mapping

API fieldDomainColumnRule
total.amount (string decimal) (Example)Money.amounttotal_minor (bigint)Convert with currency minor units; reject more decimals than the currency allows
deliveryAddress (Example)Address value objectorders.delivery_address (JSON, encrypted column)Personal data, masked in logs
[Field][Domain][Column][Rule]

Schema changes: forward-only migration scripts in [path], applied by the pipeline before the new version starts; every change must be compatible with the running previous version (expand, migrate, contract).

7. Behaviour: sequences and states

The sequence below shows the submit path inside the component, including the idempotency check and the transaction boundary.

8. Business rules and algorithms

IDRuleEnforced inSourceTest
BR-001 (Example)An order has between 1 and 100 linesOrder aggregateProduct backlog item [ID]UT-ORD-001
BR-002 (Example)Unit price is snapshotted at submit; later price changes do not alter the orderSubmitOrderHandlerPricing policyUT-ORD-004
BR-003 (Example)Cancellation is refused once the warehouse reports picking startedOrder.cancelLogistics agreementUT-ORD-009
BR-004 (Example)Unpaid orders expire after 30 minutesExpiry jobPayments policyIT-ORD-003
[BR-NNN][Rule][Class or module][Source][Test ID]

9. Error handling, retries and idempotency

9.1 Error catalogue

Errors are returned as problem details (RFC 9457) with a stable type URI per error.

Type URI suffixHTTP statusWhenRetry by caller
/problems/validation (Example)400 or 422Schema or business rule failure; errors lists fieldsNo
/problems/idempotency-conflict (Example)409Same key reused with a different request bodyNo
/problems/invalid-state (Example)409Transition not allowed from current statusNo
/problems/rate-limited (Example)429Caller quota exceededYes, after Retry-After
/problems/dependency-unavailable (Example)503Payment orchestrator timed out or circuit openYes, same idempotency key
[Suffix][Status][When][Yes / No]

9.2 Retry and resilience policy

CallPolicyCircuit breakerNotes
Payment intent (Example)No inline retry: one retry would take the worst case to 50 + 300 + 450 + 450 = 1,250 ms, above the 800 ms minimumOpens at 50 % failures over 20 calls, half-open after 30 sCaller retries with same key; expect about 1 % timeouts at the p99 setting
Outbox publish (Example)Exponential backoff from 200 ms to 30 s with jitter, unlimitedNot applicableAlert when oldest unpublished row is older than 2 min
Event consumption (Example)Broker redelivery, 5 attemptsNot applicableThen dead-letter topic, alert, replay tool
[Call][Policy][Settings][Notes]

Consumers must be idempotent: each consumer records processed event IDs for [7 days] and ignores repeats.

10. Concurrency, transactions and consistency

  • Transaction boundary: Example: one database transaction per command, covering the order rows, status history, idempotency record and outbox row. No remote call is made inside a transaction.
  • Concurrency control: Example: optimistic locking on orders.version; a conflicting update returns /problems/invalid-state after one internal re-read.
  • Ordering: Example: events for one order are published in commit order; there is no ordering guarantee across orders.
  • Read consistency: Example: the API reads from the primary; analytics consumers are eventually consistent with a typical lag under [5 s].
  • Scheduled jobs: Example: the expiry job runs on one replica at a time using a database advisory lock.

11. Configuration and feature flags

KeyPurposeDefaultAllowed rangeSourceRestart needed
payment.timeoutMs (Example)Payment intent timeout (IF-005); keep at or above the measured p99 and at or below 450 so the timeout path fits NFR-PE-001450300 to 450Config mapNo (reloaded)
orders.maxLines (Example)BR-001 limit1001 to 500Config mapNo
outbox.pollIntervalMs (Example)Relay polling20050 to 5000Config mapYes
db.pool.max (Example)Connection pool size per replica205 to 50Config mapYes
flag.partnerChannel (Example)Enable partner channelOffOn or offFeature flag serviceNo
vault:db-credentials (Example)Database loginNot applicableNot applicableSecrets vault, rotatedNo (dynamic)
[Key][Purpose][Default][Range][Source][Yes / No]

12. Security implementation

ControlImplementationHLD or NFR refVerification
Authentication (Example)Validate JWT signature, issuer, audience and expiry using the identity provider key set, cached 10 minHLD 10.1Unit and integration tests with forged tokens
Object-level authorisation (Example)Every read and write checks that the caller owns the order or holds the agent roleNFR-SE-002Negative tests per endpoint
Input validation (Example)Schema validation at the edge of the api module; size limits; reject unknown fieldsNFR-SE-001Contract tests, fuzzing in CI
Data protection (Example)Delivery address in an encrypted column; personal fields masked in logsNFR-SE-003Log scan in test
Secrets (Example)Read from the vault at start and on rotation events; never loggedNFR-SE-004Pipeline secret scan
Audit (Example)Status history row with actor and reason for each agent changeNFR-SE-006Test IT-ORD-007
[Control][Implementation][Ref][Verification]

Target verification level: [OWASP ASVS 5.0.0 level 2, or the internal standard]. Secure coding rules: Secure Coding Standard (security/secure-coding-standard).

13. Logging, metrics and tracing

SignalNameType and unitLabelsUse
Request duration (Example)http.server.request.durationHistogram, secondsroute, method, statusLatency SLO
Orders submitted (Example)orders.submittedCounterchannel, resultBusiness health
Outbox lag (Example)orders.outbox.oldest_ageGauge, secondsnoneAlert above 120 s
Payment dependency errors (Example)orders.payment.errorsCounterreasonCircuit breaker tuning
[Signal][Name][Type][Labels][Use]

Logging: structured JSON, one line per event, with trace ID, order ID and caller ID; personal fields masked; levels as in the coding standard. Tracing: OpenTelemetry instrumentation for inbound HTTP, database, outbound HTTP and broker spans; trace context is carried in event headers. Names follow OpenTelemetry semantic conventions (version [1.44.0 or the version pinned by the platform]).

14. Performance and capacity

Step in POST /v1/ordersBudget p95
Validation and mapping (Example)20 ms
Idempotency check and insert transaction (Example)60 ms
Price lookups from cache (Example)20 ms
Payment intent call (counted in the payment orchestrator budget)0 ms here
Serialisation, framework and network overhead (Example)50 ms
Headroom (Example)150 ms
Total inside component300 ms

Check (Example): 20 + 60 + 20 + 0 + 50 + 150 = 300 ms. With the gateway (50 ms) and the payment intent (350 ms p95) the request budget is 700 ms p95; on the timeout path it is 50 + 300 + 450 = 800 ms, the NFR-PE-001 minimum.

Sizing (Example): peak 50 requests per second for order submission (NFR-PE-002 minimum; target 60); measured capacity [40] requests per second per replica at the p95 target; three replicas give 120 requests per second, so one zone can be lost and the remaining two replicas (80 per second) still cover the 60 per second target. Database pool: 3 replicas x 20 connections = 60 at minimum scale, and 9 x 20 = 180 at the maximum of 9 replicas in section 16. Confirm 180 plus [other clients] fits the database limit of [200], or cap db.pool.max at [n]. The outbox relay publishes up to 60 events per second (IF-003), one per confirmed order.

15. Test approach

LevelScopeToolingKey casesGate
Unit (Example)Domain and use cases with fake ports[Test framework]All BR rows, every state transition including refused onesPull request, coverage of domain at [90 %]
Contract (Example)Provided OpenAPI and AsyncAPI, consumer-driven contracts[Contract tool]Each operation and event versionPull request
Integration (Example)Real database and broker in containers[Tool]Outbox order, idempotency, optimistic lockingMain branch
Performance (Example)Component under load in pre-production[Load tool]2x peak for 30 min, p95 at or below 300 ms inside the component; payment stub at p99 latency to prove the timeout pathRelease
Resilience (Example)Broker stopped during load in pre-production[Fault injection tool]Submissions keep succeeding, pods stay ready, outbox drains after restartRelease
Security (Example)Authorisation negatives, dependency and image scans[Scanner]Cross-customer access refusedRelease
[Level][Scope][Tool][Cases][Gate]

Test strategy: Test Strategy (quality/test-strategy); performance test plan: Performance Test Plan (quality/performance-test-plan).

16. Build, deployment and runtime

ItemValue
ArtefactExample: Container image [registry]/order-service:[semver], signed, with SBOM
PipelineExample: Build, unit, contract, image scan, deploy to test, integration, deploy to pre-production, performance, approval, production
Deployment strategyExample: Rolling update, max surge 1, max unavailable 0; database migration job runs first
Resources per replicaExample: Requests 0.5 CPU and 512 MiB; limit 1 GiB memory
ScalingExample: Minimum 3, maximum 9 replicas, scale on CPU 60 % and request rate
Health checksExample: Liveness on process health; readiness on database connectivity only. Broker health is surfaced through the orders.outbox.oldest_age alert, never through readiness, so a broker outage does not stop order capture (HLD section 11, ADR-003)
RollbackExample: Redeploy previous image; migrations are backward compatible, so no schema rollback
RunbooksExample: Links to the runbook for each alert in section 13 (dev/runbook)

17. Traceability and open issues

InputDesign elementTest
NFR-PE-001 (Example)Section 14 budget, cache use, pool sizePT-ORD-01
NFR-SE-002 (Example)Ownership check in application moduleST-ORD-03
ADR-003 (Example)Outbox table and relay, readiness without brokerIT-ORD-002, RT-ORD-01
ADR-004 (Example)payment.timeoutMs 450, no inline retry, circuit breakerPT-ORD-01
BR-003 (Example)Order.cancel guardUT-ORD-009
[ID][Element][Test ID]
IDOpen issueOwnerDue
ISS-LLD-001 (Example)Confirm currency list for launch markets@product-ownerYYYY-MM-DD
[ID][Issue][@owner]YYYY-MM-DD

Review checklist before approval:

  • Every provided operation and event is in a contract file and in section 5.
  • Every dependency call has a timeout, a retry rule and a fallback.
  • Every business rule has an ID, an enforcement point and a test.
  • No remote call happens inside a database transaction.
  • Personal data fields are identified, protected and masked in logs.
  • The latency budget and sizing arithmetic have been recomputed.
  • Nothing here contradicts the HLD inputs in section 2.

18. Glossary and references

18.1 Glossary

TermMeaning
AggregateCluster of domain objects changed together in one transaction, with one root
Idempotency keyCaller-supplied value that makes repeated submissions return the same result
OutboxTable of events written with the state change and published by a relay
Problem detailsStandard JSON body for HTTP API errors, defined in RFC 9457
Dead-letter topicDestination for messages that failed all delivery attempts
[Term][Meaning]

18.2 References

IDReferenceVersion or dateUse
REF-01IEEE 1016-2009, Standard for Information Technology: Systems Design: Software Design Descriptions2009; IEEE status Inactive-Reserved since 2020-03-05Concepts of design concerns, viewpoints and views
REF-02OpenAPI Specification, spec.openapis.org3.2 line (3.2.0 released September 2025)REST contract
REF-03AsyncAPI Specification, asyncapi.com3.1.0Event contract
REF-04RFC 9457, Problem Details for HTTP APIs (IETF)July 2023, obsoletes RFC 7807Error format
REF-05OWASP Application Security Verification Standard5.0.0, May 2025Security verification level
REF-06OpenTelemetry semantic conventions, opentelemetry.io1.44.0 at time of writingTelemetry names
REF-07[Parent HLD][Version]Fixed inputs

Standard and licence note

Structure aligned with IEEE 1016-2009 (design stakeholders, concerns, viewpoints and views for a software design description); IEEE lists this standard as Inactive-Reserved, and it remains a common reference for detailed design. Contract and error formats are based on the OpenAPI Specification, the AsyncAPI Specification and IETF RFC 9457; the security level refers to the OWASP ASVS by name and level only, and no OWASP text is adapted. No text, definitions or tables are reproduced from IEEE standards. This template is original text written for this collection. Check the current versions at standards.ieee.org, spec.openapis.org, asyncapi.com, rfc-editor.org and owasp.org before use. Template licence: MIT.

Modèles associés