Skip to content

Part II: Building the first version

13. Make it save your data

Save the information your product needs and check who can access it.

Which tool will you build with?

Choose the one you’re comfortable using. We’ll remember your choice as you work through the handbook.

Your designer creates a request. Later, the client opens it on another device and responds. The designer comes back to read the answer. For that to work, the information needs to survive beyond the browser session where it was entered.

A database gives the application a shared place to store and retrieve that information. In our Prisma build, we'll use Prisma Postgres for that role. If your starter already has a database, inspect and use the existing setup before adding another one.

Keep using made-up content while you build and test. The change in this chapter is that the information you enter will be saved and available when you return, including from another device. You don't need real client work to check that.

The information needs to survive beyond the browser session where it was entered.

Describe what needs to be remembered

Start with the things in the flow. For our hypothetical product, there's a feedback request and a response to it. Each needs enough information for the product to show the right content to the right person.

ThingWhat it needs to remember
RequestIts identifier, designer, intended client, draft link, and question
ResponseThe request it answers, who submitted it, and the answer

An identifier lets the application distinguish one request from another, even if they ask the same question. Connecting the response to that identifier lets the designer see which request it answers.

You also need a few rules. Can the client change a response after sending it? Can the designer change the question after someone answers? For this first trial, keep a shared request fixed and create a new one if the draft or question changes. That avoids making an old response appear to approve something the client hasn't seen.

Write these decisions in the brief. They affect the product's behaviour, so the AI needs them when it implements the data model.

Decide who can see and change each record

The designer should be able to create requests and read their responses. The client should be able to see and answer the request intended for them. An unrelated visitor shouldn't gain access by changing an identifier in the URL.

An account can establish who someone is. The application still needs to check whether that person may perform the requested action. Hiding a button doesn't enforce that rule; the code handling the action must check access too.

Ask the AI to inspect what the starter already supports and recommend an access approach for your brief. Have it explain how each person will get access and what they will be allowed to do. If it proposes a private link, ask what happens if the link is forwarded. Choose the approach before asking it to connect the screens to saved data.

For the first trial, use sample design material and test identities. Have the AI help you set up access for the designer and client and explain how to open the product as each of them. These are the people using your product; their access is separate from your own Prisma and AI accounts. You can arrange their access manually without building a full signup experience.

Connect the existing flow

Prisma ORM lets application code work with the database. The Prisma ORM quickstart describes the setup for Prisma Postgres. Use the configuration and commands appropriate to the versions already in your project.

Choose ChatGPT or Claude above to see these steps.

Give the AI the data requirements and chosen access rules from your brief, then ask it to connect the screens you've already built. Adapt the request-and-response example in this prompt to the information your product needs to save:

Connect the flow to saved data
Inspect the existing Prisma setup and use the current project
conventions. Implement the request and response model in our brief.

Connect request creation, the client request page, response
submission, and the designer's response view to the database.
Validate submitted values on the server as well as in the form.

Explain any database changes before applying them. Preserve existing
records. Show success only after the save succeeds, and preserve the
user's input if it fails.

Implement the access rules we agreed on. Check permission when the
application reads or changes a record, even if the interface hides
the action. Set up test access for each kind of user and explain
how I can try the product as each one. Add checks that an unrelated
visitor cannot read or change their records.

List the project's required setup steps without displaying credentials.
Then verify the complete flow with disposable sample data.

A database change needs to reach the database as well as the code. Ask the AI which project command applies that change, and read the result. An edited data definition alone doesn't demonstrate that saving works.

Prove that saving works

Create a new request from the designer's view. Use a different browser or a private browsing window for the client, so it doesn't share the designer's sign-in. Open the request using the client's account or private link. Submit a response, then return to the designer's view. Refresh both pages and check that the right content remains.

Then try opening the same request without the required account or private link. Check that you can't read or change it. Use the application's normal interface to test, and ask the AI to add focused checks for the access rules behind it.

Keep a note of anything that failed. We'll use that list in Test it, fix it, and keep going before sharing the product.

Before you move on0 / 4