# thiagofernandesfelipe/servicos_farmaceuticos architecture

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

- Interactive diagram: https://gitdiagram.com/thiagofernandesfelipe/servicos_farmaceuticos
- Repository: https://github.com/thiagofernandesfelipe/servicos_farmaceuticos

## Overview

##### Project type and purpose
- This is a desktop application built with Delphi (Pascal) following a classical MVC (Model-View-Controller) pattern.
- Its purpose is to manage “Serviços Farmacêuticos,” interacting with a MySQL database (script.sql provides the schema).
- Key indicators: directories named Controllers, DAO, Models, Views; .dpr and .dproj Delphi project files; MySQL mentioned in README.

##### File structure
- Controllers: business-logic layer (uConexaoControl, uProcedimentoControl, uServicoControl)
- DAO: persistence layer interacting with MySQL (uConexaoDAO, uProcedimentoDAO, uServicoDAO)
- Models: data entities (uAcaoModel, uProcedimentoModel, uServicoModel)
- Views: VCL form files (.dfm + .pas) for UI (Main form and Serviços form)
- Root files: servicos_farmaceuticos.dpr (entry point), script.sql (DB schema), .res for resources
- Win32/Debug: compiled units and the .exe for local deployment/testing

##### README for additional insights
- Confirms MVC pattern and tech stack: Delphi 11 + MySQL 8.0.
- Suggests there are no external microservices—just a single Delphi client connecting to MySQL.

##### Elements
- “Views” (uFrmPrincipalView, uFrmServicoView)
- “Controllers” (uConexaoControl, uProcedimentoControl, uServicoControl)
- “Models” (uAcaoModel, uProcedimentoModel, uServicoModel)
- “DAO” (uConexaoDAO, uProcedimentoDAO, uServicoDAO)
- “MySQL Database” (tables created by script.sql)
- UI → Controller → DAO → Database
- Database → DAO → Controller → UI
- Business logic (Controllers) in another (e.g., green)
- Data layer (Models + DAO) in a third (e.g., yellow)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry Point and Project Files
    EP["servicos_farmaceuticos.dpr"]:::entry
    DPROJ["servicos_farmaceuticos.dproj"]:::entry
    RES["servicos_farmaceuticos.res"]:::entry

    %% Views Layer
    subgraph "Views" 
        direction TB
        U1["uFrmPrincipalView.pas"]:::view
        U1DFM["uFrmPrincipalView.dfm"]:::view
        U2["uFrmServicoView.pas"]:::view
        U2DFM["uFrmServicoView.dfm"]:::view
    end

    %% Controllers Layer
    subgraph "Controllers"
        direction TB
        C1["uConexaoControl.pas"]:::controller
        C2["uProcedimentoControl.pas"]:::controller
        C3["uServicoControl.pas"]:::controller
    end

    %% Models Layer
    subgraph "Models"
        direction TB
        M1["uAcaoModel.pas"]:::model
        M2["uProcedimentoModel.pas"]:::model
        M3["uServicoModel.pas"]:::model
    end

    %% DAO Layer
    subgraph "DAO"
        direction TB
        D1["uConexaoDAO.pas"]:::dao
        D2["uProcedimentoDAO.pas"]:::dao
        D3["uServicoDAO.pas"]:::dao
    end

    %% Database
    subgraph "Database"
        direction TB
        SCRIPT["script.sql"]:::database
        DB["MySQL Database"]:::database
    end

    %% Data Flows
    EP -->|"launches"| U1
    EP -->|"launches"| U2

    U1 -->|"UserEvent"| C2
    U1 -->|"UserEvent"| C3
    U2 -->|"UserEvent"| C2
    U2 -->|"UserEvent"| C3

    C1 -->|"Init Connection"| D1
    C2 -->|"Validate & Prepare"| M2
    C3 -->|"Validate & Prepare"| M3

    C2 -->|"LoadProcedimentos"| D2
    C3 -->|"LoadServicos"| D3

    D1 -->|"Connect"| DB
    D2 -->|"Execute SQL SELECT"| DB
    D3 -->|"Execute SQL SELECT"| DB
    SCRIPT -->|"Initialize Schema"| DB

    DB -->|"ResultSet"| D2
    DB -->|"ResultSet"| D3

    D2 -->|"Returns uProcedimentoModelList"| C2
    D3 -->|"Returns uServicoModelList"| C3
    D1 -->|"ConnectionHandle"| C1

    C2 -->|"Populate Data"| U1
    C3 -->|"Populate Data"| U2

    %% Click Events
    click U1 "https://github.com/thiagofernandesfelipe/servicos_farmaceuticos/blob/main/Views/uFrmPrincipalView.pas"
    click U1DFM "https://github.com/thiagofernandesfelipe/servicos_farmaceuticos/blob/main/Views/uFrmPrincipalView.dfm"
    click U2 "https://github.com/thiagofernandesfelipe/servicos_farmaceuticos/blob/main/Views/uFrmServicoView.pas"
    click U2DFM "https://github.com/thiagofernandesfelipe/servicos_farmaceuticos/blob/main/Views/uFrmServicoView.dfm"

    click C1 "https://github.com/thiagofernandesfelipe/servicos_farmaceuticos/blob/main/Controllers/uConexaoControl.pas"
    click C2 "https://github.com/thiagofernandesfelipe/servicos_farmaceuticos/blob/main/Controllers/uProcedimentoControl.pas"
    click C3 "https://github.com/thiagofernandesfelipe/servicos_farmaceuticos/blob/main/Controllers/uServicoControl.pas"

    click M1 "https://github.com/thiagofernandesfelipe/servicos_farmaceuticos/blob/main/Models/uAcaoModel.pas"
    click M2 "https://github.com/thiagofernandesfelipe/servicos_farmaceuticos/blob/main/Models/uProcedimentoModel.pas"
    click M3 "https://github.com/thiagofernandesfelipe/servicos_farmaceuticos/blob/main/Models/uServicoModel.pas"

    click D1 "https://github.com/thiagofernandesfelipe/servicos_farmaceuticos/blob/main/DAO/uConexaoDAO.pas"
    click D2 "https://github.com/thiagofernandesfelipe/servicos_farmaceuticos/blob/main/DAO/uProcedimentoDAO.pas"
    click D3 "https://github.com/thiagofernandesfelipe/servicos_farmaceuticos/blob/main/DAO/uServicoDAO.pas"

    click SCRIPT "https://github.com/thiagofernandesfelipe/servicos_farmaceuticos/blob/main/script.sql"
    click EP "https://github.com/thiagofernandesfelipe/servicos_farmaceuticos/blob/main/servicos_farmaceuticos.dpr"
    click DPROJ "https://github.com/thiagofernandesfelipe/servicos_farmaceuticos/blob/main/servicos_farmaceuticos.dproj"
    click RES "https://github.com/thiagofernandesfelipe/servicos_farmaceuticos/blob/main/servicos_farmaceuticos.res"

    %% Styles
    classDef entry fill:#ffe0e0,stroke:#e06060,stroke-width:1px
    classDef view fill:#e0f7ff,stroke:#60a0d0,stroke-width:1px
    classDef controller fill:#e0ffe0,stroke:#60d060,stroke-width:1px
    classDef model fill:#fff7d0,stroke:#d0b060,stroke-width:1px
    classDef dao fill:#ffe4c4,stroke:#d08040,stroke-width:1px
    classDef database fill:#f0f0f0,stroke:#909090,stroke-width:1px,stroke-dasharray: 3 3
```
