# bryan-13-ty/calculadora-de-intervalos-de-confianza architecture

> Architecture diagram of the GitHub repository bryan-13-ty/calculadora-de-intervalos-de-confianza, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bryan-13-ty/calculadora-de-intervalos-de-confianza
- Repository: https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza

## Overview

1. **Overall shape**
   This repository is a small, single-process statistical calculator centered on **confidence-interval computation**. The architecture is layered around one entrypoint (`main.py`), a set of **case modules** for each interval type, and shared **service/validation/visualization** code under `src/`.

2. **Entry orchestration**
   `main.py` is the top-level execution path. It likely handles the user interaction flow: selecting the interval family, collecting inputs, invoking the appropriate case logic, and presenting results. For an architecture diagram, treat this as the **orchestrator/controller boundary**.

3. **Problem-domain modules by interval type**
   The `casos/` package contains one module per supported confidence-interval scenario:
   - `media.py`
   - `dif_medias.py`
   - `proporcion.py`
   - `dif_proporciones.py`
   - `varianza.py`
   - `coc_varianzas.py`
   
   These are the **domain entry points** for each statistical case. They separate the formulas and parameter requirements for each interval family.

4. **Shared calculation engine**
   `src/services/calculos.py` is the central computation layer. It likely contains reusable formula functions for margins of error, critical values, and interval bounds. The `casos/*` modules probably call into this service rather than implementing all math inline.

5. **Input validation and error handling**
   `src/validaciones.py` is the gatekeeper for user-supplied data and statistical assumptions. `src/errores.py` and `src/advertencias.py` define the project’s custom error/warning types or messages. In the architecture, place these between input collection and calculation to show that invalid sample sizes, inconsistent variances, or unsupported assumptions are rejected early.

6. **Visualization/output support**
   `src/visualization/graficas.py` is a separate presentation-side component for generating interval graphics. It is likely used after computation to visualize the point estimate and confidence bounds. This is a downstream consumer of the computed interval, not part of the math core.

7. **Utility and shared configuration**
   `src/utils.py` and `config/config.py` hold cross-cutting helpers and constants. `config/` likely contains shared parameters such as confidence levels, formatting, or distribution-related settings. These modules sit at the **shared infrastructure layer** used by both case logic and services.

8. **Repository boundaries**
   The project is organized into clear boundaries:
   - `casos/`: statistical use cases
   - `src/services/`: reusable computational logic
   - `src/validaciones.py` + `src/errores.py` + `src/advertencias.py`: input safety and domain constraints
   - `src/visualization/`: presentation/graphing
   - `config/`: shared configuration
   - `docs/` and `assets/`: supporting materials, not runtime logic

9. **Data flow**
   The typical flow is:
   **user input → validation → case selection → shared calculations → optional graph generation → result output**.
   The key architectural idea is that the case modules translate a specific statistical scenario into a standard call pattern against the shared computation layer.

10. **Supported statistical domains**
   The README defines the supported confidence-interval families, and these map directly to the `casos/` modules:
   - population mean
   - difference of means
   - proportion
   - difference of proportions
   - population variance
   - ratio of variances
   
   That makes the project a **statistical decision tree** rather than a general-purpose analytics engine.

11. **External/static assets**
   `assets/images/` contains illustrative images for each case, and `docs/formulario_Intervalos_de_confianza.pdf` provides reference formulas. These are documentation/support assets rather than runtime dependencies, but they matter for understanding the educational intent and UI presentation.

12. **Likely runtime model**
   The README says to run `py main.py`, which suggests a **local Python application** rather than a web service. No external APIs, databases, or message brokers are indicated. The main architectural concern is therefore internal module coordination, not distributed-system integration.

13. **Diagram guidance**
   If you draw this system, center it on `main.py`, connect it to the six `casos/` modules, then show each case calling:
   - `src/validaciones.py` for input checks
   - `src/services/calculos.py` for formulas
   - `src/visualization/graficas.py` for charts
   - `src/errores.py` / `src/advertencias.py` for exceptional paths
   - `config/config.py` and `src/utils.py` as shared support

14. **Design character**
   The codebase is best understood as a **modular educational calculator** with one level of indirection between user-facing scenarios and statistical formulas. Its main architectural strength is the separation between **case-specific orchestration** and **shared math/validation logic**.

Main entry points: [`src/services/calculos.py`](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/src/services/calculos.py) (Calculations), [`src/validaciones.py`](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/src/validaciones.py) (Validation), [`main.py`](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/main.py) (Main), [`src/visualization/graficas.py`](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/src/visualization/graficas.py) (Graphs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entrypoint"]
  node_main["Main<br/>orchestrator<br/>[main.py]"]
end

subgraph group_cases["Statistical cases"]
  node_case_media["Mean CI<br/>case module<br/>[media.py]"]
  node_case_dif_medias["Mean diff<br/>case module<br/>[dif_medias.py]"]
  node_case_proporcion["Proportion CI<br/>case module<br/>[proporcion.py]"]
  node_case_dif_proporciones["Prop diff<br/>case module"]
  node_case_varianza["Variance CI<br/>case module<br/>[varianza.py]"]
  node_case_coc_varianzas["Variance ratio<br/>case module<br/>[coc_varianzas.py]"]
end

subgraph group_core["Core services"]
  node_calculos["Calculations<br/>math service<br/>[calculos.py]"]
  node_validaciones["Validation<br/>input gate<br/>[validaciones.py]"]
  node_errores["Errors<br/>[errores.py]"]
  node_advertencias["Warnings<br/>[advertencias.py]"]
end

subgraph group_presentation["Presentation"]
  node_graficas["Graphs<br/>visualization<br/>[graficas.py]"]
end

subgraph group_support["Shared support"]
  node_utils["Utilities<br/>shared helpers<br/>[utils.py]"]
  node_config["Config<br/>settings<br/>[config.py]"]
end

node_main -->|"selects"| node_case_media
node_main -->|"selects"| node_case_dif_medias
node_main -->|"selects"| node_case_proporcion
node_main -->|"selects"| node_case_dif_proporciones
node_main -->|"selects"| node_case_varianza
node_main -->|"selects"| node_case_coc_varianzas
node_case_media -->|"checks"| node_validaciones
node_case_media -->|"computes"| node_calculos
node_case_dif_medias -->|"checks"| node_validaciones
node_case_dif_medias -->|"computes"| node_calculos
node_case_proporcion -->|"checks"| node_validaciones
node_case_proporcion -->|"computes"| node_calculos
node_case_dif_proporciones -->|"checks"| node_validaciones
node_case_dif_proporciones -->|"computes"| node_calculos
node_case_varianza -->|"checks"| node_validaciones
node_case_varianza -->|"computes"| node_calculos
node_case_coc_varianzas -->|"checks"| node_validaciones
node_case_coc_varianzas -->|"computes"| node_calculos
node_calculos -->|"reads"| node_config
node_calculos -->|"uses"| node_utils
node_case_media -->|"renders"| node_graficas
node_case_dif_medias -->|"renders"| node_graficas
node_case_proporcion -->|"renders"| node_graficas
node_case_dif_proporciones -->|"renders"| node_graficas
node_case_varianza -->|"renders"| node_graficas
node_case_coc_varianzas -->|"renders"| node_graficas
node_validaciones -->|"raises"| node_errores
node_validaciones -->|"warns"| node_advertencias

click node_main "https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/main.py"
click node_case_media "https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/casos/media.py"
click node_case_dif_medias "https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/casos/dif_medias.py"
click node_case_proporcion "https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/casos/proporcion.py"
click node_case_dif_proporciones "https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/casos/dif_proporciones.py"
click node_case_varianza "https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/casos/varianza.py"
click node_case_coc_varianzas "https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/casos/coc_varianzas.py"
click node_calculos "https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/src/services/calculos.py"
click node_validaciones "https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/src/validaciones.py"
click node_errores "https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/src/errores.py"
click node_advertencias "https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/src/advertencias.py"
click node_graficas "https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/src/visualization/graficas.py"
click node_utils "https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/src/utils.py"
click node_config "https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/config/config.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main toneBlue
class node_case_media,node_case_dif_medias,node_case_proporcion,node_case_dif_proporciones,node_case_varianza,node_case_coc_varianzas toneAmber
class node_calculos,node_validaciones,node_errores,node_advertencias toneMint
class node_graficas toneRose
class node_utils,node_config toneIndigo
```

## Components

### Entrypoint

Top-level runtime orchestration.

- [Main](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/main.py): orchestrator · Top-level application flow and case selection. · `main.py`

### Statistical cases

One module per confidence-interval family.

- [Mean CI](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/casos/media.py): case module · Confidence interval for a population mean. · `casos/media.py`
- [Mean diff](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/casos/dif_medias.py): case module · Confidence interval for the difference of means. · `casos/dif_medias.py`
- [Proportion CI](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/casos/proporcion.py): case module · Confidence interval for a proportion. · `casos/proporcion.py`
- [Prop diff](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/casos/dif_proporciones.py): case module · Confidence interval for the difference of proportions. · `casos/dif_proporciones.py`
- [Variance CI](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/casos/varianza.py): case module · Confidence interval for a population variance. · `casos/varianza.py`
- [Variance ratio](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/casos/coc_varianzas.py): case module · Confidence interval for the ratio of variances. · `casos/coc_varianzas.py`

### Core services

Shared validation, math, and support logic.

- [Calculations](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/src/services/calculos.py): math service · Reusable statistical formulas and interval computations. · `src/services/calculos.py`
- [Validation](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/src/validaciones.py): input gate · Checks user input and statistical assumptions. · `src/validaciones.py`
- [Errors](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/src/errores.py): domain errors · Custom error definitions and handling support. · `src/errores.py`
- [Warnings](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/src/advertencias.py): domain warnings · Warning types or messages for non-fatal issues. · `src/advertencias.py`

### Presentation

Output and visualization layer.

- [Graphs](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/src/visualization/graficas.py): visualization · Interval charts and presentation graphics. · `src/visualization/graficas.py`

### Shared support

Cross-cutting utilities and configuration.

- [Utilities](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/src/utils.py): shared helpers · Common helper functions used across modules. · `src/utils.py`
- [Config](https://github.com/bryan-13-ty/calculadora-de-intervalos-de-confianza/blob/main/config/config.py): settings · Shared configuration and constants. · `config/config.py`

## Connections

- Main → Mean CI: selects · Routes the user to the mean interval workflow.
- Main → Mean diff: selects · Routes the user to the difference-of-means workflow.
- Main → Proportion CI: selects · Routes the user to the proportion workflow.
- Main → Prop diff: selects · Routes the user to the difference-of-proportions workflow.
- Main → Variance CI: selects · Routes the user to the variance workflow.
- Main → Variance ratio: selects · Routes the user to the variance-ratio workflow.
- Mean CI → Validation: checks · Validates sample and confidence inputs before computing.
- Mean CI → Calculations: computes · Delegates interval formulas to the shared math layer.
- Mean diff → Validation: checks · Validates assumptions for two-sample mean intervals.
- Mean diff → Calculations: computes · Uses shared formulas for mean-difference intervals.
- Proportion CI → Validation: checks · Validates proportion inputs and constraints.
- Proportion CI → Calculations: computes · Uses shared formulas for proportion intervals.
- Prop diff → Validation: checks · Validates two-proportion assumptions and counts.
- Prop diff → Calculations: computes · Uses shared formulas for difference-of-proportions intervals.
- Variance CI → Validation: checks · Validates variance interval inputs.
- Variance CI → Calculations: computes · Uses shared formulas for variance intervals.
- Variance ratio → Validation: checks · Validates ratio-of-variances assumptions.
- Variance ratio → Calculations: computes · Uses shared formulas for variance-ratio intervals.
- Calculations → Config: reads · Consumes shared statistical settings and constants.
- Calculations → Utilities: uses · Reuses helper logic for formatting and support calculations.
- Mean CI → Graphs: renders · Produces a visualization of the computed interval.
- Mean diff → Graphs: renders · Produces a visualization of the computed interval.
- Proportion CI → Graphs: renders · Produces a visualization of the computed interval.
- Prop diff → Graphs: renders · Produces a visualization of the computed interval.
- Variance CI → Graphs: renders · Produces a visualization of the computed interval.
- Variance ratio → Graphs: renders · Produces a visualization of the computed interval.
- Validation → Errors: raises · Uses custom error types for invalid inputs.
- Validation → Warnings: warns · Emits non-fatal warnings for borderline assumptions.
