Skip to content

Commit

Permalink
Merge pull request #52 from ebeeton/43-create-a-react-app-for-the-fro…
Browse files Browse the repository at this point in the history
…nt-end

Update README.md.
  • Loading branch information
ebeeton committed May 27, 2024
2 parents 6d06276 + 35e9814 commit 4ad07e0
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

[![Go](https://github.com/ebeeton/buddhabrot-go/actions/workflows/go.yml/badge.svg)](https://github.com/ebeeton/buddhabrot-go/actions/workflows/go.yml)

A Buddhabrot plotter written as a Go learning exercise.
A Buddhabrot plotter written as a Go, React, and TypeScript learning exercise.

![Buddhabrot image](/samples/sample.png)

This plot took about a minute on an eight-core machine using the parameters
below.
This plot took about a minute on an eight-core machine.

## Usage

Expand All @@ -18,16 +17,20 @@ repository called `.env` and set the contents to `DB_ROOT_PASSWORD=yourchoice`.

### Run It

In the same directory run `docker compose up --build`, which starts the API on
`http://localhost:3000`. After all the containers are running you can request a
plot.
In the same directory run `docker compose up`, which starts the web application
on [http://localhost:8000](http://localhost:8000).

### Request a Plot

The parameters used to plot the image are posted in JSON by clients
to '/api/plots', and the API records them in the database. The row ID and
parameters are returned with HTTP status 201. The ID will be used to obtain a
PNG image of the plot after it is complete. Because the plotting is CPU
The form on the left of the app defines the parameters that are used to plot an
image. The table on the right shows the plot history and links to images of
completed plots. Click the plot button to enqueue a plot.

## Under the Hood

The parameters used to plot the image are posted to an API running on port 3000,
and the API records them in the database. The row ID returned will be used to
obtain a PNG image of the plot after it is complete. Because the plotting is CPU
intensive, RabbitMQ is used to enqueue the plot request for a separate plotter
process so the API request doesn't block.

Expand Down Expand Up @@ -89,7 +92,7 @@ You will get a response similiar to this; note the `Id` property.

### Getting Images

Given the `Id` from the previous step, you can do a get to `/api/plots/25'`. If
Given the `Id` from the previous step, you can do a get to `/api/plots/25`. If
the plotter process has completed the plot, this will return a PNG image.
Otherwise 404 is returned until the plot is complete. To do this with curl:

Expand Down

0 comments on commit 4ad07e0

Please sign in to comment.