# bpthiago/estagio-rec architecture

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

- Interactive diagram: https://gitdiagram.com/bpthiago/estagio-rec
- Repository: https://github.com/bpthiago/estagio-rec

## Overview

This project is a C# web API designed to manage and coordinate student internship data for the Campus, specifically facilitating the processes for the Coordenadoria de Relações Institucionais e Extensão Comunitária – REC. The project is structured in a layered (or Clean Architecture) fashion, separating concerns clearly among the presentation layer (controllers), application/business logic, domain entities, and persistence layers.

##### Main Components
- Frontend/API Layer: Although there isn’t a dedicated “frontend” directory, the controllers (e.g., AlunoController, EmpresaController, EstagioController, OrientadorController) represent the API endpoints handling HTTP requests.
- Application Layer: Contains the business logic (UseCases, DTOs, Services) that drive the system’s processes for operations like adding, updating, deleting, and retrieving records for “Aluno”, “Empresa”, “Estagio”, and “Orientador”.
- Domain Layer: Encapsulates core business entities (Aluno, Empresa, Estagio, Orientador) and enumerations (e.g., SituacaoEnum) that define the data models.
- Persistence Layer: Responsible for data access and storage, including the AppDbContext, various repository implementations, and corresponding interfaces to abstract data operations.
- Supporting Infrastructure: Projects files like Dockerfile, docker-compose files indicate containerization, while configuration files (launchSettings.json) enable environment settings.

##### Component Relationships and Interactions
- The Controllers receive API requests and pass them to the Application layer. They invoke specific UseCases (e.g., AdicionarAlunoHandler, AtualizarEmpresaHandler) to process business logic.
- The UseCases interact with the Domain entities, validating and transforming data via Mappers and DTO objects.
- After processing, the UseCases will delegate operations to the Persistence layer through repository interfaces. The repositories (e.g., AlunoRepository, EmpresaRepository) implement the actual data access logic and communicate with the database.
- The Application layer also offers extensions (ServiceExtensions) to configure dependency injection, linking controllers, use cases, and repository implementations.
- Docker files and associated docker-compose configurations represent the deployment containerization strategy, showing how the application is built, tested, and deployed.

##### Architectural Patterns/Design Principles
- Layered Architecture / Clean Architecture: Clear separation into controllers, application logic, domain model, and persistence.
- Use of DTOs and Mappers: Ensures that data transformation logic is decoupled from business logic.
- Repository Pattern: For abstracting data access processing.
- Dependency Injection: Evidenced by ServiceExtensions to manage dependencies.
- Containerization: Use of Docker and Docker Compose for portability and deployment.

##### Relevant Technologies and Frameworks
- The project is based in .NET/C# (as evidenced by the .csproj file and solution file) using an MVC/Web API pattern.
- Entity Framework (likely inferred from the AppDbContext, which is typical in EF setups).
- Docker for containerization.
- Possibly additional .NET libraries/frameworks for dependency injection and mapping.

##### Detail the Data Flow and Dependency Injection
- That the Use Cases might have base classes (e.g., BaseUseCases) that provide common functionality, representing a shared service abstraction.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Presentation Layer
    subgraph "Presentation Layer"
        Controllers["API Controllers"]:::presentation
    end

    %% Application Layer
    subgraph "Application Layer"
        UseCases["Use Cases"]:::application
        DTOs["DTOs"]:::application
        AppService["Service Extensions (DI)"]:::application
    end

    %% Domain Layer
    subgraph "Domain Layer"
        Entities["Domain Entities"]:::domain
        Enumerations["Domain Enumerations"]:::domain
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        AppDbContext["AppDbContext"]:::persistence
        RepoInterfaces["Repository Interfaces"]:::persistence
        RepoImpl["Repository Implementations"]:::persistence
        PersService["Persistence Service Extensions"]:::persistence
    end

    %% Deployment/Infrastructure
    subgraph "Deployment/Infrastructure"
        Dockerfile["Dockerfile"]:::deployment
        DockerCompose["Docker Compose"]:::deployment
        EnvConfig["Environment Config"]:::deployment
    end

    %% Data Storage
    Database(["Database"]):::persistence

    %% Connections between layers
    Controllers -->|"calls"| UseCases
    UseCases -->|"processes"| Entities
    UseCases -->|"validates"| DTOs
    UseCases -->|"invokes"| RepoInterfaces
    RepoImpl -->|"implements"| RepoInterfaces
    RepoImpl -->|"communicates with"| AppDbContext
    AppDbContext -->|"reads/writes"| Database
    AppService -->|"configures"| UseCases
    PersService -->|"configures"| RepoImpl

    %% Click Events for Component Mapping
    click Controllers "https://github.com/bpthiago/estagio-rec/tree/master/EstagioREC/Controllers"
    click UseCases "https://github.com/bpthiago/estagio-rec/tree/master/EstagioREC/Application/UseCases"
    click DTOs "https://github.com/bpthiago/estagio-rec/tree/master/EstagioREC/Application/DTOs"
    click AppService "https://github.com/bpthiago/estagio-rec/blob/master/EstagioREC/Application/Services/ServiceExtensions.cs"
    click Entities "https://github.com/bpthiago/estagio-rec/tree/master/EstagioREC/Domain/Entities"
    click Enumerations "https://github.com/bpthiago/estagio-rec/blob/master/EstagioREC/Domain/Enums/SituacaoEnum.cs"
    click AppDbContext "https://github.com/bpthiago/estagio-rec/blob/master/EstagioREC/Persistence/Data/AppDbContext.cs"
    click RepoInterfaces "https://github.com/bpthiago/estagio-rec/tree/master/EstagioREC/Persistence/Repository/Interfaces"
    click RepoImpl "https://github.com/bpthiago/estagio-rec/tree/master/EstagioREC/Persistence/Repository/Implementations"
    click PersService "https://github.com/bpthiago/estagio-rec/blob/master/EstagioREC/Persistence/ServiceExtensions.cs"
    click Dockerfile "https://github.com/bpthiago/estagio-rec/tree/master/EstagioREC/Dockerfile"
    click DockerCompose "https://github.com/bpthiago/estagio-rec/blob/master/docker-compose.yml"
    click EnvConfig "https://github.com/bpthiago/estagio-rec/blob/master/EstagioREC/Properties/launchSettings.json"

    %% Styles
    classDef presentation fill:#cce5ff,stroke:#005cbf,stroke-width:2px;
    classDef application fill:#d4edda,stroke:#28a745,stroke-width:2px;
    classDef domain fill:#fff3cd,stroke:#ffc107,stroke-width:2px;
    classDef persistence fill:#f8d7da,stroke:#dc3545,stroke-width:2px;
    classDef deployment fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
```
