# raspberrypifoundation/editor-api architecture

> Architecture diagram of the GitHub repository raspberrypifoundation/editor-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/raspberrypifoundation/editor-api
- Repository: https://github.com/raspberrypifoundation/editor-api
- Video tour (about a minute): https://gitdiagram.com/raspberrypifoundation/editor-api/video

## Overview

This Rails monolith exposes project and curriculum-management APIs for the Raspberry Pi Code Editor. Users and service clients enter through REST or GraphQL; project operations support persistence, remixing, images, and Scratch assets, while education workflows manage schools, classes, lessons, teachers, and students. Authentication and authorization underpin these interfaces. The README also documents asynchronous curriculum synchronization and GitHub webhook imports. The graph reflects documented capabilities and sampled controller behavior; unsampled controller wiring is intentionally not inferred.

Main entry points: [`app/controllers/api/projects_controller.rb`](https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/projects_controller.rb) (Project endpoints), [`app/controllers/api/school_classes_controller.rb`](https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/school_classes_controller.rb) (Class endpoints), [`app/controllers/api`](https://github.com/raspberrypifoundation/editor-api/tree/main/app/controllers/api) (REST API), [`app/controllers/graphql_controller.rb`](https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/graphql_controller.rb) (GraphQL API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["API interfaces"]
  node_rest["REST API"]
  node_graphql["GraphQL API"]
  node_schema["Editor schema"]
end

subgraph group_projects["Projects and assets"]
  node_project_api["Project endpoints"]
  node_project_ops["Project operations"]
  node_project_store[("Project records<br/>[project.rb]")]
  node_images["Project images"]
  node_scratch["Scratch projects"]
  node_scratch_assets["Scratch assets"]
  node_asset_store[("Asset storage<br/>[scratch_asset.rb]")]
end

subgraph group_education["Education management"]
  node_schools["School endpoints"]
  node_classes["Class endpoints"]
  node_class_ops["Class operations"]
  node_students["Student management"]
  node_lessons["Lesson management"]
  node_education_ops["Education operations"]
  node_school_store[("School records<br/>[school.rb]")]
end

subgraph group_identity["Identity and access"]
  node_auth["Login and sessions<br/>[auth_controller.rb]"]
  node_permissions["Authorization<br/>[ability.rb]"]
  node_profile["Profile identity"]
end

subgraph group_integrations["External integrations"]
  node_profile_service["Raspberry Pi Accounts"]
  node_experience["Experience CS sync"]
  node_github["GitHub webhook"]
  node_upload["Curriculum upload job<br/>[upload_job.rb]"]
  node_github_service["GitHub"]
end

node_user(("Editor user"))
node_service(("Service client"))

node_user -->|"calls REST"| node_rest
node_service -->|"calls REST"| node_rest
node_user -->|"calls GraphQL"| node_graphql
node_graphql -->|"executes schema"| node_schema
node_user -->|"signs in"| node_auth
node_auth -->|"authenticates"| node_profile
node_profile -->|"requests identity"| node_profile_service
node_rest -->|"checks access"| node_permissions
node_graphql -.->|"checks access"| node_permissions
node_rest -->|"dispatches project requests"| node_project_api
node_project_api -.->|"runs operations"| node_project_ops
node_project_api -.->|"reads and writes"| node_project_store
node_project_api -->|"serves image routes"| node_images
node_project_api -->|"serves Scratch routes"| node_scratch
node_scratch -->|"serves asset routes"| node_scratch_assets
node_scratch_assets -->|"reads and writes"| node_asset_store
node_service -->|"migrates projects"| node_experience
node_experience -.->|"updates projects"| node_project_store
node_user -->|"manages schools"| node_schools
node_user -->|"manages classes"| node_classes
node_classes -->|"calls operations"| node_class_ops
node_classes -->|"creates students"| node_education_ops
node_user -->|"manages students"| node_students
node_user -->|"manages lessons"| node_lessons
node_schools -.->|"reads and writes"| node_school_store
node_classes -.->|"reads and writes"| node_school_store
node_github_service -->|"sends push event"| node_github
node_github -->|"schedules job"| node_upload

click node_rest "https://github.com/raspberrypifoundation/editor-api/tree/main/app/controllers/api"
click node_graphql "https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/graphql_controller.rb"
click node_schema "https://github.com/raspberrypifoundation/editor-api/blob/main/app/graphql/editor_api_schema.rb"
click node_auth "https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/auth_controller.rb"
click node_permissions "https://github.com/raspberrypifoundation/editor-api/blob/main/app/models/ability.rb"
click node_project_api "https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/projects_controller.rb"
click node_project_ops "https://github.com/raspberrypifoundation/editor-api/tree/main/lib/concepts/project/operations"
click node_project_store "https://github.com/raspberrypifoundation/editor-api/blob/main/app/models/project.rb"
click node_images "https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/projects/images_controller.rb"
click node_scratch "https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/scratch/projects_controller.rb"
click node_scratch_assets "https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/scratch/assets_controller.rb"
click node_asset_store "https://github.com/raspberrypifoundation/editor-api/blob/main/app/models/scratch_asset.rb"
click node_schools "https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/schools_controller.rb"
click node_classes "https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/school_classes_controller.rb"
click node_class_ops "https://github.com/raspberrypifoundation/editor-api/tree/main/lib/concepts/school_class/operations"
click node_students "https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/school_students_controller.rb"
click node_lessons "https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/lessons_controller.rb"
click node_education_ops "https://github.com/raspberrypifoundation/editor-api/tree/main/lib/concepts"
click node_school_store "https://github.com/raspberrypifoundation/editor-api/blob/main/app/models/school.rb"
click node_profile "https://github.com/raspberrypifoundation/editor-api/blob/main/lib/profile_api_client.rb"
click node_experience "https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/experience_cs_project_migrations_controller.rb"
click node_github "https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/github_webhooks_controller.rb"
click node_upload "https://github.com/raspberrypifoundation/editor-api/blob/main/app/jobs/upload_job.rb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_rest,node_graphql,node_schema,node_user,node_service toneBlue
class node_project_api,node_project_ops,node_project_store,node_images,node_scratch,node_scratch_assets,node_asset_store toneAmber
class node_schools,node_classes,node_class_ops,node_students,node_lessons,node_education_ops,node_school_store toneMint
class node_auth,node_permissions,node_profile toneRose
class node_profile_service,node_experience,node_github,node_upload,node_github_service toneIndigo
```

## Components

### API interfaces

- [REST API](https://github.com/raspberrypifoundation/editor-api/tree/main/app/controllers/api): `app/controllers/api`
- [GraphQL API](https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/graphql_controller.rb): `app/controllers/graphql_controller.rb`
- [Editor schema](https://github.com/raspberrypifoundation/editor-api/blob/main/app/graphql/editor_api_schema.rb): `app/graphql/editor_api_schema.rb`

### Projects and assets

- [Project endpoints](https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/projects_controller.rb): `app/controllers/api/projects_controller.rb`
- [Project operations](https://github.com/raspberrypifoundation/editor-api/tree/main/lib/concepts/project/operations): `lib/concepts/project/operations`
- [Project records](https://github.com/raspberrypifoundation/editor-api/blob/main/app/models/project.rb): `app/models/project.rb`
- [Project images](https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/projects/images_controller.rb): `app/controllers/api/projects/images_controller.rb`
- [Scratch projects](https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/scratch/projects_controller.rb): `app/controllers/api/scratch/projects_controller.rb`
- [Scratch assets](https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/scratch/assets_controller.rb): `app/controllers/api/scratch/assets_controller.rb`
- [Asset storage](https://github.com/raspberrypifoundation/editor-api/blob/main/app/models/scratch_asset.rb): `app/models/scratch_asset.rb`

### Education management

- [School endpoints](https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/schools_controller.rb): `app/controllers/api/schools_controller.rb`
- [Class endpoints](https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/school_classes_controller.rb): `app/controllers/api/school_classes_controller.rb`
- [Class operations](https://github.com/raspberrypifoundation/editor-api/tree/main/lib/concepts/school_class/operations): `lib/concepts/school_class/operations`
- [Student management](https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/school_students_controller.rb): `app/controllers/api/school_students_controller.rb`
- [Lesson management](https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/lessons_controller.rb): `app/controllers/api/lessons_controller.rb`
- [Education operations](https://github.com/raspberrypifoundation/editor-api/tree/main/lib/concepts): `lib/concepts`
- [School records](https://github.com/raspberrypifoundation/editor-api/blob/main/app/models/school.rb): `app/models/school.rb`

### Identity and access

- [Login and sessions](https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/auth_controller.rb): `app/controllers/auth_controller.rb`
- [Authorization](https://github.com/raspberrypifoundation/editor-api/blob/main/app/models/ability.rb): `app/models/ability.rb`
- [Profile identity](https://github.com/raspberrypifoundation/editor-api/blob/main/lib/profile_api_client.rb): `lib/profile_api_client.rb`

### External integrations

- **Raspberry Pi Accounts**
- [Experience CS sync](https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/api/experience_cs_project_migrations_controller.rb): `app/controllers/api/experience_cs_project_migrations_controller.rb`
- [GitHub webhook](https://github.com/raspberrypifoundation/editor-api/blob/main/app/controllers/github_webhooks_controller.rb): `app/controllers/github_webhooks_controller.rb`
- [Curriculum upload job](https://github.com/raspberrypifoundation/editor-api/blob/main/app/jobs/upload_job.rb): `app/jobs/upload_job.rb`
- **GitHub**

### Other components

- **Editor user**
- **Service client**

## Connections

- Editor user → REST API: calls REST
- Service client → REST API: calls REST
- Editor user → GraphQL API: calls GraphQL
- GraphQL API → Editor schema: executes schema
- Editor user → Login and sessions: signs in
- Login and sessions → Profile identity: authenticates
- Profile identity → Raspberry Pi Accounts: requests identity
- REST API → Authorization: checks access
- GraphQL API → Authorization: checks access
- REST API → Project endpoints: dispatches project requests
- Project endpoints → Project operations: runs operations
- Project endpoints → Project records: reads and writes
- Project endpoints → Project images: serves image routes
- Project endpoints → Scratch projects: serves Scratch routes
- Scratch projects → Scratch assets: serves asset routes
- Scratch assets → Asset storage: reads and writes
- Service client → Experience CS sync: migrates projects
- Experience CS sync → Project records: updates projects
- Editor user → School endpoints: manages schools
- Editor user → Class endpoints: manages classes
- Class endpoints → Class operations: calls operations
- Class endpoints → Education operations: creates students
- Editor user → Student management: manages students
- Editor user → Lesson management: manages lessons
- School endpoints → School records: reads and writes
- Class endpoints → School records: reads and writes
- GitHub → GitHub webhook: sends push event
- GitHub webhook → Curriculum upload job: schedules job
