Many ecommerce projects assume that every order follows the same path. Real businesses often sell in ways that need different rules, carts, and fulfilment options. A good storefront design alone cannot fix that gap.
This article explores how developers can structure one storefront around separate commerce responsibilities. It uses a documented grocery and takeout project as its main reference point.
Define Commerce Responsibilities Before Choosing Architecture
Start by listing the business rules that the platform must enforce. Those rules decide where the application boundaries should sit. Software selection should come only after that analysis is complete.
Three responsibilities usually need clearly separate owners: commerce logic, editorial content, and storefront presentation. Mixing them makes every later change harder to review, estimate, and test.
Separating Commerce, Content and Storefront Responsibilities
In this architecture, Medusa acts as the commerce backend. It manages products, pricing, carts, checkout, customers, promotions, and orders. Its extensible design supports business-specific ordering workflows when teams need them.
Strapi manages landing pages, promotions, and FAQs as a separate content system. Staff can update routine content without touching transactional commerce data. That boundary keeps editorial work away from pricing and orders.
Next.js serves as the responsive, customer-facing storefront in this design. It combines commerce data from Medusa with content from Strapi. The diagram below shows these relationships conceptually, not as verified production topology.
Customer browser
|
Next.js storefront
| |
Medusa Strapi
(commerce) (content)
|
+-- Grocery Basket cart
+-- Takeout Order cart
Medusa - - - > [secure local bridge: PLANNED] - - - > SoftPlus POS
Designing Separate Cart and Ordering Contexts
Grocery and takeout orders follow different rules, so they need distinct cart contexts. A cart context defines which items, checkout steps, and fulfilment options are valid together.
Asian Basket uses a Grocery Basket and a Takeout Order, with separate carts. Guest purchasing is supported according to the case study. Everything else in this section is a general recommendation, not project detail.
Developers can model each context as a distinct type with its own validation. A shared checkout function should reject combinations that violate the active context's fulfilment rules.
// Illustrative TypeScript, not Asian Basket production code. Untested.
type Cart =
| { kind: "grocery"; itemIds: string[]; fulfilment: "pickup" | "local_delivery" }
| { kind: "takeout"; itemIds: string[]; fulfilment: "pickup" | "third_party_delivery" };
function validateCart(cart: Cart, itemKinds: Map<string, "grocery" | "takeout">): string[] {
const errors: string[] = [];
for (const id of cart.itemIds) {
if (itemKinds.get(id) !== cart.kind) {
errors.push(`Item ${id} does not belong in a ${cart.kind} cart.`);
}
}
return errors;
}
Keeping Transactional Data Separate From Editorial Content
Pricing, stock, carts, and orders are transactional data owned by commerce. Landing pages, promotions, and FAQs are editorial content and belong elsewhere. Each type also needs its own editing workflow and approval path.
The storefront still has to combine both sources on one page. That raises questions, such as what to show when content is unavailable. Core commerce pages should still render when editorial blocks fail.
Composing Independent Services in a Next.js Storefront
A Next.js storefront can request commerce and content data independently, then merge the results. Server-side code can handle those requests before the page reaches the browser.
Editorial content changes slowly, so it tolerates caching well. Availability, cart totals, and checkout state need fresher data and backend validation. Caching those values carelessly can show customers outdated stock or prices.
These points are general recommendations, since Asian Basket's caching approach is not documented. Teams should choose rendering modes only after testing their own traffic and data.
Applying the Architecture to Asian Basket
Asian Basket is a grocery and vegetarian takeout business in Windsor and Essex County. Gyan Solutions designed one unified headless platform to serve both ordering models.
Medusa runs commerce, Strapi manages content, and Next.js presents the responsive storefront. The catalogue uses a simple two-level Department and Category structure to keep navigation shallow.
The Asian Basket architecture case study covers the wider project background for readers who want it. This section summarizes only the architectural decisions that matter, so the link is optional.
Planning POS Synchronization Without Tight Coupling
Asian Basket manages in-store products, pricing, and stock in a local SoftPlus POS system. The online platform must work alongside it without disrupting daily store operations.
The team designed a phased approach around a proposed secure local bridge. That bridge would exchange permitted product, pricing, and inventory data with the ecommerce platform.
Synchronization has not been confirmed as completed, so this section describes planning only. Similar projects should define product identifiers and data ownership before designing retries and reconciliation.
Engineering Trade-Offs and Failure Scenarios
Operating independent components creates independent failure modes that teams must plan for. A content outage, a slow commerce call, or a stale cache affects different pages.
The commerce backend should remain the authority for validation. The storefront can guide users, but the backend must confirm every order. Client-side checks improve usability but never replace server-side validation.
Test each ordering workflow separately, including invalid item combinations and unavailable fulfilment options. Also simulate content and commerce service failures during checkout. These are recommendations, not documented Asian Basket test results.
Architectural Lessons for Ecommerce Developers
Business rules should usually shape application boundaries, not the other way around. Modular systems still need clear data contracts, shared identifiers, and agreed ownership of records.
Simpler architecture is often the better choice for businesses with conventional ordering needs. A single platform with built-in content tools can often be easier to operate.
Where do you draw the boundary between commerce validation and storefront logic in your projects? Share how your team handles multiple ordering models in the comments below.
Top comments (0)