Self-study: A CRUD Diagram of a Todo App

Reinforce the series: draw a “Client → Server → Database” diagram in Excalidraw for six actions in a Todo app — the method, the request, the response and the changes in the table.

Self-study task

1Try the app

Open the Todo app and see what it can do:

  • add a few tasks
  • mark one as completed
  • change the text of a task with a double-click
  • delete a task with the cross
  • click through the All, Active and Completed filters

2Imagine the server and the database

The app has a server and a database with a todos table. It has three columns: id, title and completed.

Example of the todos table
idtitlecompleted
1Prepare the reportfalse
2Update the documentationtrue
3Check the sign-in formfalse
  • true — the task is completed — the app shows it crossed out
  • false — the task is active — not done yet

Task

In Excalidraw, draw a “Client → Server → Database” diagram for each of the 6 scenarios:

  1. 1The user opens the task list
  2. 2The user adds a new task
  3. 3The user marks a task as completed
  4. 4The user changes the text of a task (double-click)
  5. 5The user deletes a task (the cross)
  6. 6The user clicks the Active filter

For each scenario, label:

  • MethodGET, POST, PATCH, PUT or DELETE
  • RequestThe address and the body, if one is needed
  • ResponseThe code and what the server returns
  • Database tableWhat changed after the operation — or what didn’t

All scenarios are positive: the user does everything right, and the server carries everything out.

How to hand it in

Do your homework and send your teacher a link to the diagram: in Excalidraw, click Share → Shareable link and copy the link. Good luck, you’ve got this!

Quick reference

Methods and CRUD

POST /api/v1/products — create (201 Created), GET /api/v1/products — read (200 OK), PATCH /api/v1/products/3 — change part of the data, PUT /api/v1/products/3 — replace completely (both 200 OK), DELETE /api/v1/products/3 — delete (204 No Content).

The record number in the address

When a request is about one task, its id usually goes in the address: for example, /todos/3. The whole list is /todos.

Request body

A body is needed when the client sends data: when creating and changing. GET and DELETE usually do without a body.

Filter

A filter changes nothing in the database — it is a read. The condition can go in the address, for example /todos?completed=false.