# damiramirez/go-so-2024 architecture

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

- Interactive diagram: https://gitdiagram.com/damiramirez/go-so-2024
- Repository: https://github.com/damiramirez/go-so-2024

## Overview

##### Main Components
- Kernel: Acts as the central coordinator and contains submodules for process management (PCB management), scheduling algorithms (FIFO, Round Robin, Virtual Round Robin), longterm/shortterm planning, resource management, and blocking.
- CPU: Responsible for low-level instruction handling. Its internal structure includes components for fetching, decoding/dispatching, executing instructions, and TLB management.
- Memory (Memoria): Manages memory operations. It contains modules to handle memory functions, utilities, and supports configurations linked to deadlock and TLB setups.
- I/O Subsystem (Entradasalida): Manages device interactions (e.g., generic I/O, keyboard, monitor, file system I/O, and specialized scenarios like Salvation’s Edge). It provides API servers for handling requests.
- Auxiliary Modules and Utilities: This includes shared utilities such as logging, configuration management, request handling, and serialization, which support all major components.

##### Interactions
- That configuration files (found in each module’s “config” directory) are responsible for defining operation modes (e.g., scheduling algorithms, TLB policies) that are injected into each module.
- That there are API layers in each major module (shown in the “api” directories) that allow for networked or inter-process communication (e.g., the Kernel’s API with handlers for planning, process management, and I/O operations).

##### Architectural Patterns and Design Principles
- Modular Structure: Each core system (kernel, CPU, memory, and I/O) is isolated in its own directory with an internal breakdown (e.g., API servers, handlers, internal logic, global configuration).
- Configurability: The heavy use of external JSON configuration files demonstrates a design for high customizability (e.g., switching scheduling policies or memory management strategies).
- Testing and Process Simulation: The “run” scripts and “procesos” directory indicate that the system is built for rigorous testing by simulating processes and scenarios like deadlock, planning, and FS interactions.

##### Essential Architectural Elements
- Detail every internal module that is key to the simulation (e.g., CPU’s “fetch”, “dispatch”, “execute” pipelines; Kernel’s “block”, “longterm”, “shortterm” modules).
- External integrations are represented, such as the API endpoints each module exposes (i.e., the “handlers” directories).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Kernel Block
    subgraph "Kernel"
        K_PCB["PCB Management"]:::kernelStyle
        K_Sched["Scheduling (FIFO,RoundRobin,VRoundRobin)"]:::kernelStyle
        K_Planner["LongTerm/ShortTerm Planning"]:::kernelStyle
        K_Resource["Resource & Blocking"]:::kernelStyle
        K_API["API Handlers"]:::kernelStyle
    end

    %% CPU Block
    subgraph "CPU"
        CPU_Fetch["Fetch"]:::cpuStyle
        CPU_Dispatch["Dispatch"]:::cpuStyle
        CPU_Execute["Execute"]:::cpuStyle
        CPU_TLB["TLB Management (FIFO/ LRU)"]:::cpuStyle
        CPU_API["API Layer"]:::cpuStyle
    end

    %% Memory Block
    subgraph "Memory"
        MEM_Functions["Memory Functions"]:::memoryStyle
        MEM_Utilities["Utilities"]:::memoryStyle
        MEM_Config["Configurations"]:::memoryStyle
        MEM_API["API Layer"]:::memoryStyle
    end

    %% I/O Subsystem Block
    subgraph "Entradasalida I/O"
        IO_Generic["Generic I/O"]:::ioStyle
        IO_Keyboard["Keyboard"]:::ioStyle
        IO_Monitor["Monitor"]:::ioStyle
        IO_FS["File System I/O"]:::ioStyle
        IO_Salvation["Salvation's Edge"]:::ioStyle
        IO_API["API Server"]:::ioStyle
    end

    %% Auxiliary Modules and Simulation
    subgraph "Auxiliary & Simulation"
        Utils["Auxiliary Modules & Utilities"]:::simulationStyle
        ProcSim["Process Simulation"]:::simulationStyle
    end

    %% Configuration Influence Node
    Config["JSON Configs"]:::configStyle

    %% Interactions
    %% Kernel interactions to other major components via its API
    K_API -->|"schedules_process"| CPU_Fetch
    K_API -->|"allocates_memory"| MEM_Functions
    K_API -->|"manages_IO"| IO_API

    %% Utils supports all modules (dotted connections)
    Utils --- K_API
    Utils --- CPU_API
    Utils --- MEM_API
    Utils --- IO_API

    %% Process simulation linked to Kernel's PCB management
    K_PCB -->|"simulated_by"| ProcSim

    %% Configuration influences specific submodules
    Config -.-> K_Sched
    Config -.-> CPU_TLB
    Config -.-> MEM_Config
    Config -.-> IO_Generic

    %% Click Events for Component Mapping
    click K_API "https://github.com/damiramirez/go-so-2024/tree/main/kernel/"
    click CPU_Fetch "https://github.com/damiramirez/go-so-2024/tree/main/cpu/"
    click MEM_Functions "https://github.com/damiramirez/go-so-2024/tree/main/memoria/"
    click IO_Generic "https://github.com/damiramirez/go-so-2024/tree/main/entradasalida/"
    click Utils "https://github.com/damiramirez/go-so-2024/tree/main/utils/"
    click ProcSim "https://github.com/damiramirez/go-so-2024/tree/main/procesos/"
    click ProcSim "https://github.com/damiramirez/go-so-2024/tree/main/run/"

    %% Styles Definition
    classDef kernelStyle fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef cpuStyle fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef memoryStyle fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef ioStyle fill:#FFB347,stroke:#000,stroke-width:2px;
    classDef simulationStyle fill:#D8BFD8,stroke:#000,stroke-width:2px;
    classDef configStyle fill:#FFC0CB,stroke:#000,stroke-width:2px;
```
