Capstone Project 4: Design a Scalable E-commerce Platform
Integrate catalog, search, cart, checkout, inventory, payment, order events, and notification workflows.
Domain Boundaries, Catalog, Search, and Cart
Separate major responsibilities: catalog owns product facts, search provides a query-optimized index, cart stores a user's intended selections, inventory owns stock availability, order management owns the order lifecycle, and payment integration tracks provider transactions.
Search is a derived index and may lag behind catalog updates. Product detail pages can use cacheable read models, while price and stock must be revalidated at checkout. A cart is not a reservation unless the business explicitly reserves inventory when items are added.
Define API contracts and ownership so two services do not independently become the source of truth for the same field. Denormalize product display data into read models when useful, but specify how updates and deletion propagate.
- Give each domain clear ownership of its authoritative data.
- Search and catalog views may be eventually consistent.
- Revalidate price and availability at checkout.
Why should an e-commerce search index generally not be the source of truth for inventory?
Checkout, Payment, and Order Orchestration
Checkout validates the cart, calculates totals, reserves inventory, initiates payment, and confirms or cancels the order. Persist each state transition and use idempotency keys for client retries. Never rely on a single long HTTP request to complete every external action.
Use a saga or durable workflow for cross-service steps. If payment fails, release the reservation; if payment succeeds but the response is lost, query or reconcile provider state before charging again. Webhooks must be authenticated, deduplicated, and safe to process out of order.
Publish order events through a transactional outbox so downstream systems—email, analytics, fulfillment—can react without losing the relationship between a committed order and its event. Consumers should be idempotent and expose backlog metrics.
- Use durable state transitions and idempotent checkout requests.
- Handle ambiguous payment outcomes through provider lookup and reconciliation.
- Use an outbox for reliable downstream event publication.
Scaling, Security, and Operational Readiness
Cache product reads and static assets, but keep inventory and payment correctness in controlled write paths. Partition high-volume order or event data based on query and retention patterns. Protect flash-sale endpoints with admission control, queues, and fair rate limits so a surge does not overwhelm every dependency.
Secure customer data, restrict administrative actions, tokenize payment data through compliant providers, and avoid storing sensitive card data unless the organization has the necessary compliance program. Audit price changes, refunds, inventory adjustments, and privileged access.
Monitor checkout conversion alongside technical SLIs. A service can return HTTP 200 while a business flow fails later. Track payment success, reservation expiry, order confirmation delay, outbox lag, reconciliation mismatches, and inventory anomalies.
- Protect correctness-sensitive writes from traffic spikes.
- Treat privileged business operations as auditable security events.
- Observe business outcomes as well as infrastructure health.