Skip to content

Latest commit

 

History

History
156 lines (117 loc) · 5.98 KB

README.md

File metadata and controls

156 lines (117 loc) · 5.98 KB

All Contributors

Idea Machine Backend

This code is meant to run a http server locally on a raspberry pi to orchestrate print requests coming from the idea-machine webapp (see here), handle bluetooth connections to the dices, administrate the labels of the dices, read the buzzer input and (pre-) generate ideas.

Prerequisites

These are the other necessary repositories:

If you want to run this yourself, you also need a supabase project (to store ideas) and an openai api key (to generate ideas).

Install npm dependencies

If you are not in the project folder, cd into it and install dependencies:

cd idea-machine-backend && npm ci

Add the .env file

Create a .env file in the root of the project and add the needed variables:

cp .env.example .env

Run it

You can run the server with the following command:

npm run start

or the dev mode (watching the directory):

npm run dev

Architecture / Flow

The server uses multiple technologies to handle the different tasks:

  • Bluetooth to connect to the dices and receive side change events
  • GPIO to read the buzzer input
  • A REST API to:
    • handle read/update dice labels,
    • live generate ideas,
    • pregenerate ideas,
    • pick an idea from pregenerated ideas
    • regenerate pdfs (in case of design changes)
    • shutdown
    • is alive check
  • WebSockets to update the connection status to the dice administration website, and listen for new printing jobs in the DB

The main flow can be visually represented as follows:

architecture-flow.png

How are the ideas generated?

The ideas are generated using gpt-4o and dall-e 3. A prompt is sent to the gpt-4o model, and the output is sent to the dall-e model to generate an image. The idea text and idea image are then used to generate an HTML (postcard), which is then converted to a PDF (postcard).

How do you connect to dices via bluetooth?

You first need to pair the dices with the raspberry pi. You can do this by running the following command:

bluetoothctl

Then, in the bluetoothctl console, run the following commands:

scan on

You should see the dices in the list of devices. Then, pair the dice with the following command:

pair <MAC_ADDRESS_OF_DICE>

Contributing

Before you create a pull request, write an issue so we can discuss your changes.

Contributors

Thanks goes to these wonderful people (emoji key):

Raphael.A
Raphael.A

💻 👀 🤔
Dennis Ostendorf
Dennis Ostendorf

💻
aeschi
aeschi

💻 🎨 👀 🤔

This project follows the all-contributors specification. Contributions of any kind welcome!

Credits

Made by

Link to CityLAB Berlin website
A project by

Link to Technologiestiftung Berlin website
Supported by

Link to Senatskanzlei Berlin website

Related Projects

https://github.com/technologiestiftung/idea-machine-frontend

https://github.com/technologiestiftung/idea-machine-dice