# thiagofernandesfelipe/cadastro_pessoas architecture

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

## Overview

##### Project type and purpose
- This is a desktop CRUD application (“CadastroPessoas”) built in Delphi 11 targeting Win32.
- Implements an MVC-style pattern to manage person records in a MySQL database.

##### File structure
- Top-level Delphi project files (.dpr, .dproj, .res).
- Controllers folder (PessoaController).
- Models folder (PessoaModel, PessoaListaModel).
- DAOs folder (ConexaoDAO, PessoaDAO).
- Views folder (CadastroPessoasView .pas + .dfm).
- Win32\Debug\config.ini holds database connection settings.
- A SQL dump file for schema setup.

##### Key README insights
- Uses MySQL 8.0.23.
- config.ini holds database credentials and is read at runtime by ConexaoDAO.

##### Main components
a. View Layer
- Component: CadastroPessoasView (Delphi form + DFM)
- Role: UI for creating, editing, listing persons
b. Controller Layer
- Component: uPessoaController
- Role: Handles UI events, orchestrates calls to Models and DAOs
c. Model Layer
- Components: uPessoaModel, uPessoaListaModel
- Role: Encapsulate business objects and in-memory collections
d. DAO / Persistence Layer
- Components: uConexaoDAO, uPessoaDAO
- Role: Manage database connections and CRUD SQL operations
- Reads config.ini for DB credentials
e. External Service
- MySQL Database Server (schema from dump-projeto_silbeck-202502081956.sql)

- View → Controller: User actions (button clicks)
- Controller → Model: Create/Update domain objects
- Controller → DAO: Pass models for persistence
- DAO → MySQL: Execute SQL over TCP using credentials from config.ini
- DAO → Controller: Return results (success/failure, datasets)
- Controller → View: Push updated Models or lists back for display

##### Important architectural patterns
- MVC separation of concerns (UI, business, persistence)
- DAO pattern isolates SQL logic
- Config-driven connection to external DB

##### Technologies & frameworks
- Delphi VCL (UI, form definitions .dfm)
- MySQL 8.0.23
- INI-file parsing via Delphi’s TIniFile in ConexaoDAO
- Pascal units for each layer

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        CPV["CadastroPessoasView\n(.pas + .dfm)"]:::view
    end

    %% Controller Layer
    subgraph "Controller Layer"
        PC["uPessoaController"]:::controller
    end

    %% Model Layer
    subgraph "Model Layer"
        PM["uPessoaModel"]:::model
        PLM["uPessoaListaModel"]:::model
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        CDAO["uConexaoDAO"]:::dao
        PDAO["uPessoaDAO"]:::dao
        configINI["config.ini"]:::config
    end

    %% External Resources
    sqlDump["Schema Dump\ndump-projeto_silbeck-202502081956.sql"]:::note
    MySQL["MySQL 8.0.23"]:::db

    %% Connections
    CPV -->|"user actions"| PC
    PC -->|"create/update()"| PM
    PC -->|"list()"| PLM
    PC -->|"save()/load()"| PDAO
    PDAO -->|"connect() with creds"| CDAO
    CDAO -->|"reads credentials"| configINI
    PDAO -->|"executeQuery() over TCP"| MySQL
    MySQL -->|"results"| PDAO
    PDAO -->|"results"| PC
    PC -->|"updateView()"| CPV
    sqlDump -.->|"initial schema setup"| MySQL

    %% Click Events
    click CPV "https://github.com/thiagofernandesfelipe/cadastro_pessoas/blob/main/Views/uCadastroPessoasView.pas"
    click CPV "https://github.com/thiagofernandesfelipe/cadastro_pessoas/blob/main/Views/uCadastroPessoasView.dfm"
    click PC "https://github.com/thiagofernandesfelipe/cadastro_pessoas/blob/main/Controllers/uPessoaController.pas"
    click PM "https://github.com/thiagofernandesfelipe/cadastro_pessoas/blob/main/Models/uPessoaModel.pas"
    click PLM "https://github.com/thiagofernandesfelipe/cadastro_pessoas/blob/main/Models/uPessoaListaModel.pas"
    click CDAO "https://github.com/thiagofernandesfelipe/cadastro_pessoas/blob/main/DAOs/uConexaoDAO.pas"
    click PDAO "https://github.com/thiagofernandesfelipe/cadastro_pessoas/blob/main/DAOs/uPessoaDAO.pas"
    click configINI "https://github.com/thiagofernandesfelipe/cadastro_pessoas/blob/main/Win32/Debug/config.ini"
    click sqlDump "https://github.com/thiagofernandesfelipe/cadastro_pessoas/blob/main/dump-projeto_silbeck-202502081956.sql"

    %% Styles
    classDef view fill:#1E90FF,stroke:#333,color:#fff;
    classDef controller fill:#32CD32,stroke:#333,color:#000;
    classDef model fill:#FFD700,stroke:#333,color:#000;
    classDef dao fill:#FF8C00,stroke:#333,color:#000;
    classDef config fill:#D3D3D3,stroke:#333,color:#000;
    classDef db fill:#696969,stroke:#333,color:#fff;
    classDef note fill:#F5F5F5,stroke:#666,color:#000,stroke-dasharray: 5 5;
```
