Esmeralda C. Cabrera Ventura ← Articles Dossiers Project details Portfolio LinkedIn
Engineering Dossier Headless CMS · API Integration Four milestones complete

Headless CMS Storefront

A React shopping cart powered by a Strapi 5 backend: the catalog modeled and published in a headless CMS, every endpoint tested and secured, and the storefront restocked live from the API.

Implementation & API Testing
Esmeralda C. Cabrera Ventura
Headless CMS · Content Modeling · REST API Testing · Token Authentication · React
Scope of this document
A technical account of four milestones: standing up and modeling a headless CMS backend with least-privilege roles, an API testing workflow, an authenticated write secured by a scoped token, and a React client adapted to a breaking response-shape change the instructions did not anticipate.
Engineering Facts
Windows · Node.js v24 · Strapi v5.60 · local SQLite

Access levelspublic read, token-authorized write2

Milestones deliveredcontent model to live storefront4

HTTP requests verifiedtwo reads, two writes4

Public role permissions grantedfind and findOne only2

Token permissions on the live write key1

Fastest measured API response59 ms
Authenticated write66 ms · 201
Independent confirmations of that write3

Times the instructions were wrong3

Because the backend is generated from a content model rather than hand-written, the engineering shifts to data modeling, access control and API integration — and to noticing when a tutorial is older than the tool it describes.
01
Thesis

When the backend is generated, the judgement moves

Not away from engineering — toward modeling, access control and verifying what the API actually returns.

This project builds the data layer and storefront of a small online shop. A headless CMS stores the product catalog, provides an admin panel for non-technical editors, and auto-generates a REST API from the content model, leaving the presentation layer to any frontend. A React cart consumes that API.

Nobody hand-writes server code here, which is the point and also the trap. The work that remains is the work that decides whether the result is correct: how the data is typed, who is permitted to change it, and whether the client matches the response the API genuinely produces rather than the one the documentation describes.

The response is the contract. The tutorial is a description of the contract, written at an earlier date.

The four milestones

  • Backend — model a product collection, configure least-privilege role permissions, publish the catalog, expose it over REST
  • API testing — learn the workflow against a public practice API: status codes, latency, payload size and response shape
  • Authenticated writes — apply that workflow to my own backend, creating a product through a token-protected endpoint
  • Storefront — connect the React cart so its catalog restocks from the live API
The React storefront with product list, cart contents, checkout and a restock field pointing at the local API
The full loopA product created through an authenticated API request, stored by the CMS, and pulled into the storefront — the complete path from API client to database to user interface.
02
Model

Typing the catalog, and locking it down

Four fields, two of them deliberately numeric, and a default of exposing nothing.

FieldTypePurpose
NameTextProduct name
CountryTextCountry of origin
CostNumber · integerUnit price, so the frontend can do arithmetic without parsing strings
inStockNumber · integerAvailable units, for the same reason

Typing cost and stock as integers rather than text avoids a whole category of bug in which "$3" and "3" are the same value to a person and different values to a program. It is the cheapest decision in the project and the one with the longest reach.

Least privilege, by default

The CMS exposes nothing publicly unless told to. For the public role I enabled exactly two operations — find and findOne — so anyone can browse the catalog and no unauthenticated caller can create, edit or delete a product. Every write therefore needs a credential, which is what makes the authenticated request in section 04 meaningful rather than decorative.

Public role
Read only
find and findOne on the product collection. Nothing else is reachable without a credential.
Enabled
Writes
Token required
Create, update and delete are unavailable to anonymous callers by design.
Scoped token
Publishing
Draft and published
Only published entries are returned by the public API, so unfinished edits never reach the storefront.
The content manager showing four products with published status
CatalogThe starting catalog entered and published. Unpublished entries are invisible to the public endpoint.
The CMS admin dashboard showing schema, published content and API token tasks complete
Admin panelThe non-technical editing surface the CMS provides — the reason a headless CMS suits a catalog that someone other than a developer maintains.
03
Data

Two things the raw JSON said that the admin UI did not

Reading the actual response rather than the interface surfaced both immediately.

The public products endpoint returning four products as JSON with pagination metadata
The public endpointAll four products returned as JSON, with pagination metadata confirming the total. This view is what exposed both issues below.

Data quality

The raw JSON revealed trailing spaces inside product and country values. They are invisible in the admin interface, and perfectly capable of breaking an exact-match search or filter later — the kind of defect that gets reported as "search doesn't work for some products" long after anyone remembers typing them. I corrected them and republished.

Identifiers

The admin list showed one set of numeric IDs while the API returned another. Strapi 5 stores a draft row and a published row per entry, and the API serves the published rows, so the numeric ID is not a stable handle across both. The document ID is.

Reaching for the obvious-looking integer would have produced code that works until someone edits an entry — which is the worst kind of working.
04
Auth

Reads are public, writes carry a token

The same testing workflow, applied first to a practice API and then to my own.

Before testing my own backend I spent a round against a public practice API, sending one read and one write and analyzing the status code, response time, size and body of each. The distinction worth internalizing: a 200 means "here is what you asked for," while a 201 means the server accepted a payload and created a resource. The practice API confirmed creation twice over — the status, and a server-generated identifier in the body — which is exactly the pattern to look for when verifying any write.

RequestAuthStatusTimeResult
GET /postsNone200 OK134 ms100 posts across 10 users, each with the expected fields
POST /postsNone201 Created129 msEchoed the payload and assigned a new identifier
GET /api/productsPublic role200 OK59 msFull catalog returned in the response envelope
POST /api/productsBearer token201 Created66 msNew product created and published immediately
A public GET request to the local API returning 200 OK
Public readNo credential required, because the public role permits exactly this.
An authenticated POST with a redacted Bearer token in the headers returning 201 Created
Authenticated writeSucceeds only because the request carries a valid token. The token value is redacted in every capture.

Cross-checked three ways

The write was confirmed from three independent places: the response in the API client, the server's own request log recording the same call at the same moment, and the record itself in the database. Postman, the log and the data all describing one write is a stronger claim than any one of them alone — and it is the habit that catches a request that appeared to succeed but never reached the server.

Tokens are credentials. Every capture in this report has the token value redacted, and in a real deployment it belongs in an environment variable, never in source code or a shared collection.
05
Client

Mapping the response that exists

The starter code described an older response shape. Following it literally would have produced a list of undefined values.

The storefront's root component owns the state — products, cart and total — and passes data and callbacks to four children: the catalog list, the cart, the checkout total, and the restock form, which receives the setter so it can replace the shared catalog.

The restock handler prevents the browser's default form submission, awaits a request to whatever URL was typed into the form, maps each product into the four fields the UI uses, and hands the result to the setter so React re-renders. The whole request is wrapped in try/catch, so a bad URL or a stopped server logs an error instead of crashing the app.

The breaking change

The starter comments said to read each product from an attributes wrapper — the older response shape. Inspecting the real response showed that the current major version returns fields at the top level instead. Mapping through the wrapper would have produced a catalog of undefined values: a UI full of blanks, with no error anywhere to explain it.

The completed restock component in an editor with no errors or warnings
The handlerMapping the real response shape rather than the documented one, with the request wrapped so a failure is logged instead of fatal.
The CMS command-line tool prompting for a cloud login during project creation
A step not in the instructionsThe CLI asked about a cloud signup the tutorial never mentioned, because the tutorial was written for an older version. Skipped to keep the project local.
06
Debugging

Three times the guidance was wrong

A missing prompt, a confidently incorrect suggestion, and a breaking change — each requiring the same move.

IssueRoot causeResolution
CLI prompt not in the instructionsTutorial written for an older version of the toolIdentified the skip option and kept the project local
Native dependency install failedNetwork timeouts fetching the prebuilt binary, then the headers needed to compile from sourceDiagnosed from the install log; re-ran the install inside the project, which completed
Invisible data errorsTrailing spaces typed into product fieldsCaught by inspecting raw JSON; cleaned and republished
API client request failed outrightDNS lookup failure — not the request body, despite the assistant's suggestionRead the error, declined the suggested fix, retried the unchanged request
Restock mapping per the instructionsThe major version removed the attributes wrapperVerified the real shape and mapped top-level fields

The misleading suggestion, in detail

My first write to the practice API failed with a getaddrinfo ENOENT error, and the tool's AI assistant offered to "fix request body format." Reading the error itself told a different story: getaddrinfo is the DNS lookup, so the request never left my machine and the JSON body could not possibly be the problem.

The suggestion was specific, plausible and wrong. The error message was right there, and said something else.

I declined the fix, treated it as a transient network issue — consistent with the timeouts already seen during installation — and re-sent the unchanged request, which succeeded. Had I accepted the suggestion, I would have changed working code and still had a DNS problem.

Reading past the noise

The failed install produced a long log full of deprecation and cleanup warnings, all harmless. The useful lines were two timeouts. A timeout means retry; a configuration error means reconfigure. Reading far enough to tell them apart saved a rebuild.

A long install log ending in a failure in the native database driver
Mostly noiseDeprecation and cleanup warnings were harmless; the real cause was a timeout fetching a prebuilt binary.
The API client showing a request that could not be sent, with a DNS resolution error
Not a body problemThe request body was valid; the hostname could not be resolved at that moment.
07
Status

What works, and what is honestly incomplete

A list of what a thing cannot do yet is more useful than a claim that it is finished.

CapabilityStateNote
Content model and published catalogDeliveredTyped fields, draft and published workflow, stable document identifiers
Least-privilege public accessDeliveredRead-only public role; writes require a scoped token
Verified API contractDeliveredFour requests across two APIs, cross-checked against the server log and the database
Live storefront restockDeliveredAdapted to the current response shape rather than the documented one
Product imagesIncompleteThumbnails show placeholders because the image files are absent, and photos are chosen by list position, so they would mismatch after a restock. Needs a media field per product
Cart identityIncompleteThe cart counts quantities by name, so two products sharing a name would share a stock count. Key by document identifier
Real commerceNextA CMS handles the catalog and has no cart, orders or payments. Needs accounts, an orders collection, stock decrement on purchase and a payment provider
Configuration and dependenciesNextAPI URLs are hard-coded; dependency audits report vulnerabilities in starter packages; tokens belong in environment configuration
Test coverageNextA test runner is configured but the new features are not covered. Unit tests for the restock mapping and API route tests, run in CI
What this build demonstrates

Read the response, not the tutorial


The storefront works end to end, and the most transferable thing in the project is not the code. It is the habit of checking what a system actually returns before writing a client against it — which caught a breaking version change, two invisible data errors and an incorrect debugging suggestion that would each have cost far more later.


Strapi 5 · React 18 · REST · Postman · API tokens · axios · React-Bootstrap · SQLite · Node.js · Webpack

Read the article →  ·  All project details  ·  Portfolio & resume  ·  LinkedIn