# yuri9728/test-api architecture

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

- Interactive diagram: https://gitdiagram.com/yuri9728/test-api
- Repository: https://github.com/yuri9728/test-api

## Overview

##### Main Components
- Domain Layer: Represented by the Test.Domain folder, this layer contains the core business objects (e.g., Author, Book, Genre, User).
- Application Layer: Located in the Test.Application directory, this layer includes DTOs for request/response objects and mapping classes to transform domain entities into DTOs. It acts as an intermediary, ensuring that the presentation layer receives data in an appropriate format.
- Infrastructure Layer: Found in Test.Infrastructure, this includes the database context (AppDbContext) and Entity Framework migrations. It handles data persistence and integration with the database.
- Web API Layer: Within the Test.WebApi folder, this layer exposes HTTP endpoints for functionalities such as authentication and CRUD operations (book, author, and user endpoints). This is the entry point for external clients.
- Configuration & DevOps Components: Notice the Dockerfile, configuration files (appsettings.json, AuthenticationConfiguration, AuthorizationConfiguration, OpenApiConfiguration), and GitHub workflows (.github/workflows) for CI/CD.

##### Relationships and Interactions
- The Web API layer is responsible for handling HTTP requests and then invoking the appropriate logic within the Application layer.
- The Application layer uses mappers to convert incoming DTOs into Domain Entities, applying business rules and validations as needed.
- When persistence is required, the Application layer calls upon the Infrastructure layer (via the DbContext) to query or update the database.
- Authentication and Authorization configurations in the Web API layer ensure secure interactions.

##### Architectural Patterns and Design Principles
- Layered (Clean/Onion) Architecture: This separation of concerns improves maintainability and testability by isolating business logic (Domain) from data access (Infrastructure) and presentation (Web API).
- DTO and Mapper Usage: Clearly delineate how data is transformed between different layers.
- Configuration Separation: The presence of dedicated configuration folders indicates a well-structured approach to handling cross-cutting concerns like security, API documentation (OpenAPI), and environment-specific settings.
- CI/CD and Containerization: The inclusion of Docker-related files and GitHub workflow configurations underscores the project’s deployment and integration practices.

##### Relevant Technologies, Frameworks & Libraries
- .NET (with EF Core) is used for building the API.
- Entity Framework Core is used for managing the database through the AppDbContext and migrations.
- Docker is used for containerization (Dockerfile in the WebApi project).
- GitHub Actions (dotnet.yml) help with continuous integration.

- A clear label for each major component (Domain, Application, Infrastructure, Web API).
- Labels or annotations that describe data flow (e.g., “HTTP Request”, “Data Mapping”, “DB Transaction”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    client("API Consumer/Client"):::clientStyle

    subgraph "Web API Layer"
        webEndpoints("HTTP Endpoints"):::webapiNode
        webConfigs("Configurations"):::webapiNode
    end

    subgraph "Application Layer"
        appDTOs("DTOs"):::appNode
        appMappers("Mappers"):::appNode
    end

    subgraph "Domain Layer"
        domAuthor("Author"):::domainNode
        domBook("Book"):::domainNode
        domGenre("Genre"):::domainNode
        domUser("User"):::domainNode
    end

    subgraph "Infrastructure Layer"
        infraDb("AppDbContext"):::infraNode
        infraMig("Migrations"):::infraNode
    end

    subgraph "Configuration & DevOps"
        devopsDocker("Docker Configuration"):::devopsNode
        devopsCI("CI/CD Workflows"):::devopsNode
        devopsApp("App Settings"):::devopsNode
        devopsAppDev("Dev App Settings"):::devopsNode
    end

    client -->|"HTTPRequest"| webEndpoints
    webEndpoints -->|"calls"| appDTOs
    appDTOs -->|"maps"| appMappers
    appMappers -->|"applies"| domAuthor
    appMappers -->|"applies"| domBook
    appMappers -->|"applies"| domGenre
    appMappers -->|"applies"| domUser
    appMappers -->|"DBTransaction"| infraDb
    infraDb -->|"migrate"| infraMig

    devopsDocker -->|"configures"| webEndpoints
    devopsCI -->|"triggers"| webEndpoints
    devopsApp -->|"loads"| webConfigs
    devopsAppDev -->|"loads"| webConfigs

    click domAuthor "https://github.com/yuri9728/test-api/blob/main/Test.Domain/Author.cs"
    click domBook "https://github.com/yuri9728/test-api/blob/main/Test.Domain/Book.cs"
    click domGenre "https://github.com/yuri9728/test-api/blob/main/Test.Domain/Genre.cs"
    click domUser "https://github.com/yuri9728/test-api/blob/main/Test.Domain/User.cs"

    click appDTOs "https://github.com/yuri9728/test-api/tree/main/Test.Application/DTOs"
    click appMappers "https://github.com/yuri9728/test-api/tree/main/Test.Application/Mappers"

    click infraDb "https://github.com/yuri9728/test-api/blob/main/Test.Infrastructure/DbContexts/AppDbContext.cs"
    click infraMig "https://github.com/yuri9728/test-api/tree/main/Test.Infrastructure/Migrations"

    click webEndpoints "https://github.com/yuri9728/test-api/tree/main/Test.WebApi/Endpoints"
    click webConfigs "https://github.com/yuri9728/test-api/tree/main/Test.WebApi/Configurations"

    click devopsDocker "https://github.com/yuri9728/test-api/tree/main/Test.WebApi/Dockerfile"
    click devopsCI "https://github.com/yuri9728/test-api/blob/main/.github/workflows/dotnet.yml"
    click devopsApp "https://github.com/yuri9728/test-api/blob/main/Test.WebApi/appsettings.json"
    click devopsAppDev "https://github.com/yuri9728/test-api/blob/main/Test.WebApi/appsettings.Development.json"

    classDef clientStyle fill:#f9f,stroke:#333,stroke-width:2px;
    classDef webapiNode fill:#bbf,stroke:#333,stroke-width:2px;
    classDef appNode fill:#bfb,stroke:#333,stroke-width:2px;
    classDef domainNode fill:#ffb,stroke:#333,stroke-width:2px;
    classDef infraNode fill:#fbb,stroke:#333,stroke-width:2px;
    classDef devopsNode fill:#d9bbf9,stroke:#333,stroke-width:2px;
```
