This repository contains a simple application which let you add messages to a graffiti board so that every one can see them.
The application is provided in two parts. First, the backend part, which provides an API and socket endpoint through which messages can be persisted and fetched. The second part consists of a frontend application which provides a simple UI and uses the backend to create and retrieve messages.
You can use the /messages
endpoint to fetch all messages or post a new messages.
The messages
endpoint is secured using Basic Auth
with username John
and password Doe
.
curl \
-H "Authorization: Basic Sm9objpEb2U=" \
-X GET http://localhost:8085/messages
curl \
-d '{"author":"John Doe", "message":"Hello World"}' \
-H "Content-Type: application/json" \
-H "Authorization: Basic Sm9objpEb2U=" \
-X POST http://localhost:8085/messages
There is also an endpoint where you can listen to new messages using Server Sent Events.
curl \
-H "Authorization: Basic Sm9objpEb2U=" \
-N http://localhost:8085/messages/subscribe
The frontend uses WebSockets to retrieve new messages in realtime. The endpoint is exposed at /message-socket
.
Navigate to service
folder first. You can then run the application using Gradle wrapper
# On Mac or Linux
./gradlew bootRun
# On Windows
./gradlew.bat bootRun
This will run the application at http://localhost:8085.
Navigate to ui
folder in order to use the following commands.
When you want to start it for the first time you need to install frontend dependencies first.
yarn
Afterwards you can run the app.
You can use the following command to run a local development server
yarn start
This will run the app in the development mode. Open http://localhost:3000 to view it in the browser.
A more detailed documentation about available scripts can be found here.