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.
These are the other necessary repositories:
- https://github.com/technologiestiftung/idea-machine-frontend
- https://github.com/technologiestiftung/idea-machine-dice
If you want to run this yourself, you also need a supabase project (to store ideas) and an openai api key (to generate ideas).
If you are not in the project folder, cd into it and install dependencies:
cd idea-machine-backend && npm ci
Create a .env
file in the root of the project and add the needed variables:
cp .env.example .env
You can run the server with the following command:
npm run start
or the dev mode (watching the directory):
npm run dev
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:
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).
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>
Before you create a pull request, write an issue so we can discuss your changes.
Thanks goes to these wonderful people (emoji key):
Raphael.A 💻 👀 🤔 |
Dennis Ostendorf 💻 |
aeschi 💻 🎨 👀 🤔 |
This project follows the all-contributors specification. Contributions of any kind welcome!
Made by
|
A project by
|
Supported by
|
https://github.com/technologiestiftung/idea-machine-frontend