This document discusses the components used to build the Raspberry Pi Foundation Code Editor. It's a good starting point both for working on the editor itself and for using ideas or components from the editor in other projects.
The document assumes some familiarity with the app as a user. Try it out before reading further.
The editor API is a Rails monolith and is hosted at editor-api.raspberrypi.org
. Through the combination of a REST interface and a GraphQL API, it provides mechanisms for:
- Session management
- User auth (delegated to Raspberry Pi Accounts / Open ID Connect) and permissions (managed using the
cancancan
gem) - Persistence of projects, including code files, data, images and metadata.
Individual projects can be requested from /api/projects/{project_identifier}
and a list of a user's projects is available via the GraphQL API.
Project images are uploaded via POST
requests to /projects/{project_identfier}/images
and stored in an S3 bucket. However, the ability to upload images in the user interface is not currently enabled for safeguarding reasons.
A project remix is created via a POST
request to projects/{original_project_identifier}/remix
.
Currently requests to the API from a specific project page are generally performed via axios
, with AsyncThunk
s being used to manage the status of such requests and update the UI accordingly.
The My Projects page loads data and requests project renaming/deletion via GraphQL, with data stored in an Apollo cache. In the future, we aim to transition the whole app over to using the GraphQL/Apollo approach.
Copy the .env.example
file into a .env
file.
From the project directory build the app using docker:
docker-compose build
Set up the database:
docker compose run api rails db:setup
Start the application and its dependencies via docker:
docker-compose up
This can be done with the bin/with-builder.sh
script:
./bin/with-builder.sh bundle update
which should update the Gems in the container, without the need for rebuilding.
Add a comma separated list to the relevant enviroment settings. E.g for development in the .env
file:
ALLOWED_ORIGINS=localhost:3002,localhost:3000
This API receives push event data from the Raspberry Pi Learning organisation via webhooks. These webhooks are mediated locally through smee
, which runs in a Docker container. The webhook data is processed using the github_webhooks
gem in the github_webhooks_controller
.