# pablousky4/scheduler architecture

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

- Interactive diagram: https://gitdiagram.com/pablousky4/scheduler
- Repository: https://github.com/pablousky4/scheduler

## Overview

##### Project type and purpose
- This is a CLI‐driven simulation tool (“Scheduler”) that models process scheduling in an OS using FCFS (First‐Come‐First‐Serve) and Round‐Robin algorithms.
- It is not a multi‐tier web app or distributed microservice: it’s a single‐executable package with core scheduling logic, process abstractions, metrics calculation, and a simple CLI front end.

##### File structure
- Top-level:
- main.py (entry point / CLI)
- requirements.txt (dependencies)
- src/ (core logic)
– proceso.py (Process data model)
– repositorio.py (in‐memory or persisted process repository)
– scheduler.py (scheduling algorithms orchestrator)
– metrics.py (collects and computes run‐time statistics)
– __init__.py
- tests/ (pytest suite mirroring src modules)
- The structure implies a layered design:
- CLI layer invokes the scheduling engine
- Engine layer manages processes and algorithms
- Data layer holds processes
- Metrics layer consumes results

##### Extract insights from README
- Confirms CLI interface in main.py calls into src/
- Describes two scheduling strategies (FCFS, RR)
- Emphasizes simulation and reporting, not persistence or networking

a. Main components
- CLI Interface (main.py)
- Scheduler Engine
– FCFS strategy
– Round-Robin strategy
- Process Repository
- Process Model
- Metrics Calculator
b. Relationships and interactions
1. User → CLI: user invokes simulation with arguments
2. CLI → Scheduler Engine: passes process list and parameters
3. Scheduler Engine ↔ Process Repository:
- retrieves process definitions
- updates their state (ready, running, finished)
4. Scheduler Engine → Metrics Calculator: streams state transitions or final stats
5. Metrics Calculator → CLI: returns report to display
c. Architectural patterns / principles
- Single Responsibility: each module has a distinct concern (model, repo, engine, metrics, UI)
- Dependency Injection: CLI instantiates repository, engine, metrics and wires them together
- Strategy Pattern: scheduler.py selects between FCFS or RR at runtime
d. Key technologies / libraries
- Python 3.x standard libraries
- pytest for unit tests

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Main layers
    CLI["CLI Interface"]:::code
    subgraph "Scheduler Engine"
        Sched["Scheduler Engine"]:::code
        FCFS["FCFS Strategy"]:::strategy
        RR["Round-Robin Strategy"]:::strategy
    end
    Repo["Process Repository"]:::code
    Model["Process Model"]:::code
    Metrics["Metrics Calculator"]:::code

    %% Test suite
    subgraph "Unit Tests"
        direction TB
        TCLI["tests/test_cli.py"]:::test
        TSched["tests/test_scheduler.py"]:::test
        TModel["tests/test_proceso.py"]:::test
        TRepo["tests/test_repositorio.py"]:::test
        TMetrics["tests/test_metrics.py"]:::test
    end

    %% Connections
    CLI -->|"invoke(config, process_list)"| Sched
    Sched -->|"get_processes() / update_state()"| Repo
    Repo -->|"returns Process objects"| Model
    Sched -->|"emit_event()"| Metrics
    Metrics -->|"report"| CLI

    %% Tests dependencies
    TCLI --> CLI
    TSched --> Sched
    TSched --> FCFS
    TSched --> RR
    TModel --> Model
    TRepo --> Repo
    TMetrics --> Metrics

    %% Click events
    click CLI "https://github.com/pablousky4/scheduler/blob/main/main.py"
    click Sched "https://github.com/pablousky4/scheduler/blob/main/src/scheduler.py"
    click FCFS "https://github.com/pablousky4/scheduler/blob/main/src/scheduler.py"
    click RR "https://github.com/pablousky4/scheduler/blob/main/src/scheduler.py"
    click Repo "https://github.com/pablousky4/scheduler/blob/main/src/repositorio.py"
    click Model "https://github.com/pablousky4/scheduler/blob/main/src/proceso.py"
    click Metrics "https://github.com/pablousky4/scheduler/blob/main/src/metrics.py"
    click TCLI "https://github.com/pablousky4/scheduler/blob/main/tests/test_cli.py"
    click TSched "https://github.com/pablousky4/scheduler/blob/main/tests/test_scheduler.py"
    click TModel "https://github.com/pablousky4/scheduler/blob/main/tests/test_proceso.py"
    click TRepo "https://github.com/pablousky4/scheduler/blob/main/tests/test_repositorio.py"
    click TMetrics "https://github.com/pablousky4/scheduler/blob/main/tests/test_metrics.py"

    %% Styling
    classDef code fill:#BBDEFB,stroke:#1976D2,stroke-width:1px
    classDef strategy fill:#C8E6C9,stroke:#388E3C,stroke-width:1px
    classDef test fill:#E3F2FD,stroke:#90CAF9,stroke-dasharray: 5 5
    class CLI,Sched,Repo,Model,Metrics code
    class FCFS,RR strategy
    class TCLI,TSched,TModel,TRepo,TMetrics test
```
