# el-bid/red_basica architecture

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

- Interactive diagram: https://gitdiagram.com/el-bid/red_basica
- Repository: https://github.com/el-bid/red_basica

## Overview

##### Project Type and Purpose
- The README clearly shows that this is a QGIS plugin designed to aid in the design and dimensioning of sewage collector networks (especially for condominiums) using modern calculation tools. It integrates directly into QGIS (a geographic information system) and replaces legacy Excel-based dimensioning spreadsheets.
- The plugin not only adds custom drawing and attribute management capabilities (layers, dialogs, UI windows) within QGIS but also performs hydraulic calculations, handles file exports (e.g., .csv and swmm-compatible formats), and integrates with external libraries for Excel parsing and generation.

##### Analyzing the File Structure
- The “app” directory encapsulates the core plugin code and is divided using an MVC-like pattern:
- /app/controllers: Contains multiple controllers (e.g., ApiController, CalculationController, DataController, FlowController, etc.) that serve as intermediaries between the UI events and the underlying business logic.
- /app/models: Defines domain objects (e.g., Calculation, Pipe, Project) and related delegates that represent business logic and data.
- /app/views: Contains the view components including UI windows and dialogs (e.g., MainView, LoginView) with a subgroup “ui” that holds auto-generated or hand-written PyQt UI classes.
- The /app/lib directory and its xlrd/xlwt/xlutils subdirectories provide interoperability with Excel files. This indicates that the system does significant data import/export and formatting operations.
- Additional directories (e.g., /base, /profile, /i18n) include resources for printing templates, additional UI components, and internationalization files. These support both auxiliary functionalities and user customization.

##### Architectural Patterns and Components
- Layered/MVC Architecture:
- Controllers handle user requests and coordinate the flow.
- Models define domain entities and act as intermediaries for data and calculations.
- Views manage the user interface, typically through PyQt dialogs and QGIS-specific integrations.
- QGIS Plugin Integration:
- The plugin integrates directly into QGIS, so a key architectural component is the “integration layer” where QGIS events (like menu selections or interface triggers) pass control to the plugin’s controllers.
- Data Processing & External Dependencies:
- The system relies on specialized libraries (xlrd, xlwt, xlutils) for managing Excel spreadsheets used in data import/export.
- Base functions (found in the /base folder) provide helper routines, printing templates, and additional utilities used by the plugin.
- Internationalization (i18n):
- The i18n folder contains language files, which implies the application supports multiple locales.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "QGIS Integration Layer"
      QGISInterface["QGIS Plugin Interface"]:::integration
    end

    subgraph "User Interface Layer"
      UI["Frontend/User Interface"]:::ui
    end

    subgraph "Controller Layer"
      Controllers["Controllers"]:::controller
    end

    subgraph "Domain Model Layer"
      Models["Domain/Model Layer"]:::model
    end

    subgraph "Utility & External Layer"
      ExcelLib["Libraries & Utilities (Excel)"]:::utility
      Exports["External Services and Exports"]:::export
      Resources["Resource & Configuration"]:::resource
    end

    QGISInterface -->|"triggers"| Controllers
    UI -->|"useractions"| Controllers
    Controllers -->|"updates"| Models
    Controllers -->|"calls"| ExcelLib
    Controllers -->|"exports"| Exports
    Models -->|"providesData"| UI
    Resources -->|"assets"| UI
    Resources -->|"configures"| ExcelLib
    Resources -->|"supports"| Controllers

    click QGISInterface "https://github.com/el-bid/red_basica/blob/dev/app/__init__.py"
    click QGISInterface "https://github.com/el-bid/red_basica/blob/dev/base/red_basica.py"
    click UI "https://github.com/el-bid/red_basica/tree/dev/app/views"
    click UI "https://github.com/el-bid/red_basica/tree/dev/base/resources"
    click Controllers "https://github.com/el-bid/red_basica/tree/dev/app/controllers"
    click Models "https://github.com/el-bid/red_basica/tree/dev/app/models"
    click Models "https://github.com/el-bid/red_basica/tree/dev/app/models/delegates"
    click ExcelLib "https://github.com/el-bid/red_basica/tree/dev/app/lib/xlrd"
    click ExcelLib "https://github.com/el-bid/red_basica/tree/dev/app/lib/xlwt"
    click ExcelLib "https://github.com/el-bid/red_basica/tree/dev/app/lib/xlutils"
    click Exports "https://github.com/el-bid/red_basica/blob/dev/app/controllers/SwmmController.py"
    click Exports "https://github.com/el-bid/red_basica/blob/dev/app/controllers/XlsController.py"
    click Exports "https://github.com/el-bid/red_basica/tree/dev/app/resources/xls"
    click Resources "https://github.com/el-bid/red_basica/tree/dev/i18n"
    click Resources "https://github.com/el-bid/red_basica/tree/dev/base/Print"

classDef integration fill:#f9d0a9,stroke:#333,stroke-width:2px;
classDef ui fill:#a9d0f9,stroke:#333,stroke-width:2px;
classDef controller fill:#a9f9a9,stroke:#333,stroke-width:2px;
classDef model fill:#f9a9f9,stroke:#333,stroke-width:2px;
classDef utility fill:#f9e79f,stroke:#333,stroke-width:2px;
classDef export fill:#f9c0a9,stroke:#333,stroke-width:2px;
classDef resource fill:#d0a9f9,stroke:#333,stroke-width:2px;
```
