Tutorial: Chatter
DUE Wed, 09/10, 2 pm
Image: Free Icon, ChatGPT
This tutorial may be completed individually or in teams of at most 2. You can partner differently for each tutorial.
In this tutorial, users use the Chatter
app to post textual chatt
s
to our backend chatterd
. The backend stores each chatt
in a database
and shares all posted chatt
s with everyone else accessing the backend.
Treat messages you send to chatterd
and Ollama as public utterances
with no reasonable expectation of privacy and know that these
are recorded and shared with everyone who uses chatterd
.
This second tutorial builds on the first one, so if you haven’t completed the first one, you should do so first.
Expected behavior
Posting a new chatt:
DISCLAIMER: the video demo shows you one aspect of the app’s behavior. It is not a substitute for the spec. If there are any discrepancies between the demo and the spec, please follow the spec. The spec is the single source of truth. If the spec is ambiguous, please consult the teaching staff for clarification.
Objectives
Front end:
- how to submit HTTP GET, in addition to POST, asynchronously
- how to convert to/from JSON manually
Back end:
- How to set up a PostgreSQL database and table
- How to interface URL path handlers with PostgreSQL
APIs and protocol handshakes
Chatter
is a simple CRUD app. We’ll use the chatts
table we will create in PostgreSQL
to hold posted chatt
s. In this tutorial, we add two APIs to Chatter
:
postchatt
: uses HTTP POST to post achatt
as a JSON object.getchatts
: uses HTTP GET to query the database and retrieve all postedchatt
s,
Chatter
does not provide “replace” (HTTP PUT) and “delete” (HTTP DELETE) functions.
Using this syntax:
url-endpoint
-> request: data sent to Server
<- response: data sent to Client
The protocol handshakes consist of:
/postchatt
-> HTTP POST { username, message }
<- {} 200 OK
/getchatts
-> HTTP GET {}
<- [ array of chatts ] 200 OK
Data formats
We associate a username
with each message
in a chatt
. To post a chatt
with the postchatt
API, the front-end client sends a JSON Object consisting of "username"
and "message"
. For example:
{
"username": "YOUR_UNIQNAME",
"message": "Hello world!"
}
The getchatts
API sends back all posted chatt
s as a JSON Array of string arrays
(that is, an array or arrays). Each string array consists of four elements, in order:
“username”, “message”, “id”, and “timestamp”. These are unkeyed. For example:
[
["username0", "message0", "id0", "timestamp0"],
["username1", "message1", "id1", "timestamp1"],
...
]
Each element of the string array may have a value of JSONNull
.
Specifications
As in the previous tutorial, you only need to build one frontend, AND one of the alternative back-end stacks. Until you have a working backend of your own, you can use mada.eecs.umich.edu to test your front end. To receive full credit, your frontend MUST work with your own backend.
The main addition to the chatterd
backend is the use of PostgreSQL as permanent store and additional chatter
APIs to insert to and retrieve from the store.
Prepared by Sugih Jamin | Last updated: August 29th, 2025 |