# leonardocruzx/desafiobackendencontact2021 architecture

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

- Interactive diagram: https://gitdiagram.com/leonardocruzx/desafiobackendencontact2021
- Repository: https://github.com/leonardocruzx/desafiobackendencontact2021

## Overview

##### Main Components Identification

The project follows a clean architecture pattern with distinct layers:
- API Layer (TesteBackendEnContact.Api)
- Core Layer (TesteBackendEnContact.Core)
- Data Layer (TesteBackendEnContact.Data)
- Services Layer (TesteBackendEnContact.Services)
- Integration Tests Layer (TesteBackendEnContact.Api.IntegrationTests)

##### Component Relationships

- Dependency flow (always pointing downward)
- Data flow between components
- Implementation relationships

##### Special Features to Highlight

Create dedicated sections showing:
- CSV import flow
- Pagination mechanism
- Search functionality
- Contact-Company relationships
- ContactBook management

##### Specific Elements

a) Main Flows:
**Client -> API Controller -> Service -> Repository -> Database**

b) Cross-cutting Concerns:
- AutoMapper profiles
- Validation rules
- Unit of Work pattern
- Repository pattern

##### Technical Details to Note

- SQLite database connection
- REST endpoints
- Resource mapping
- Entity configurations
- Integration tests coverage

##### The search and pagination mechanisms

Keep the abstraction level focused on the architectural components while showing the key relationships and data flows that make up the contact management system. This will help developers understand both the high-level structure and the specific implementation details of the system.

Remember to include notes about the key features:
- Contact book CRUD operations
- Company management
- CSV import functionality
- Paginated search capabilities
- Company-specific contact filtering
- Export functionality

This will create a comprehensive visualization that accurately represents the system's architecture while highlighting its key functional requirements and technical implementation details.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Clients
        CSV["CSV Importer"]:::client
        API_Consumer["API Consumer"]:::client
    end

    subgraph API_Layer["API Layer"]
        Controllers["Controllers"]:::api
        click Controllers "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/tree/main/TesteBackendEnContact.Api/Controllers"
        
        Resources["DTOs/Resources"]:::api
        click Resources "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/tree/main/TesteBackendEnContact.Api/Resources"
        
        Validators["Validators"]:::api
        click Validators "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/blob/main/TesteBackendEnContact.Api/Validators/SaveContactResourceValidator.cs"
        
        Mapping["AutoMapper Profiles"]:::api
        click Mapping "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/blob/main/TesteBackendEnContact.Api/Mapping/MappingProfile.cs"
        
        subgraph Controllers_Detail["Controller Components"]
            CompanyCtrl["Company Controller"]:::controller
            click CompanyCtrl "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/blob/main/TesteBackendEnContact.Api/Controllers/CompanyController.cs"
            
            ContactBookCtrl["ContactBook Controller"]:::controller
            click ContactBookCtrl "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/blob/main/TesteBackendEnContact.Api/Controllers/ContactBookController.cs"
            
            ContactCtrl["Contact Controller"]:::controller
            click ContactCtrl "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/blob/main/TesteBackendEnContact.Api/Controllers/ContactController.cs"
        end
    end

    subgraph Service_Layer["Service Layer"]
        Services["Services"]:::service
        click Services "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/blob/main/TesteBackendEnContact.Services"
        
        CompanySvc["Company Service"]:::service
        click CompanySvc "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/blob/main/TesteBackendEnContact.Services/CompanyService.cs"
        
        ContactBookSvc["ContactBook Service"]:::service
        click ContactBookSvc "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/blob/main/TesteBackendEnContact.Services/ContactBookService.cs"
        
        ContactSvc["Contact Service"]:::service
        click ContactSvc "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/blob/main/TesteBackendEnContact.Services/ContactService.cs"
    end

    subgraph Core_Layer["Core Layer"]
        Models["Domain Models"]:::core
        click Models "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/tree/main/TesteBackendEnContact.Core/Models"
        
        Interfaces["Service Interfaces"]:::core
        click Interfaces "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/tree/main/TesteBackendEnContact.Core/Interfaces/Services"
        
        RepoInterfaces["Repository Interfaces"]:::core
        click RepoInterfaces "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/tree/main/TesteBackendEnContact.Core/Repositories"
        
        Pagination["Pagination Components"]:::core
        click Pagination "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/tree/main/TesteBackendEnContact.Core/Pagination"
        
        Filters["Filters"]:::core
        click Filters "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/blob/main/TesteBackendEnContact.Core/Filters/ContactFilter.cs"
        
        UnitOfWork["Unit of Work Interface"]:::core
        click UnitOfWork "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/blob/main/TesteBackendEnContact.Core/Interfaces/IUnitOfWork.cs"
    end

    subgraph Data_Layer["Data Layer"]
        DbContext["DbContext"]:::data
        click DbContext "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/blob/main/TesteBackendEnContact.Data/TesteBackendEnContactContext.cs"
        
        Repositories["Repositories"]:::data
        click Repositories "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/tree/main/TesteBackendEnContact.Data/Repositories"
        
        EntityConfig["Entity Configurations"]:::data
        click EntityConfig "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/tree/main/TesteBackendEnContact.Data/Configurations"
        
        UnitOfWorkImpl["Unit of Work Implementation"]:::data
        click UnitOfWorkImpl "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/blob/main/TesteBackendEnContact.Data/UnitOfWork.cs"
        
        Database[(SQLite Database)]:::database
    end

    subgraph Tests["Integration Tests"]
        IntegrationTests["API Integration Tests"]:::test
        click IntegrationTests "https://github.com/LeonardoCruzx/DesafioBackEndEncontact2021/blob/main/TesteBackendEnContact.Api.IntegrationTests"
    end

    %% Relationships
    CSV --> Controllers
    API_Consumer --> Controllers
    Controllers --> Services
    Services --> RepoInterfaces
    RepoInterfaces --> Repositories
    Repositories --> DbContext
    DbContext --> Database

    %% Styling
    classDef client fill:#gray,stroke:#333,stroke-width:2px
    classDef api fill:#blue,stroke:#333,stroke-width:2px
    classDef controller fill:#lightblue,stroke:#333,stroke-width:2px
    classDef service fill:#green,stroke:#333,stroke-width:2px
    classDef core fill:#yellow,stroke:#333,stroke-width:2px
    classDef data fill:#orange,stroke:#333,stroke-width:2px
    classDef database fill:#red,stroke:#333,stroke-width:2px
    classDef test fill:#purple,stroke:#333,stroke-width:2px
```
