# markusproject/markus architecture

> Architecture diagram of the GitHub repository markusproject/markus, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/markusproject/markus
- Repository: https://github.com/markusproject/markus

## Overview

##### Main Components

a. Client-Side Layer:
- React components (in app/javascript/Components/)
- JavaScript assets (in app/assets/javascripts/)
- Stylesheets (in app/assets/stylesheets/)

b. Server-Side Layer:
- Rails application (MVC architecture)
- API controllers (in app/controllers/api/)
- WebSocket channels (in app/channels/)
- Background jobs (in app/jobs/)

c. Data Storage Layer:
- PostgreSQL database (indicated by database.yml.postgresql)
- Git repositories for student submissions
- File storage for uploads

d. External Services:
- LTI integration (Learning Tools Interoperability)
- Autotest system
- PDF processing system

##### Architecture Patterns to Highlight

a. Core Application Structure:
**[Client Browser] <--> [Nginx/Apache] <--> [Rails App Server]**

- [Background Jobs] <--> [Redis]

- [PostgreSQL] <--> [Git Storage]

b. Key Interactions:
- Grading workflow
- Authentication paths
- Real-time updates via WebSocket

##### Specific Implementation Details

a. Authentication & Authorization:
- Policy layer (app/policies/)
- LTI authentication flow
- Role-based access control

b. File Processing:
- Git repository management
- PDF annotation system
- Jupyter notebook handling

c. Assessment Workflow:
- Assignment submission
- Automated testing
- Manual grading
- Feedback delivery

##### Important Subsystems

a. Annotation System:
- Text annotations
- PDF annotations
- Image annotations
- HTML annotations

b. Testing Framework:
- Test runners
- Result processing
- Feedback generation

c. Management:
- Formation
- Member management
- Permission handling

##### Integration Points

a. External Tools:
- LTI integration
- Git interfaces
- Automated testing services

b. Internal Services:
- Background job processing
- WebSocket communication
- File storage management

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        Browser["Web Browser"]
        ReactComp["React Components"]:::frontend
        JSAssets["JavaScript Assets"]:::frontend
        Styles["Stylesheets"]:::frontend
        PDFViewer["PDF Viewer"]:::frontend
    end

    subgraph Server["Server Layer"]
        Rails["Rails Application"]
        APICtrl["API Controllers"]:::backend
        WSChannels["WebSocket Channels"]:::backend
        BGJobs["Background Jobs"]:::backend
        GitLib["Git Repository Manager"]:::backend
        LTICtrl["LTI Controller"]:::backend
        AnnoCtrl["Annotation Controller"]:::backend
        TestCtrl["Automated Tests Controller"]:::backend
        GroupCtrl["Group Controller"]:::backend
    end

    subgraph Storage["Data Storage Layer"]
        DB[(PostgreSQL)]:::storage
        GitStorage["Git Repositories"]:::storage
        FileStore["File Storage"]:::storage
        Redis[(Redis)]:::cache
    end

    subgraph External["External Services"]
        LTI["LTI Integration"]:::external
        AutoTest["Autotest System"]:::external
        PDFProc["PDF Processing"]:::external
    end

    Browser --> ReactComp
    Browser --> JSAssets
    Browser --> Styles
    Browser --> PDFViewer

    ReactComp --> APICtrl
    ReactComp --> WSChannels
    WSChannels --> Redis
    BGJobs --> Redis

    Rails --> DB
    Rails --> GitStorage
    Rails --> FileStore
    
    GitLib --> GitStorage
    
    LTICtrl --> LTI
    TestCtrl --> AutoTest
    PDFViewer --> PDFProc

    AnnoCtrl --> DB
    TestCtrl --> DB
    GroupCtrl --> DB

    %% Click Events
    click ReactComp "https://github.com/MarkusProject/markus/tree/master/app/javascript/Components/"
    click JSAssets "https://github.com/MarkusProject/markus/tree/master/app/assets/javascripts/"
    click Styles "https://github.com/MarkusProject/markus/tree/master/app/assets/stylesheets/"
    click APICtrl "https://github.com/MarkusProject/markus/tree/master/app/controllers/api/"
    click WSChannels "https://github.com/MarkusProject/markus/tree/master/app/channels/"
    click BGJobs "https://github.com/MarkusProject/markus/tree/master/app/jobs/"
    click DB "https://github.com/MarkusProject/markus/blob/master/.dockerfiles/database.yml.postgresql"
    click LTICtrl "https://github.com/MarkusProject/markus/blob/master/app/controllers/lti_deployments_controller.rb"
    click AnnoCtrl "https://github.com/MarkusProject/markus/blob/master/app/controllers/annotations_controller.rb"
    click TestCtrl "https://github.com/MarkusProject/markus/blob/master/app/controllers/automated_tests_controller.rb"
    click GroupCtrl "https://github.com/MarkusProject/markus/blob/master/app/controllers/groups_controller.rb"
    click PDFViewer "https://github.com/MarkusProject/markus/blob/master/app/javascript/Components/Result/pdf_viewer.jsx"
    click GitLib "https://github.com/MarkusProject/markus/blob/master/app/lib/git_repository.rb"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef storage fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#e67e22,stroke:#d35400,color:white
    classDef cache fill:#9b59b6,stroke:#8e44ad,color:white

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Component"]:::backend
        DataStore["Data Storage"]:::storage
        ExtService["External Service"]:::external
        CacheLayer["Cache Layer"]:::cache
    end
```
