# learningequality/studio architecture

> Architecture diagram of the GitHub repository learningequality/studio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/learningequality/studio
- Repository: https://github.com/learningequality/studio

## Overview

- Asynchronous Task Processor: Note the “celery.py” file and associated Celery tasks, which indicate background processing (for tasks like publishing channels, importing resources, and garbage collection). Represent this as a background worker system.
- External Integrations: Include integration points with external services:
– Kolibri: since Studio publishes content channels to Kolibri.
– Ricecooker: for programmatically uploading new content with ricecooker-powered scripts.
– Docker/Kubernetes: Represent the containerization layer (directories like .docker, docker/, k8s/) that support deployment.
- Testing & DevOps: Optionally show separate pipelines for frontend tests (Vue.js) and backend tests (Python), as well as CI workflows (see the .github/workflows folder) that run linting, testing, and deployment.

##### Relationships and Data Flows
- Backend to the Database to indicate CRUD operations on models and migrations.
- Asynchronous communication between the Backend and the Celery worker (which processes long-running or periodic tasks, such as content publishing and background syncs).
- Deployment/DevOps paths that use Docker, Kubernetes, and CI/CD workflows.

##### Architectural Patterns & Design Principles
- MVC and REST API Architecture: Point out that Django is organized following MVC (or MTV in Django parlance) with views, templates, and models.
- Modularization: Divide the frontend into separate Vue modules (accounts, channelEdit, channelList, settings, etc.) and the backend into distinct apps (for content curation, automation, management, etc.).
- Containerization & Orchestration: Highlight the Docker files and Kubernetes YAML files which show how the system is containerized, deployed, and scaled in different environments.

##### Final Assembly
- Under the backend, split into subcomponents (business logic, asynchronous task processing, database interaction, and external integrations).
- Optionally, annotate horizontal layers to differentiate between presentation, application logic, data persistence, and infrastructure.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Entry Point
    U["User [Web Browser]"]:::user

    %% Frontend Layer
    subgraph "Frontend (Vue.js Client)"
        FE["Vue.js Client"]:::frontend
        FE_ACCOUNTS["Accounts"]:::frontend
        FE_ADMIN["Administration"]:::frontend
        FE_CHANNEL_EDIT["Channel Edit"]:::frontend
        FE_CHANNEL_LIST["Channel List"]:::frontend
        FE_SETTINGS["Settings"]:::frontend
        FE_SHARED["Shared Components"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Django)"
        API["Django REST API"]:::backend
        subgraph "Backend Modules"
            API_MODULE["API (api.py)"]:::backendChild
            MIDDLEWARE["Middleware"]:::backendChild
            MGMT["Management Commands"]:::backendChild
            SERIALIZERS["Serializers (serializers.py)"]:::backendChild
            VIEWSETS["ViewSets"]:::backendChild
            MODELS["Models (models.py)"]:::backendChild
            MIGRATIONS["Migrations"]:::backendChild
        end
    end

    %% Asynchronous Processing
    subgraph "Asynchronous Processing"
        CELERY["Celery Worker (Background Tasks)"]:::celery
    end

    %% Persistence Layer
    DB["PostgreSQL Database"]:::database

    %% External Integrations
    subgraph "External Integrations"
        KC["Kolibri Content"]:::integration
        KP["Kolibri Public"]:::integration
        RICE["Ricecooker Integration"]:::integration
    end

    %% Containerization & Deployment
    subgraph "Containerization & Deployment"
        DOCKER["Docker Files"]:::deployment
        K8S["Kubernetes Artifacts"]:::deployment
    end

    %% Testing & DevOps
    subgraph "Testing & DevOps"
        CICD["CI/CD Pipeline"]:::devops
        INTTEST["Integration Testing"]:::devops
        JEST["Jest Config"]:::devops
    end

    %% Connections
    U -->|"UserAction"| FE
    FE -->|"API_Call"| API

    API -->|"DataPersistence"| DB
    API -->|"TaskQueue"| CELERY
    API -->|"Publish"| KC
    API -->|"Publish"| KP
    API -->|"Import"| RICE

    %% Deployment connections (dotted lines for infrastructure support)
    DOCKER ---|"Deploys"| FE
    DOCKER ---|"Deploys"| API
    K8S ---|"Orchestrates"| FE
    K8S ---|"Orchestrates"| API

    %% Testing connections (dotted lines for CI/CD pipelines)
    CICD ---|"Tests"| FE
    CICD ---|"Tests"| API
    INTTEST ---|"Tests"| API
    JEST ---|"Tests"| FE

    %% Optional: Link Frontend submodules (for clarity they are part of the frontend)
    FE --> FE_ACCOUNTS
    FE --> FE_ADMIN
    FE --> FE_CHANNEL_EDIT
    FE --> FE_CHANNEL_LIST
    FE --> FE_SETTINGS
    FE --> FE_SHARED

    %% Backend internal module connections (to indicate composition)
    API --- API_MODULE
    API --- MIDDLEWARE
    API --- MGMT
    API --- SERIALIZERS
    API --- VIEWSETS
    API --- MODELS
    API --- MIGRATIONS

    %% Styles
    classDef user fill:#FDEBD0,stroke:#E67E22,stroke-width:2px;
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef backendChild fill:#D5F5E3,stroke:#239B56,stroke-width:1px;
    classDef database fill:#F9E79F,stroke:#7D6608,stroke-width:2px;
    classDef celery fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef integration fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;
    classDef deployment fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
    classDef devops fill:#D6EAF8,stroke:#2E86C1,stroke-width:2px;

    %% Click Events for Frontend Submodules
    click FE "https://github.com/learningequality/studio/tree/unstable/contentcuration/contentcuration/frontend"
    click FE_ACCOUNTS "https://github.com/learningequality/studio/tree/unstable/contentcuration/contentcuration/frontend/accounts"
    click FE_ADMIN "https://github.com/learningequality/studio/tree/unstable/contentcuration/contentcuration/frontend/administration"
    click FE_CHANNEL_EDIT "https://github.com/learningequality/studio/tree/unstable/contentcuration/contentcuration/frontend/channelEdit"
    click FE_CHANNEL_LIST "https://github.com/learningequality/studio/tree/unstable/contentcuration/contentcuration/frontend/channelList"
    click FE_SETTINGS "https://github.com/learningequality/studio/tree/unstable/contentcuration/contentcuration/frontend/settings"
    click FE_SHARED "https://github.com/learningequality/studio/tree/unstable/contentcuration/contentcuration/frontend/shared"

    %% Click Events for Backend and its Modules
    click API "https://github.com/learningequality/studio/tree/unstable/contentcuration/contentcuration"
    click API_MODULE "https://github.com/learningequality/studio/blob/unstable/contentcuration/contentcuration/api.py"
    click MIDDLEWARE "https://github.com/learningequality/studio/tree/unstable/contentcuration/contentcuration/middleware"
    click MGMT "https://github.com/learningequality/studio/tree/unstable/contentcuration/contentcuration/management/commands"
    click SERIALIZERS "https://github.com/learningequality/studio/blob/unstable/contentcuration/contentcuration/serializers.py"
    click VIEWSETS "https://github.com/learningequality/studio/tree/unstable/contentcuration/contentcuration/viewsets"
    click MODELS "https://github.com/learningequality/studio/blob/unstable/contentcuration/contentcuration/models.py"
    click MIGRATIONS "https://github.com/learningequality/studio/tree/unstable/contentcuration/contentcuration/migrations"

    %% Click Event for Celery Worker
    click CELERY "https://github.com/learningequality/studio/blob/unstable/contentcuration/contentcuration/celery.py"

    %% Click Events for External Integrations
    click KC "https://github.com/learningequality/studio/tree/unstable/contentcuration/kolibri_content"
    click KP "https://github.com/learningequality/studio/tree/unstable/contentcuration/kolibri_public"
    click RICE "https://github.com/learningequality/studio/blob/unstable/contentcuration/contentcuration/ricecooker_versions.py"

    %% Click Events for Containerization & Deployment
    click DOCKER "https://github.com/learningequality/studio/blob/unstable/.docker"
    click K8S "https://github.com/learningequality/studio/tree/unstable/k8s"

    %% Click Events for Testing & DevOps
    click CICD "https://github.com/learningequality/studio/tree/unstable/.github/workflows"
    click INTTEST "https://github.com/learningequality/studio/tree/unstable/integration_testing"
    click JEST "https://github.com/learningequality/studio/tree/unstable/jest_config"
```
