# cssinghnet/dapperaspnetcore architecture

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

- Interactive diagram: https://gitdiagram.com/cssinghnet/dapperaspnetcore
- Repository: https://github.com/cssinghnet/dapperaspnetcore

## Overview

##### Main Components Identification

a) API Layer
- DTOs (CompanyForCreationDto, CompanyForUpdateDto) as supporting components

b) Repository Layer
- ICompanyRepository interface and CompanyRepository implementation
- Repository pattern implementation

c) Data Access Layer
- DapperContext as the database connection manager
- Entity models (Company, Employee)

d) Database Layer
- SQL Server database
- Reference the "Script with Data.sql" for schema representation

##### Component Relationships

**Client Requests → API Controller**
- ↓
- Repository Interface
- ↓
- Repository Implementation
- ↓
- Dapper Context
- ↓
- SQL Database

##### Specific Elements

- Green: API Controllers and DTOs (Public Interface)
- Blue: Repository Layer (Business Logic)
- Orange: Data Access Layer (Dapper Context)
- Gray: Database Layer

- Rectangles: Core components (Controllers, Repositories)
- Rounded Rectangles: DTOs and Entities

##### Technical Details to Highlight

Important aspects:
- Dapper's extension methods on IDbConnection
- Async operation flow
- SQL query execution path
- DTO to Entity mapping

##### Architectural Patterns

Emphasize:
- Repository Pattern implementation
- Dependency Injection (shown in Startup.cs)
- DTO pattern for data transfer
- Separation of Concerns

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        CL[Client Requests]
    end

    subgraph "API Layer"
        CC["CompaniesController"]:::apiController
        CDTO["Company DTOs"]:::dto
    end

    subgraph "Repository Layer"
        IRepo["ICompanyRepository"]:::interface
        Repo["CompanyRepository"]:::repository
    end

    subgraph "Data Access Layer"
        DC["DapperContext"]:::dataAccess
        ENT["Entity Models"]:::entity
    end

    subgraph "Database Layer"
        DB[(SQL Server)]:::database
        SQL["SQL Scripts"]:::database
    end

    %% Relationships
    CL --> CC
    CC --> CDTO
    CC --> IRepo
    IRepo --> Repo
    Repo --> DC
    DC --> DB
    DB --> SQL
    Repo --> ENT

    %% Click Events
    click CC "https://github.com/CSSinghNet/DapperASPNetCore/blob/master/DapperASPNetCore/Controllers/CompaniesController.cs"
    click CDTO "https://github.com/CSSinghNet/DapperASPNetCore/tree/master/DapperASPNetCore/Dto"
    click IRepo "https://github.com/CSSinghNet/DapperASPNetCore/blob/master/DapperASPNetCore/Contracts/ICompanyRepository.cs"
    click Repo "https://github.com/CSSinghNet/DapperASPNetCore/blob/master/DapperASPNetCore/Repository/CompanyRepository.cs"
    click DC "https://github.com/CSSinghNet/DapperASPNetCore/blob/master/DapperASPNetCore/Context/DapperContext.cs"
    click ENT "https://github.com/CSSinghNet/DapperASPNetCore/tree/master/DapperASPNetCore/Entities"
    click SQL "https://github.com/CSSinghNet/DapperASPNetCore/blob/master/Script with Data.sql"

    %% Styles
    classDef apiController fill:#90EE90,stroke:#333,stroke-width:2px
    classDef dto fill:#98FB98,stroke:#333,stroke-width:2px
    classDef interface fill:#ADD8E6,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5
    classDef repository fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef dataAccess fill:#FFA500,stroke:#333,stroke-width:2px
    classDef entity fill:#FFB347,stroke:#333,stroke-width:2px
    classDef database fill:#C0C0C0,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["API Controller"]:::apiController
        L2["DTOs"]:::dto
        L3["Interface"]:::interface
        L4["Repository"]:::repository
        L5["Data Access"]:::dataAccess
        L6["Entity"]:::entity
        L7["Database"]:::database
    end
```
