# jhackisneros/examen_final architecture

> Architecture diagram of the GitHub repository jhackisneros/examen_final, 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/jhackisneros/examen_final
- Repository: https://github.com/jhackisneros/examen_final

## Overview

##### Project Type and Purpose
- This is a Python‐based scheduling/processing tool (not a full‐stack web app).
- It reads process definitions from a JSON “database,” runs a scheduler, collects metrics, and persists or displays results.
- Entry points: `lanzador.py` (launcher script) and `main.py`.

##### Main Architectural Components
a. Presentation / CLI Layer
- lanzador.py – parses CLI arguments, environment variables, scheduling strategy parameters.
- main.py – orchestrates application bootstrap, service wiring (dependency injection of scheduler, repos, metrics).

b. Application / Orchestration Layer
- src/scheduler.py – core scheduling engine; implements dispatch algorithms.
- src/metrics.py – collects and formats scheduling metrics (turnaround time, waiting time, etc.).

c. Domain Layer
- src/proceso.py – domain model of a “Process” with id, arrival time, burst, priority, etc.
- src/repositorio_procesos.py – domain‐level interface for loading process lists.

d. Infrastructure / Persistence Layer
- database/json_database.py – concrete persistence adapter reading/writing `procesos.json`.
- src/database.py – abstract database interface for storing schedules or metrics.
- src/repositorio.py – general repository abstraction for persistence of runs/results.

e. Tests
- tests/test_proceso.py – example of unit tests against the domain model.

##### Relationships & Data Flow
- CLI → main → scheduler
- Scheduler → repositorio_procesos (to fetch input processes)
- Scheduler → metrics (to record scheduling events)
- Metrics → repositorio (to persist or export metrics)
- Repositorio → database adapter (JSON persistence)
- Optionally, database → repositorio_procesos (for loading)

##### Architectural Patterns & Principles
- Layered architecture: CLI / Application / Domain / Infrastructure
- Dependency Inversion: Scheduler and Metrics depend on repository interfaces, not concrete JSON classes.
- Single Responsibility: Each module has one clear concern (parsing, scheduling, persistence).
- Testability: Mocks can replace JSON DB for unit testing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI / Presentation Layer
    subgraph "CLI Layer"
        direction TB
        CLI["lanzador.py"]:::cli
        Main["main.py"]:::cli
    end

    %% Application / Orchestration Layer
    subgraph "Application / Orchestration Layer"
        direction TB
        Scheduler["Scheduler Service"]:::app
        Metrics["Metrics Collector"]:::app
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        Proceso["Process Domain Model"]:::domain
        RepoProc["Process Repository Interface"]:::domain
    end

    %% Infrastructure / Persistence Layer
    subgraph "Infrastructure / Persistence Layer"
        direction TB
        DBInterface["Database Interface"]:::infra
        Repo["General Repository"]:::infra
        JSONAdapter["JSON Database Adapter"]:::infra
        JSONFile["procesos.json"]:::infra
    end

    %% Tests
    subgraph "Tests"
        direction TB
        TestProceso["test_proceso.py"]:::tests
    end

    %% Relationships
    CLI -->|"parses args/env"| Main
    Main -->|"wires Scheduler & Metrics"| Scheduler
    Main -->|"wires Scheduler & Metrics"| Metrics

    Scheduler -->|"List<Proceso>"| RepoProc
    Scheduler -->|"ScheduleResult"| Metrics

    Metrics -->|"MetricsData"| Repo

    Repo -->|"persist() calls"| DBInterface
    JSONAdapter -.->|"implements"| DBInterface
    JSONAdapter -->|"reads/writes"| JSONFile
    JSONAdapter -->|"loads processes"| RepoProc

    %% Click Events
    click CLI "https://github.com/jhackisneros/examen_final/blob/main/lanzador.py"
    click Main "https://github.com/jhackisneros/examen_final/blob/main/main.py"
    click Scheduler "https://github.com/jhackisneros/examen_final/blob/main/src/scheduler.py"
    click Metrics "https://github.com/jhackisneros/examen_final/blob/main/src/metrics.py"
    click Proceso "https://github.com/jhackisneros/examen_final/blob/main/src/proceso.py"
    click RepoProc "https://github.com/jhackisneros/examen_final/blob/main/src/repositorio_procesos.py"
    click JSONAdapter "https://github.com/jhackisneros/examen_final/blob/main/database/json_database.py"
    click JSONFile "https://github.com/jhackisneros/examen_final/blob/main/database/procesos.json"
    click DBInterface "https://github.com/jhackisneros/examen_final/blob/main/src/database.py"
    click Repo "https://github.com/jhackisneros/examen_final/blob/main/src/repositorio.py"
    click TestProceso "https://github.com/jhackisneros/examen_final/blob/main/tests/test_proceso.py"

    %% Styles
    classDef cli fill:#BBDEFB,stroke:#333,stroke-width:1px
    classDef app fill:#90CAF9,stroke:#333,stroke-width:1px
    classDef domain fill:#C8E6C9,stroke:#333,stroke-width:1px
    classDef infra fill:#FFE0B2,stroke:#333,stroke-width:1px
    classDef tests fill:#E0E0E0,stroke:#333,stroke-width:1px
```
