# ruyili/blockoj architecture

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

- Interactive diagram: https://gitdiagram.com/ruyili/blockoj
- Repository: https://github.com/ruyili/blockoj

## Overview

##### Main Components

a. Frontend Layer:
- Blockly Editor (core component)
- User Interface (Pug templates)
- Style Components (SASS/CSS)
- Client-side JavaScript modules

b. Backend Layer:
- Express.js Server
- Authentication System
- Problem Management
- Judging System (C-based)
- Database Interface

c. Database Layer:
- PostgreSQL Database

d. External Services:
- AWS EC2 (hosting)

##### Component Relationships

- Client ↔ Server (HTTP/WebSocket)
- Server ↔ Judge System
- Server ↔ Database
- Judge System ↔ Test Cases

##### Detailed Component Breakdown

- Blockly Editor Interface
- Problem View
- User Authentication Views
- Code Submission Interface
- Notification System

- Auth Controller (/src/server/auth.js)
- Problem Reader (/src/server/problem-reader.js)
- Compilation Service (/src/server/compile.js)
- Judge System (/src/server/judging)
- Database Manager (/src/server/database.js)

- PostgreSQL Database
- Problem Test Cases
- User Solutions
- Temporary Compilation Files

##### Additional Details

Notes for:
- Scalability considerations
- Security measures
- Error handling flow
- Test case isolation

##### The submission and evaluation pipeline

- Rectangles: Core services
- Hexagons: External services
- Rounded rectangles: User interfaces
- Diamonds: Decision points

- Blue: User-facing components
- Green: Processing components
- Yellow: Storage components
- Red: Security components
- Gray: External services

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#dae8fc,stroke:#6c8ebf
    classDef backend fill:#d5e8d4,stroke:#82b366
    classDef storage fill:#fff2cc,stroke:#d6b656
    classDef security fill:#f8cecc,stroke:#b85450
    classDef external fill:#e6e6e6,stroke:#666666

    %% Frontend Layer
    subgraph Frontend
        UI[User Interface]:::frontend
        BE["Blockly Editor"]:::frontend
        CS["Client Scripts"]:::frontend
        ST["Styles"]:::frontend
    end

    %% Backend Layer
    subgraph Server
        EX["Express Server"]:::backend
        AS["Auth System"]:::backend
        PM["Problem Manager"]:::backend
        CS_["Compilation Service"]:::backend
        JS["Judge System"]:::backend
        DI["Database Interface"]:::backend
    end

    %% Storage Layer
    subgraph Storage
        DB[(PostgreSQL)]:::storage
        TC[("Test Cases")]:::storage
        PS[("Problem Storage")]:::storage
        TF[("Temp Files")]:::storage
    end

    %% External Services
    AWS["AWS EC2"]:::external

    %% Relationships
    UI --> EX
    BE --> EX
    CS --> EX
    EX --> AS
    EX --> PM
    EX --> CS_
    CS_ --> JS
    JS --> TC
    PM --> PS
    EX --> DI
    DI --> DB
    EX --> AWS

    %% Click Events
    click BE "https://github.com/ruyili/blockoj/blob/master/public/js/blockly-loader.js"
    click UI "https://github.com/ruyili/blockoj/tree/master/src/views/"
    click ST "https://github.com/ruyili/blockoj/tree/master/src/style/"
    click AS "https://github.com/ruyili/blockoj/blob/master/src/server/auth.js"
    click PM "https://github.com/ruyili/blockoj/blob/master/src/server/problem-reader.js"
    click JS "https://github.com/ruyili/blockoj/blob/master/src/server/judging/judge.c"
    click DI "https://github.com/ruyili/blockoj/blob/master/src/server/database.js"
    click EX "https://github.com/ruyili/blockoj/blob/master/src/server/server.js"
    click PS "https://github.com/ruyili/blockoj/tree/master/src/problems/"
    click CS "https://github.com/ruyili/blockoj/blob/master/public/js/component-loader.js"
    click CS_ "https://github.com/ruyili/blockoj/blob/master/src/server/compile.js"
    click TF "https://github.com/ruyili/blockoj/tree/master/src/server/judging/temp/"
    click TC "https://github.com/ruyili/blockoj/tree/master/src/server/judging/test/"

    %% Legend
    subgraph Legend
        F["Frontend Component"]:::frontend
        B["Backend Component"]:::backend
        S["Storage Component"]:::storage
        E["External Service"]:::external
    end
```
