Skip to content
MINH VO A working notebook
by an engineer in Vietnam
Foundation8 min read

A frontend developer's first backend vertical slice

Build a first backend vertical slice around one note-creation request, durable storage, clear input rules and a recovery case.

Watercolor notebooks, an open sketchbook and a wooden pencil on a cream surface

For a frontend developer learning backend work, a small vertical slice should connect one user action to a durable result and make one failure recoverable. I favor that scope because you can follow the whole request while the system is still small enough to explain. A large API with many endpoints can hide the same unanswered questions behind more files.

Use a hypothetical note-creation feature. The first version accepts a title and body for one exercise account, stores them and returns a note identifier. It does not need collaboration, search or a background job. The learning goal is to understand the contract between the form, endpoint and stored record.

State the contract before writing the handler

Write down the accepted input and the visible result. For example, the title must contain non-whitespace text, the body may be empty and the server assigns the identifier. Choose those rules deliberately; another product may make different choices.

The MDN HTTP overview describes how clients and servers exchange requests and responses. Your application supplies the meaning of the request body and result. A successful connection does not establish that the note met the product’s rules or was durably stored.

For this exercise, define the following cases before implementation:

Input or conditionExpected application behavior
Valid title and bodyCreate one note and return its identifier
Whitespace-only titleReject the request with a field-level explanation
Unexpected fieldApply an explicit reject-or-ignore policy
Storage unavailable before the writeReturn a failure without claiming the note was saved
Response lost after a completed writeTreat the result as uncertain until the client can resolve it

The last row deserves attention even if the first implementation only documents it. It separates a failed response from a failed operation. Do not give the interface a message that confidently says “nothing was saved” when the server’s result is unknown.

Keep the first data model inspectable

A note record needs an identifier, title, body and owner. A creation timestamp may be useful, but decide who supplies it and what it means. Client clocks can differ, so a server-assigned timestamp is often easier to interpret for creation order.

Store ownership with the record even if the exercise starts with one account. That makes the eventual authorization question visible. A single-account local prototype can postpone an authentication integration; it should still explain that limitation instead of quietly treating a fixed user identifier as a production identity design.

If creating the note also creates another required record, such as an audit entry in the same database, decide whether those writes must succeed together. The PostgreSQL transaction tutorial explains transactions as grouped operations with all-or-nothing behavior. The database transaction does not automatically include an external email or file upload, so keep the first slice within a boundary you understand.

A note form sends a defined request, the endpoint validates it, a stored record is inspected and the interface shows the matching resultView full-size image ↗

The stored-record check is separate from the response check. A handler could accidentally return a plausible identifier without writing the intended values. A database row could also exist while the interface presents the wrong success state.

Build one path and inspect its boundaries

Start by submitting a valid request directly to the endpoint. Inspect the returned identifier and use it to read the stored record. Compare every accepted field with the request. Then connect the form and repeat the same check through the interface.

This order helps isolate problems. If the direct request succeeds but the form does not, inspect serialization, headers and the event path. If both fail in the same way, inspect the server’s validation and storage behavior. Avoid changing several layers at once without knowing which observation each change is meant to explain.

Next, run the invalid-title case. Check that the database did not gain a record, that the endpoint returned the intended failure and that the interface explains how to correct the input. A test that only checks for any error misses the agreement between the layers.

Add one recovery case before another feature

Temporarily make storage unavailable in the isolated exercise environment. Submit a note and observe the result. The interface should leave the user’s input available for recovery rather than discarding it after a failed save. Restore storage and repeat the request under the operation’s stated retry rule.

A more demanding variation loses the response after the write. That may require a deliberate test hook or a controlled proxy. If you have not built that experiment, keep it in the unresolved list. Do not say the retry behavior is verified merely because the ordinary request succeeded twice.

For review, collect the contract table, one accepted request, one rejected request and the matching stored-state observations. Explain where identity comes from and which failure remains untested. That packet lets another developer assess the slice without reconstructing your intentions from the code.

Once you can explain those artifacts, choose the next feature that introduces a new question. Editing a note introduces concurrency. Sharing introduces authorization changes. Exporting introduces longer-running work. Each addition has a reason to exist in the learning plan beyond making the demo look larger.

Turn the form into a precise input contract

Choose one normalization rule before comparing request and stored values. For this exercise, trim whitespace around the title but preserve whitespace inside the body. The title and body must both be strings; an empty body is valid. Reject fields outside the defined input schema, including a caller-supplied owner or note identifier. Those values belong to the server’s identity and storage decisions.

The difference between normalization and validation is useful to a frontend developer. Normalization turns an accepted representation into the form the product wants to store. Validation decides whether an input belongs to the accepted domain. Silently converting an array into text is neither an obvious nor a necessary part of a note-create contract.

Submitted inputExpected interpretation
Title Grocery, empty bodyStore title Grocery and preserve the empty body
Title containing only spacesReject after trimming; create no note
Body is an arrayReject the wrong type
Input includes ownerIdReject the unexpected field under this chosen policy
Malformed JSONReject the representation before field validation

Put input-size limits in the contract as well. Name the unit: encoded request bytes, code points and a language runtime’s string length can differ. You do not need an elaborate international-text policy for the first fixture, but a reviewer should not have to guess what “maximum length” means. Keep any limit enforced by the form consistent with the server’s authoritative rule.

Make the success response point to the created object

A useful successful response contains the server-assigned identifier and the normalized values the interface should present. For an HTTP endpoint that creates a resource, 201 Created communicates that creation has occurred; a Location header can identify the created resource. Choose the actual route and representation as part of the API design rather than copying a status code without its meaning.

Send success only after the storage operation reaches the completion point promised by the application. A successful HTTP status does not independently prove the database configuration provides the durability you assume. In the local exercise, inspect the row, restart the application process without resetting its database, then read the same identifier again. That distinguishes process memory from the persistence path you intended to learn.

The check also separates application restart from database recovery. Restarting the API process is a smaller experiment than power loss or restoring a database backup. Preserve that distinction when you describe what the slice demonstrates.

The note-create contract trims the title, validates types and server-owned fields, commits the record and returns the same identity for a later readView full-size image ↗

Trace a discrepancy to the boundary that produced it

Suppose the form shows Grocery after the server stored Grocery. That may be an interface synchronization issue under the chosen normalization rule. If the server returns identifier 92 but a read of 92 finds no note, investigate the persistence and response path before changing the form. If direct valid requests succeed while form requests fail type checks, inspect the serialized request rather than weakening server validation.

Keep the observation small enough to explain. Record the accepted input, returned identity, persisted fields and rendered state together, using fictional data. Avoid logging the entire contents of real notes merely to make debugging convenient. A field name, error category and request identifier can be enough to connect the steps in this exercise.

The first slice is complete when those boundaries agree for the selected valid, invalid and recovery cases. It is still a small application contract, not a general backend certification. The next feature should add a specific new responsibility while preserving the behavior this slice already established.

Sources & further reading

  1. MDN: overview of HTTP
  2. PostgreSQL tutorial: transactions
  3. MDN: 201 Created
← Back to the journal
All notes

Illustration

100%