Name this Cat

The honor of naming this cat has been bestowed upon you. What would you call this cat? (it is gender-fluid). It is also looking for a job - can you suggest an occupation?


Previous entries:
Nothing to display


About this Page

The purpose of this simple page is to demonstrate its backend architecture. The frontend uses javascript async/await functions to make requests of a custom REST API program that I built. The program was made in Java using Spring Boot, with separate Controller, Service, Entity, Repository and Payload classes. The finished program was then containerized with Docker and deployed as a service on Google Cloudrun. The REST API program connects to an SQL server which runs on Google Cloud SQL to store the cat names and occupations list.

See the Java code on GitHub

The Java REST API receives GET and POST requests at the root endpoint. To retrieve a list of all of the records stored in the database, a GET request is made. It is not necessary to include anything in the body of the GET request. Functionality to retrieve a single record by ID was not implemented as it is unnecessary for this demonstration.

To enter a new record in the database, a POST request is made including a body object (JSON formatted) containing the key-value pairs of "name" and "occupation". An id is automatically assigned to the record by the Spring Boot program because of the annotation "@GeneratedValue(strategy = GenerationType.IDENTITY)" included in the CatnamesEntity.

Example request body for POST:

To delete a record, a DELETE request is made to the endpoint with "/{id}" appended. The API controller DELETE method calls the DELETE service method and passes it the record id for deletion.

Because the API is hosted at a different domain than the frontend page, it was necessary to deal with CORS rules. The annotation @CrossOrigin(origins = "https://nickroach.github.io/", maxAge = 3600) was included in the CatnamesController to take care of this. The API will only fulfill requests made by browsers running javascript programs running at that domain.