# jarrodfolinofc/examon-core architecture

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

- Interactive diagram: https://gitdiagram.com/jarrodfolinofc/examon-core
- Repository: https://github.com/jarrodfolinofc/examon-core

## Overview

##### Main Components

A. Core Framework Layer:
- ExamonItem Registry (Central coordination)
- ExamonSerializer (Data persistence)
- Question Models & Factories

B. Code Execution Layer:
- Sandbox Environment
- Restricted Python Driver
- Unrestricted Driver
- Print Collector

C. Question Types Layer:
- Multiple Choice Questions
- Code as String Questions
- Input Parameter Questions
- Free Text Questions

##### Component Relationships

**┌─────────────────────────────────────────────────────┐**
- Client Interface                   │
- ┘
- ↓
**┌─────────────────────────────────────────────────────┐**
- Examon Item Registry                  │
- (Central coordination and question management)     │
- ┘
- ↙               ↓              ↘
**┌──────────────┐    ┌─────────────┐    ┌─────────────┐**
- Question    │    │    Code     │    │  Question   │
- Factories   │    │  Execution  │    │   Models    │
- ┘    └─────────────┘    └─────────────┘
- ↙     ↘         ↙         ↘            ↓
**┌──────┐  ┌──────┐ ┌───────┐ ┌──────────┐ ┌─────────┐**
- MC   │  │Code  │ │Restr. │ │Unrestr.  │ │Question │
- Quest.│  │Quest.│ │Python │ │Execution │ │Response │
- ┘  └──────┘ └───────┘ └──────────┘ └─────────┘

##### Important Details

A. Security Boundaries:
- Sandbox environment
- Isolation between restricted and unrestricted execution

B. Data Flow:
- Question creation flow
- Code execution flow
- Result collection and validation

##### Additional Architectural Notes

- Factory Pattern Implementation: Show how different question types are created
- Serialization Layer: Include how questions are stored/retrieved
- Code Metrics: Show how difficulty calculations are integrated

##### Implementation Details to Emphasize

- The separation between question types and their factories
- The isolation of code execution environments
- The central role of the ExamonItemRegistry
- The extensibility points for new question types

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Interface"]
        CI[Client API]
    end

    subgraph Core["Core Framework Layer"]
        Registry["ExamonItem Registry"]:::core
        Serializer["ExamonSerializer"]:::core
        QModels["Question Models"]:::core
        QResponse["Question Response"]:::core
        CodeMetrics["Code Metrics"]:::core
    end

    subgraph Execution["Code Execution Layer"]
        Sandbox["Sandbox Environment"]:::execution
        RPython["Restricted Python Driver"]:::execution
        UPython["Unrestricted Driver"]:::execution
        PrintCol["Print Collector"]:::execution
    end

    subgraph Factories["Question Factory Layer"]
        BaseFactory["Base Question Factory"]:::factory
        MCFactory["Multi Choice Factory"]:::factory
        CodeStrFactory["Code as String Factory"]:::factory
        InputParamFactory["Input Parameter Factory"]:::factory
    end

    %% Relationships
    CI --> Registry
    Registry --> Serializer
    Registry --> QModels
    Registry --> BaseFactory
    
    BaseFactory --> MCFactory
    BaseFactory --> CodeStrFactory
    BaseFactory --> InputParamFactory
    
    MCFactory --> QModels
    CodeStrFactory --> QModels
    InputParamFactory --> QModels
    
    QModels --> QResponse
    QModels --> CodeMetrics
    
    CodeStrFactory --> Sandbox
    InputParamFactory --> Sandbox
    
    Sandbox --> RPython
    Sandbox --> UPython
    RPython --> PrintCol
    UPython --> PrintCol

    %% Click Events
    click Registry "https://github.com/JarrodFolinoFC/examon-core/blob/main/examon_core/examon_item_registry.py"
    click Serializer "https://github.com/JarrodFolinoFC/examon-core/blob/main/examon_core/examon_serializer.py"
    click QModels "https://github.com/JarrodFolinoFC/examon-core/blob/main/examon_core/models/question.py"
    click QResponse "https://github.com/JarrodFolinoFC/examon-core/blob/main/examon_core/models/question_response.py"
    click BaseFactory "https://github.com/JarrodFolinoFC/examon-core/blob/main/examon_core/models/factories/base_question_factory.py"
    click Sandbox "https://github.com/JarrodFolinoFC/examon-core/blob/main/examon_core/code_execution/sandbox.py"
    click RPython "https://github.com/JarrodFolinoFC/examon-core/blob/main/examon_core/code_execution/restricted_python_driver.py"
    click UPython "https://github.com/JarrodFolinoFC/examon-core/blob/main/examon_core/code_execution/unrestricted_driver.py"
    click PrintCol "https://github.com/JarrodFolinoFC/examon-core/blob/main/examon_core/code_execution/print_collector.py"
    click MCFactory "https://github.com/JarrodFolinoFC/examon-core/blob/main/examon_core/models/factories/multi_choice_factory.py"
    click CodeStrFactory "https://github.com/JarrodFolinoFC/examon-core/blob/main/examon_core/models/factories/code_as_string_factory.py"
    click InputParamFactory "https://github.com/JarrodFolinoFC/examon-core/blob/main/examon_core/models/factories/input_param_question_factory.py"
    click CodeMetrics "https://github.com/JarrodFolinoFC/examon-core/blob/main/examon_core/models/code_metrics.py"

    %% Styling
    classDef core fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef execution fill:#b7e3c0,stroke:#333,stroke-width:2px
    classDef factory fill:#ffd7a8,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Execution Components]:::execution
        L3[Factory Components]:::factory
    end
```
