The first backend was a standalone Laravel API. The rebuild puts Hampa on the platform I wrote for Starsor: one Laravel application that renders its pages on the server through Inertia and Vue 3, with TypeScript on the front end.
Accounts, the catalog, the cart, checkout, payments and the admin panel come with that platform. What has to be written for Hampa is everything a store doesn't have, and the first backend already models it:
Programs, tiers and add-ons
A program has a type (workout or nutrition), a level and a goal. It sells in tiers with their own prices and can carry optional add-on services ordered with it. An order's total is recalculated from its lines, tiers, add-ons and discount code on every change.
A questionnaire that branches
Questions are data, not code: each has a type, options, a validation rule and an optional condition on an earlier answer or a profile field such as gender. A program lists the questions it needs, and an order counts as complete only when every required question that applies has an answer.
States that set themselves
A program order is waiting for the form, waiting for the plan, or has its plan. Nobody sets that by hand: the state is recomputed whenever an answer, a body record or a plan is saved, and payment is tracked separately from it.
Body records
Age, height, weight and the three photos are stored per order rather than per account, so each plan keeps the measurements it was written from.
Plans as documents
A finished plan is one structured document attached to the order: sessions, exercises, sets, meals and notes. Coaches start from reusable templates of the same shape, and the same document renders in the web panel and on a phone.
Libraries and substitutes
Exercises carry a level and the muscle areas they target; foods carry their macronutrients. Substitutes are stored as pairs in both libraries, which is what the swap above reads.
Content per language
Programs, questions, exercises and foods keep their text in translation tables, so another language is new rows rather than new columns. The first market is Persian.