# rafaelxfernandes/asp.net-core architecture

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

- Interactive diagram: https://gitdiagram.com/rafaelxfernandes/asp.net-core
- Repository: https://github.com/rafaelxfernandes/asp.net-core

## Overview

##### High-Level Architecture Overview
a. Presentation Layer (Web API)
b. Business Logic Layer
c. Data Access Layer
d. Database Layer

##### Component Breakdown

a. Web API Layer (From modules 5 & 6):
- DTOs package (Data Transfer Objects)
- AutoMapper profiles for object mapping
- Swagger documentation component

b. Business Logic Layer:
- Model classes (Filme, Cinema, Endereco, Sessao)
- Exception handling components
- Authentication/Authorization system
- Business rules validators

c. Data Access Layer:
- Entity Framework Core context (FilmeContext)
- Repository patterns
- Migration components
- Database connection handling

##### Relationships and Flows
- Entity relationships:
- Cinema ←→ Endereco (1:1)
- Cinema ←→ Sessao (1:n)
- Filme ←→ Sessao (1:n)

##### Specific Elements
- API endpoints with HTTP methods (GET, POST, PUT, DELETE)
- Database tables with relationships
- Middleware components
- Validation flow
- Error handling flow

##### Technical Details to Highlight
- .NET 6 framework
- Entity Framework Core
- AutoMapper
- Swagger/OpenAPI
- LINQ queries
- SQL Server database

##### Notes for important implementation details

Important Considerations:
- Clear boundaries between different modules
- Progression from basic C# concepts to advanced Web API features
- Error handling paths
- Validation flows
- Points of extension or customization

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Web API Layer"
        Controllers["Controllers"]:::api
        click Controllers "https://github.com/RafaelxFernandes/ASP.NET-Core/tree/master/6 - .NET Relacionando entidades/dotnet-api-2-Aula-5/FilmesApi/Controllers/"
        DTOs["Data Transfer Objects"]:::dto
        click DTOs "https://github.com/RafaelxFernandes/ASP.NET-Core/tree/master/6 - .NET Relacionando entidades/dotnet-api-2-Aula-5/FilmesApi/Data/Dtos/"
        AutoMapper["AutoMapper Profiles"]:::mapper
        click AutoMapper "https://github.com/RafaelxFernandes/ASP.NET-Core/tree/master/6 - .NET Relacionando entidades/dotnet-api-2-Aula-5/FilmesApi/Profiles/"
        Swagger["Swagger Documentation"]:::docs
    end

    subgraph "Business Logic Layer"
        Models["Domain Models"]:::model
        click Models "https://github.com/RafaelxFernandes/ASP.NET-Core/tree/master/6 - .NET Relacionando entidades/dotnet-api-2-Aula-5/FilmesApi/Models/"
        ExceptionHandling["Exception Handling"]:::error
        click ExceptionHandling "https://github.com/RafaelxFernandes/ASP.NET-Core/tree/master/4 - C# Exceções/csharp_exception-Aula5/csharp_exception/"
        Auth["Authentication/Authorization"]:::auth
        Validators["Business Rules Validators"]:::validator
    end

    subgraph "Data Access Layer"
        EFContext["Entity Framework Context"]:::dal
        click EFContext "https://github.com/RafaelxFernandes/ASP.NET-Core/blob/master/6 - .NET Relacionando entidades/dotnet-api-2-Aula-5/FilmesApi/Data/FilmeContext.cs"
        Migrations["Database Migrations"]:::dal
        click Migrations "https://github.com/RafaelxFernandes/ASP.NET-Core/tree/master/6 - .NET Relacionando entidades/dotnet-api-2-Aula-5/FilmesApi/Migrations/"
        DBConnection["Database Connection"]:::dal
    end

    subgraph "Database Layer"
        Database[(SQL Server)]:::db
        subgraph "Entity Relationships"
            Cinema[("Cinema")]:::entity
            Endereco[("Endereco")]:::entity
            Filme[("Filme")]:::entity
            Sessao[("Sessao")]:::entity
        end
    end

    %% Relationships
    Controllers --> DTOs
    DTOs --> AutoMapper
    AutoMapper --> Models
    Controllers --> ExceptionHandling
    Controllers --> Auth
    Models --> Validators
    Models --> EFContext
    EFContext --> Migrations
    Migrations --> DBConnection
    DBConnection --> Database

    %% Entity Relationships
    Cinema --- |1:1| Endereco
    Cinema --- |1:n| Sessao
    Filme --- |1:n| Sessao

    %% Configuration
    Config["Application Configuration"]:::config
    click Config "https://github.com/RafaelxFernandes/ASP.NET-Core/tree/master/6 - .NET Relacionando entidades/dotnet-api-2-Aula-5/FilmesApi/"
    Config --> Controllers
    Config --> EFContext

    %% Styling
    classDef api fill:#2196F3,stroke:#1565C0,color:white
    classDef dto fill:#4CAF50,stroke:#2E7D32,color:white
    classDef model fill:#4CAF50,stroke:#2E7D32,color:white
    classDef dal fill:#FFC107,stroke:#FFA000,color:black
    classDef error fill:#F44336,stroke:#C62828,color:white
    classDef auth fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef db fill:#607D8B,stroke:#455A64,color:white
    classDef entity fill:#78909C,stroke:#546E7A,color:white
    classDef validator fill:#FF9800,stroke:#F57C00,color:white
    classDef mapper fill:#00BCD4,stroke:#0097A7,color:white
    classDef docs fill:#8BC34A,stroke:#689F38,color:white
    classDef config fill:#795548,stroke:#5D4037,color:white
```
