# mehrdadbahrainy/daprepo architecture

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

- Interactive diagram: https://gitdiagram.com/mehrdadbahrainy/daprepo
- Repository: https://github.com/mehrdadbahrainy/daprepo

## Overview

DapRepo is a Dapper-backed generic repository and unit-of-work library. An application creates a unit of work, obtains an entity repository, and performs CRUD or paged reads; the repository issues SQL through Dapper on the unit of work’s connection. The unit of work opens and disposes that connection and optionally manages a TransactionScope. The sample documents a Person model and SQL table. The sample’s Program and repository wiring are inferred from the README; their source was not sampled.

Main entry points: [`src/DapRepo.DataAccess/UnitOfWork.cs`](https://github.com/mehrdadbahrainy/daprepo/blob/master/src/DapRepo.DataAccess/UnitOfWork.cs) (Unit of Work), [`sample/DapRepo.Sample/DapRepo.Sample/AppUnitOfWork.cs`](https://github.com/mehrdadbahrainy/daprepo/blob/master/sample/DapRepo.Sample/DapRepo.Sample/AppUnitOfWork.cs) (Sample Unit of Work), [`sample/DapRepo.Sample/DapRepo.Sample/Models/Person.cs`](https://github.com/mehrdadbahrainy/daprepo/blob/master/sample/DapRepo.Sample/DapRepo.Sample/Models/Person.cs) (Person Model), [`src/DapRepo.DataAccess/GenericRepository.cs`](https://github.com/mehrdadbahrainy/daprepo/blob/master/src/DapRepo.DataAccess/GenericRepository.cs) (Generic Repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_uow["Unit of Work"]
  node_uow_api["Unit of Work API<br/>[IUnitOfWork.cs]"]
  node_uow_impl["Unit of Work<br/>[UnitOfWork.cs]"]
  node_transaction_scope["Transaction Scope"]
end

subgraph group_repo["Repository Layer"]
  node_generic_api["Repository API"]
  node_generic_repo["Generic Repository"]
  node_key_attribute["Key Attribute<br/>[KeyAttribute.cs]"]
  node_ignore_attribute["Ignore Attribute<br/>[IgnoreAttribute.cs]"]
  node_not_generated["Not Generated"]
end

subgraph group_sample["Person Sample"]
  node_person_repo["Person Repository"]
  node_app_uow["Sample Unit of Work<br/>[AppUnitOfWork.cs]"]
  node_person_model["Person Model<br/>[Person.cs]"]
  node_person_table[("Person Table<br/>[Person.sql]")]
end

node_application(("Application"))
node_connection["Database Connection"]
node_dapper["Dapper"]
node_database[("SQL Database")]

node_application -->|"creates"| node_app_uow
node_app_uow -->|"extends"| node_uow_impl
node_app_uow -->|"creates"| node_connection
node_uow_impl -->|"opens, disposes"| node_connection
node_uow_impl -.->|"manages optionally"| node_transaction_scope
node_app_uow -->|"creates"| node_person_repo
node_person_repo -->|"extends"| node_generic_repo
node_generic_repo -->|"implements"| node_generic_api
node_generic_repo -->|"queries, executes"| node_dapper
node_dapper -->|"uses"| node_connection
node_dapper -->|"executes SQL"| node_database
node_person_repo -->|"uses"| node_person_model
node_person_table -->|"defines table"| node_database
node_person_model -->|"marks key"| node_key_attribute
node_person_model -->|"marks ignored field"| node_ignore_attribute
node_person_model -->|"marks key behavior"| node_not_generated
node_uow_impl -->|"implements"| node_uow_api

click node_uow_api "https://github.com/mehrdadbahrainy/daprepo/blob/master/src/DapRepo.DataAccess/IUnitOfWork.cs"
click node_uow_impl "https://github.com/mehrdadbahrainy/daprepo/blob/master/src/DapRepo.DataAccess/UnitOfWork.cs"
click node_generic_api "https://github.com/mehrdadbahrainy/daprepo/blob/master/src/DapRepo.DataAccess/IGenericRepository.cs"
click node_generic_repo "https://github.com/mehrdadbahrainy/daprepo/blob/master/src/DapRepo.DataAccess/GenericRepository.cs"
click node_person_repo "https://github.com/mehrdadbahrainy/daprepo/blob/master/sample/DapRepo.Sample/DapRepo.Sample/Repositories/PersonRepository.cs"
click node_app_uow "https://github.com/mehrdadbahrainy/daprepo/blob/master/sample/DapRepo.Sample/DapRepo.Sample/AppUnitOfWork.cs"
click node_person_model "https://github.com/mehrdadbahrainy/daprepo/blob/master/sample/DapRepo.Sample/DapRepo.Sample/Models/Person.cs"
click node_person_table "https://github.com/mehrdadbahrainy/daprepo/blob/master/sample/DapRepo.Sample/DapRepo.Sample.Database/dbo/Tables/Person.sql"
click node_key_attribute "https://github.com/mehrdadbahrainy/daprepo/blob/master/src/DapRepo.DataAccess/KeyAttribute.cs"
click node_ignore_attribute "https://github.com/mehrdadbahrainy/daprepo/blob/master/src/DapRepo.DataAccess/IgnoreAttribute.cs"
click node_not_generated "https://github.com/mehrdadbahrainy/daprepo/blob/master/src/DapRepo.DataAccess/NotDbGeneratedAttribute.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_uow_api,node_uow_impl,node_transaction_scope toneBlue
class node_generic_api,node_generic_repo,node_key_attribute,node_ignore_attribute,node_not_generated,node_connection,node_database toneAmber
class node_person_repo,node_app_uow,node_person_model,node_person_table toneMint
class node_application,node_dapper toneIndigo
```

## Components

### Unit of Work

- [Unit of Work API](https://github.com/mehrdadbahrainy/daprepo/blob/master/src/DapRepo.DataAccess/IUnitOfWork.cs): `src/DapRepo.DataAccess/IUnitOfWork.cs`
- [Unit of Work](https://github.com/mehrdadbahrainy/daprepo/blob/master/src/DapRepo.DataAccess/UnitOfWork.cs): `src/DapRepo.DataAccess/UnitOfWork.cs`
- **Transaction Scope**

### Repository Layer

- [Repository API](https://github.com/mehrdadbahrainy/daprepo/blob/master/src/DapRepo.DataAccess/IGenericRepository.cs): `src/DapRepo.DataAccess/IGenericRepository.cs`
- [Generic Repository](https://github.com/mehrdadbahrainy/daprepo/blob/master/src/DapRepo.DataAccess/GenericRepository.cs): `src/DapRepo.DataAccess/GenericRepository.cs`
- [Key Attribute](https://github.com/mehrdadbahrainy/daprepo/blob/master/src/DapRepo.DataAccess/KeyAttribute.cs): `src/DapRepo.DataAccess/KeyAttribute.cs`
- [Ignore Attribute](https://github.com/mehrdadbahrainy/daprepo/blob/master/src/DapRepo.DataAccess/IgnoreAttribute.cs): `src/DapRepo.DataAccess/IgnoreAttribute.cs`
- [Not Generated](https://github.com/mehrdadbahrainy/daprepo/blob/master/src/DapRepo.DataAccess/NotDbGeneratedAttribute.cs): `src/DapRepo.DataAccess/NotDbGeneratedAttribute.cs`

### Person Sample

- [Person Repository](https://github.com/mehrdadbahrainy/daprepo/blob/master/sample/DapRepo.Sample/DapRepo.Sample/Repositories/PersonRepository.cs): `sample/DapRepo.Sample/DapRepo.Sample/Repositories/PersonRepository.cs`
- [Sample Unit of Work](https://github.com/mehrdadbahrainy/daprepo/blob/master/sample/DapRepo.Sample/DapRepo.Sample/AppUnitOfWork.cs): `sample/DapRepo.Sample/DapRepo.Sample/AppUnitOfWork.cs`
- [Person Model](https://github.com/mehrdadbahrainy/daprepo/blob/master/sample/DapRepo.Sample/DapRepo.Sample/Models/Person.cs): `sample/DapRepo.Sample/DapRepo.Sample/Models/Person.cs`
- [Person Table](https://github.com/mehrdadbahrainy/daprepo/blob/master/sample/DapRepo.Sample/DapRepo.Sample.Database/dbo/Tables/Person.sql): `sample/DapRepo.Sample/DapRepo.Sample.Database/dbo/Tables/Person.sql`

### Other components

- **Application**
- **Database Connection**
- **Dapper**
- **SQL Database**

## Connections

- Application → Sample Unit of Work: creates
- Sample Unit of Work → Unit of Work: extends
- Sample Unit of Work → Database Connection: creates
- Unit of Work → Database Connection: opens, disposes
- Unit of Work → Transaction Scope: manages optionally
- Sample Unit of Work → Person Repository: creates
- Person Repository → Generic Repository: extends
- Generic Repository → Repository API: implements
- Generic Repository → Dapper: queries, executes
- Dapper → Database Connection: uses
- Dapper → SQL Database: executes SQL
- Person Repository → Person Model: uses
- Person Table → SQL Database: defines table
- Person Model → Key Attribute: marks key
- Person Model → Ignore Attribute: marks ignored field
- Person Model → Not Generated: marks key behavior
- Unit of Work → Unit of Work API: implements
