Skip to main content

Map Application State

You will determine who owns each value, how long it must survive, and where the application stores it.

1. Map the data model​

Read the files in database/migrations in timestamp order. For each domain table, record:

  • Primary key
  • Foreign keys
  • Unique constraints
  • Important columns and timestamps

Compare the schema with the relationships in app/Models. Identify which records checkout creates or changes.

2. Classify state​

Complete this table in your notes with concrete examples from the store:

Kind of stateOwnerRequired lifetimeStorage location
Request dataOne requestUntil the responseYour finding
CookieOne browserAcross matching requestsYour finding
Guest cartOne visitorBrowsing sessionYour finding
Product and order dataApplicationAcross restartsYour finding
Cached dataApplication or instanceUntil expirationYour finding
InvoiceOrder or instanceDetermine from evidenceYour finding

A cookie and a session are not the same thing. Determine what the browser stores and what its cookie identifies on the server.

3. Compare browser contexts​

  1. Add an item in one private browser window.
  2. Open a second private browser window.
  3. Compare the carts and cookie names.
  4. Explain which state belongs to one visitor and which is shared by the application.

Do not record or share cookie values.

4. Draw the system​

Create a component diagram containing:

Browser -> Nginx -> Laravel -> PostgreSQL

Add sessions, cache, invoices, and external-service simulators. Mark each storage location as browser-local, instance-local, or shared.

Next, test those boundaries under architecture pressure.